According to the spec, as long as the given string can be parsed into a <dimension-token>, the return value is the reification of the token. And reification doesn't have type checking, either.
So CSSNumericValue.parse('1xyz') should return something non-null, which doesn't make sense, and is inconsistent with the CSSUnitValue(value, type) constructor, which throws when the type is invalid.
I think we should throw a SyntaxError when the unit is invalid. I'll put up a PR to fix it.
According to the spec, as long as the given string can be parsed into a
<dimension-token>
, the return value is the reification of the token. And reification doesn't have type checking, either.So
CSSNumericValue.parse('1xyz')
should return something non-null, which doesn't make sense, and is inconsistent with the CSSUnitValue(value, type) constructor, which throws when the type is invalid.I think we should throw a
SyntaxError
when the unit is invalid. I'll put up a PR to fix it.