Skip to content

Commit 6698b77

Browse files
committed
Merge pull request MyIntervals#65 from yunosh/fix-size-values
Only replace 0. with . at the begin of a size value.
2 parents f07018f + 8ca038a commit 6698b77

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

lib/Sabberworm/CSS/Value/Size.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function isRelative() {
6161

6262
public function __toString() {
6363
$l = localeconv();
64-
return str_replace(array($l['decimal_point'], '0.'), '.', $this->fSize) . ($this->sUnit === null ? '' : $this->sUnit);
64+
return preg_replace(array('/' . preg_quote($l['decimal_point'], '/') . '/', '/^(-?)0\./'), '$1.', $this->fSize) . ($this->sUnit === null ? '' : $this->sUnit);
6565
}
6666

6767
}

tests/Sabberworm/CSS/RuleSet/LenientParsingTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function testFaultToleranceOn() {
2020
$sFile = dirname(__FILE__) . '/../../../files' . DIRECTORY_SEPARATOR . "-fault-tolerance.css";
2121
$oParser = new Parser(file_get_contents($sFile), Settings::create()->withLenientParsing(true));
2222
$oResult = $oParser->parse();
23-
$this->assertSame('.test1 {}'."\n".'.test2 {hello: 2.2;hello: 200000000000.2;}'."\n".'#test {}'."\n".'#test2 {help: none;}'."\n", $oResult->__toString());
23+
$this->assertSame('.test1 {}'."\n".'.test2 {hello: 2.2;hello: 2000000000000.2;}'."\n".'#test {}'."\n".'#test2 {help: none;}'."\n", $oResult->__toString());
2424
}
2525

2626
/**
@@ -37,7 +37,7 @@ public function testLocaleTrap() {
3737
$sFile = dirname(__FILE__) . '/../../../files' . DIRECTORY_SEPARATOR . "-fault-tolerance.css";
3838
$oParser = new Parser(file_get_contents($sFile), Settings::create()->withLenientParsing(true));
3939
$oResult = $oParser->parse();
40-
$this->assertSame('.test1 {}'."\n".'.test2 {hello: 2.2;hello: 200000000000.2;}'."\n".'#test {}'."\n".'#test2 {help: none;}'."\n", $oResult->__toString());
40+
$this->assertSame('.test1 {}'."\n".'.test2 {hello: 2.2;hello: 2000000000000.2;}'."\n".'#test {}'."\n".'#test2 {help: none;}'."\n", $oResult->__toString());
4141
}
4242

4343
public function testCaseInsensitivity() {

tests/phpunit.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<phpunit bootstrap="bootstrap.php"></phpunit>

0 commit comments

Comments
 (0)