-
Notifications
You must be signed in to change notification settings - Fork 143
When doing CSSStyleValue.parse(), what should throw vs return null? #305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
My gut feeling says throw for 1 and return Sebastian |
I think 2 is more or less the same as 3 - in each case, it's possible that the failure is due to uneven implementation across different browsers. |
@SebastianZ WDYT? Should 2 be like 3, or distinguishable? |
I stand with my previous comment that 2 and 3 should be distinguishable. Sebastian |
Currently specified behavior is:
This satisfies distinguishability. Remaining question: should 3. return null instead? |
This makes 1 and 3 hard to distinguish, so I still say return Sebastian |
I'm leaning that way too. @tabatkins ? |
#1 is definitely a SyntaxError, no question in my mind. I think #2 being a TypeError has strong reasoning behind it. I don't have strong opinions on #3. I guess I think I'd rather have them both throw, with whatever error is most appropriate, and solve the "wrong property, or wrong value?" problem more directly. That sounds like an API idea we can work on. I don't think we should smuggle the use-case into which error we emit. |
The CSS Working Group just discussed #305, and agreed to the following resolutions:
The full IRC log of that discussion
|
Let's do TypeError for everything; that's the error we're currently consistently throwing in all the StylePropertyMap similar cases, and they don't even check for whether the string is a valid ident. |
present, CSSStyleValue.parse/parseAll thrown type or syntax error. but CSSStyleValue.parse/parseAll was decided to throw only type error. w3c/css-houdini-drafts#305 Bug: 798937 Change-Id: I00d6855d1b3667441d009d8d3551daed970cab1a Reviewed-on: https://chromium-review.googlesource.com/849972 Reviewed-by: Darren Shen <shend@chromium.org> Commit-Queue: Hwanseung Lee <hs1217.lee@samsung.com> Cr-Commit-Position: refs/heads/master@{#527126}
The old (very incomplete) definition of CSSStyleValue.parse() said that things returned null if they didn't parse. I've rewritten it in a proper algorithmic style, and identified three possible error locations. Which should throw, and which should return null? (Currently, the spec throws for all of them.)
The text was updated successfully, but these errors were encountered: