Skip to content

Commit 77d5d02

Browse files
committed
Merge remote-tracking branch 'slusarz/size'
Closes #57 as fixed
2 parents 3d356f4 + a328f71 commit 77d5d02

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

lib/Sabberworm/CSS/Value/Size.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function isRelative() {
5757
}
5858

5959
public function __toString() {
60-
return $this->fSize . ($this->sUnit === null ? '' : $this->sUnit);
60+
return str_replace('0.', '.', $this->fSize) . ($this->sUnit === null ? '' : $this->sUnit);
6161
}
6262

63-
}
63+
}

tests/Sabberworm/CSS/ParserTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function testColorParsing() {
5555
$this->assertEquals(array('r' => new Size(35.0, null, true), 'g' => new Size(35.0, null, true), 'b' => new Size(35.0, null, true)), $aValues[0][0]->getColor());
5656
$aColorRule = $oRuleSet->getRules('border-color');
5757
$aValues = $aColorRule[0]->getValues();
58-
$this->assertEquals(array('r' => new Size(10.0, null, true), 'g' => new Size(100.0, null, true), 'b' => new Size(230.0, null, true), 'a' => new Size(0.3, null, true)), $aValues[0][0]->getColor());
58+
$this->assertEquals(array('r' => new Size(10.0, null, true), 'g' => new Size(100.0, null, true), 'b' => new Size(230.0, null, true), 'a' => new Size("0000.3", null, true)), $aValues[0][0]->getColor());
5959
$aColorRule = $oRuleSet->getRules('outline-color');
6060
$aValues = $aColorRule[0]->getValues();
6161
$this->assertEquals(array('r' => new Size(34.0, null, true), 'g' => new Size(34.0, null, true), 'b' => new Size(34.0, null, true)), $aValues[0][0]->getColor());
@@ -149,7 +149,7 @@ function testSpecificity() {
149149

150150
function testManipulation() {
151151
$oDoc = $this->parsedStructureForFile('atrules');
152-
$this->assertSame('@charset "utf-8";@font-face {font-family: "CrassRoots";src: url("../media/cr.ttf");}html, body {font-size: -0.6em;}
152+
$this->assertSame('@charset "utf-8";@font-face {font-family: "CrassRoots";src: url("../media/cr.ttf");}html, body {font-size: -.6em;}
153153
@keyframes mymove {from {top: 0px;}
154154
to {top: 200px;}
155155
}@-moz-keyframes some-move {from {top: 0px;}
@@ -167,7 +167,7 @@ function testManipulation() {
167167
$oSelector->setSelector('#my_id ' . $oSelector->getSelector());
168168
}
169169
}
170-
$this->assertSame('@charset "utf-8";@font-face {font-family: "CrassRoots";src: url("../media/cr.ttf");}#my_id html, #my_id body {font-size: -0.6em;}
170+
$this->assertSame('@charset "utf-8";@font-face {font-family: "CrassRoots";src: url("../media/cr.ttf");}#my_id html, #my_id body {font-size: -.6em;}
171171
@keyframes mymove {from {top: 0px;}
172172
to {top: 200px;}
173173
}@-moz-keyframes some-move {from {top: 0px;}
@@ -181,12 +181,12 @@ function testManipulation() {
181181
}', $oDoc->__toString());
182182

183183
$oDoc = $this->parsedStructureForFile('values');
184-
$this->assertSame('#header {margin: 10px 2em 1cm 2%;font-family: Verdana,Helvetica,"Gill Sans",sans-serif;font-size: 10px;color: red !important;background-color: green;background-color: rgba(0,128,0,0.7);}
184+
$this->assertSame('#header {margin: 10px 2em 1cm 2%;font-family: Verdana,Helvetica,"Gill Sans",sans-serif;font-size: 10px;color: red !important;background-color: green;background-color: rgba(0,128,0,.7);}
185185
body {color: green;font: 75% "Lucida Grande","Trebuchet MS",Verdana,sans-serif;}' . "\n", $oDoc->__toString());
186186
foreach ($oDoc->getAllRuleSets() as $oRuleSet) {
187187
$oRuleSet->removeRule('font-');
188188
}
189-
$this->assertSame('#header {margin: 10px 2em 1cm 2%;color: red !important;background-color: green;background-color: rgba(0,128,0,0.7);}
189+
$this->assertSame('#header {margin: 10px 2em 1cm 2%;color: red !important;background-color: green;background-color: rgba(0,128,0,.7);}
190190
body {color: green;}' . "\n", $oDoc->__toString());
191191
foreach ($oDoc->getAllRuleSets() as $oRuleSet) {
192192
$oRuleSet->removeRule('background-');
@@ -248,9 +248,9 @@ function testSlashedValues() {
248248
function testFunctionSyntax() {
249249
$oDoc = $this->parsedStructureForFile('functions');
250250
$sExpected = 'div.main {background-image: linear-gradient(rgb(0,0,0),rgb(255,255,255));}
251-
.collapser::before, .collapser::-moz-before, .collapser::-webkit-before {content: "»";font-size: 1.2em;margin-right: 0.2em;-moz-transition-property: -moz-transform;-moz-transition-duration: 0.2s;-moz-transform-origin: center 60%;}
251+
.collapser::before, .collapser::-moz-before, .collapser::-webkit-before {content: "»";font-size: 1.2em;margin-right: .2em;-moz-transition-property: -moz-transform;-moz-transition-duration: .2s;-moz-transform-origin: center 60%;}
252252
.collapser.expanded::before, .collapser.expanded::-moz-before, .collapser.expanded::-webkit-before {-moz-transform: rotate(90deg);}
253-
.collapser + * {height: 0;overflow: hidden;-moz-transition-property: height;-moz-transition-duration: 0.3s;}
253+
.collapser + * {height: 0;overflow: hidden;-moz-transition-property: height;-moz-transition-duration: .3s;}
254254
.collapser.expanded + * {height: auto;}' . "\n";
255255
$this->assertSame($sExpected, $oDoc->__toString());
256256

@@ -259,15 +259,15 @@ function testFunctionSyntax() {
259259
$mValue->setSize($mValue->getSize() * 3);
260260
}
261261
}
262-
$sExpected = str_replace(array('1.2em', '0.2em', '60%'), array('3.6em', '0.6em', '180%'), $sExpected);
262+
$sExpected = str_replace(array('1.2em', '.2em', '60%'), array('3.6em', '.6em', '180%'), $sExpected);
263263
$this->assertSame($sExpected, $oDoc->__toString());
264264

265265
foreach ($oDoc->getAllValues(null, true) as $mValue) {
266266
if ($mValue instanceof Size && !$mValue->isRelative() && !$mValue->isColorComponent()) {
267267
$mValue->setSize($mValue->getSize() * 2);
268268
}
269269
}
270-
$sExpected = str_replace(array('0.2s', '0.3s', '90deg'), array('0.4s', '0.6s', '180deg'), $sExpected);
270+
$sExpected = str_replace(array('.2s', '.3s', '90deg'), array('.4s', '.6s', '180deg'), $sExpected);
271271
$this->assertSame($sExpected, $oDoc->__toString());
272272
}
273273

@@ -316,7 +316,7 @@ function testListValueRemoval() {
316316
continue;
317317
}
318318
}
319-
$this->assertSame('html, body {font-size: -0.6em;}' . "\n", $oDoc->__toString());
319+
$this->assertSame('html, body {font-size: -.6em;}' . "\n", $oDoc->__toString());
320320

321321
$oDoc = $this->parsedStructureForFile('nested');
322322
foreach ($oDoc->getAllDeclarationBlocks() as $oBlock) {

0 commit comments

Comments
 (0)