Skip to content

Commit ddd9c85

Browse files
ssddanbrownbsweeney
authored andcommitted
Fixed rems being parsed as em units
Caused by unit handling checking for em units before rems, hence mis-identifying the unit.
1 parent 0514b5c commit ddd9c85

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/Svg/CssLength.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,28 @@ class CssLength
66
{
77
/**
88
* Array of valid css length units.
9-
* Should be pre-sorted so no earlier length is contained within a latter (eg. 'in' within 'vmin').
9+
* Should be pre-sorted by unit text length so no earlier length can be
10+
* contained within a latter (eg. 'in' within 'vmin').
1011
*
1112
* @var string[]
1213
*/
1314
protected static $units = [
15+
'vmax',
1416
'vmin',
17+
'rem',
1518
'px',
16-
'%',
1719
'pt',
1820
'cm',
1921
'mm',
20-
'q',
2122
'in',
2223
'pc',
2324
'em',
24-
'rem',
2525
'ex',
2626
'ch',
2727
'vw',
2828
'vh',
29-
'vmax'
29+
'%',
30+
'q',
3031
];
3132

3233
/**

tests/Svg/CssLengthTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function test_getUnit()
4242
$this->assertEquals('vmin', (new CssLength('40vmin'))->getUnit());
4343
$this->assertEquals('q', (new CssLength('50Q'))->getUnit());
4444
$this->assertEquals('', (new CssLength('50GB'))->getUnit());
45+
$this->assertEquals('rem', (new CssLength('44.5435rem'))->getUnit());
4546
}
4647

4748
}

0 commit comments

Comments
 (0)