Skip to content

Commit 841f697

Browse files
authored
Merge pull request #165 from raxbg/fix/size_render
Fix/size render
2 parents 86fd609 + 3619a6c commit 841f697

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

lib/Sabberworm/CSS/Value/Size.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ public function __toString() {
115115
public function render(\Sabberworm\CSS\OutputFormat $oOutputFormat) {
116116
$l = localeconv();
117117
$sPoint = preg_quote($l['decimal_point'], '/');
118-
return preg_replace(array("/$sPoint/", "/^(-?)0\./"), array('.', '$1.'), $this->fSize) . ($this->sUnit === null ? '' : $this->sUnit);
118+
$sSize = preg_match("/[\d\.]+e[+-]?\d+/i", (string)$this->fSize) ? preg_replace("/$sPoint?0+$/", "", sprintf("%f", $this->fSize)) : $this->fSize;
119+
return preg_replace(array("/$sPoint/", "/^(-?)0\./"), array('.', '$1.'), $sSize) . ($this->sUnit === null ? '' : $this->sUnit);
119120
}
120121

121122
}

tests/Sabberworm/CSS/ParserTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,4 +754,10 @@ function testMicrosoftFilterParsing() {
754754
$sExpected = ".test {filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=\"#80000000\",endColorstr=\"#00000000\",GradientType=1);}";
755755
$this->assertSame($sExpected, $oDoc->render());
756756
}
757+
758+
function testLargeSizeValuesInFile() {
759+
$oDoc = $this->parsedStructureForFile('large-z-index', Settings::create()->withMultibyteSupport(false));
760+
$sExpected = '.overlay {z-index: 10000000000000000000000;}';
761+
$this->assertSame($sExpected, $oDoc->render());
762+
}
757763
}

tests/files/large-z-index.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.overlay {
2+
z-index: 9999999999999999999999;
3+
}

0 commit comments

Comments
 (0)