Skip to content

Commit 77908d1

Browse files
committed
Bug fix in rendering very big or very small size values - they were previously rendered in scientific notation
1 parent a90142f commit 77908d1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/Sabberworm/CSS/Value/Size.php

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

122123
}

0 commit comments

Comments
 (0)