w3c / css-houdini-drafts

Mirror of https://hg.css-houdini.org/drafts
https://drafts.css-houdini.org/
Other
1.84k stars 141 forks source link

[css-typed-om] CSSNumericValue.parse() needs type checking for `<dimension-token>` #1064

Closed xiaochengh closed 2 years ago

xiaochengh commented 2 years ago

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.