@@ -86,7 +86,7 @@ export function isLineStyle( string ) {
return lineStyleValues.includes( string );
}
-const lengthRegExp = /^([+-]?[0-9]*[.]?[0-9]+([a-z]+|%)|0)$/;
+const lengthRegExp = /^([+-]?[0-9]*[.]?[0-9]+(px|cm|mm|in|pc|pt|ch|em|ex|rem|vh|vw|vmin|vmax|%)|0)$/;
/**
* Checks if string contains [length](https://developer.mozilla.org/en-US/docs/Web/CSS/length) CSS value.
@@ -124,7 +124,36 @@ describe( 'Styles utils', () => {
describe( 'isLength()', () => {
it( 'returns true for various units', () => {
testValues(
- [ '1px', '2rem', '34.5px', '.2em', '0', '1346vmax' ],
+ [
+ '1px',
+ '1cm',
+ '1mm',
+ '1in',
+ '1pc',
+ '1pt',
+ '1ch',
+ '1em',
+ '1ex',
+ '1rem',
+ '1vh',
+ '1vw',
+ '1vmin',
+ '1vmax'
+ ],
+ isLength
+ );
+ } );
+
+ it( 'returns true for various values notation', () => {
+ testValues(
+ '0',
+ '1000px',
+ '1.1px',
+ '345.457px',
+ '.457px'
isLength
);
} );