diff --git a/CHANGELOG.md b/CHANGELOG.md index 86ceb2ca..348b62de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ This project adheres to [Semantic Versioning](https://semver.org/). ### Added +- Add support for the `dvh`, `lvh` and `svh` length units (#415) + ### Changed ### Deprecated diff --git a/src/Value/Size.php b/src/Value/Size.php index 19a29d52..5b5ab772 100644 --- a/src/Value/Size.php +++ b/src/Value/Size.php @@ -19,7 +19,12 @@ class Size extends PrimitiveValue * * @internal */ - const ABSOLUTE_SIZE_UNITS = ['px', 'cm', 'mm', 'mozmm', 'in', 'pt', 'pc', 'vh', 'vw', 'vmin', 'vmax', 'rem']; + const ABSOLUTE_SIZE_UNITS = [ + 'px', 'pt', 'pc', + 'cm', 'mm', 'mozmm', 'in', + 'vh', 'dvh', 'svh', 'lvh', + 'vw', 'vmin', 'vmax', 'rem', + ]; /** * @var array diff --git a/tests/Value/SizeTest.php b/tests/Value/SizeTest.php new file mode 100644 index 00000000..d743087a --- /dev/null +++ b/tests/Value/SizeTest.php @@ -0,0 +1,51 @@ + + */ + public static function provideUnit() + { + $units = [ + 'px', 'pt', 'pc', + 'cm', 'mm', 'mozmm', 'in', + 'vh', 'dvh', 'svh', 'lvh', + 'vw', 'vmin', 'vmax', 'rem', + '%', 'em', 'ex', 'ch', 'fr', + 'deg', 'grad', 'rad', 's', 'ms', 'turn', 'Hz', 'kHz', + ]; + + return \array_combine( + $units, + \array_map( + function ($unit) { + return [$unit]; + }, + $units + ) + ); + } + + /** + * @test + * + * @dataProvider provideUnit + */ + public function parsesUnit($unit) + { + $subject = Size::parse(new ParserState('1' . $unit, Settings::create())); + + self::assertSame($unit, $subject->getUnit()); + } +}