-
Notifications
You must be signed in to change notification settings - Fork 658
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
[web-animations-1] Fix invalid error code for KeyfameEffect.pseudoElement #4829
Conversation
I'm OOO currently; can one of the other editors take a look please? |
I'm not sure. I think we're trying to match WebIDL semantics here which throws a JS TypeError for an invalid enum value, for example. |
There's definitely a case for a JS TypeError. Are there any other examples of it being used for an invalid value outside an infinite family of strings (SyntaxError seems to be used here a lot), or just for values outside finite enums? |
One example is that in the process a keyframes argument procedure right towards the end we have:
So at least within Web Animations, we currently always use a TypeError. I don't recall exactly how we ended up there. There was certainly at least one case where we were deciding between SyntaxError or TypeError and the advice we got was something along the lines of, "We normally use TypeError, but it doesn't really matter". Maybe @heycam recalls? |
To me it seems like either will work. When i asked @stephenmcgruer, he referenced me to the DOMException part fo the WebIDL spec defining
|
Oh, that seems pretty clear then! |
That makes me think we should update the parsing of easing to throw a SyntaxError too. Mind fixing that too? |
There is the potential for web compat issues there (slight since its still an exception, but technically authors could be catching TypeErrors specifically currently), right? I think it's probably still reasonable, but just something to think about. |
Yes, that's right. I might be being a bit optimistic that no-one is watching specifically for TypeErrors from those procedures. |
It looks looks there are a lot more places (including all of keyframe parsing) besides parsing easing that uses TypeError for infinite families of values instead of the more specific DOMException error types (SyntaxError, RangeError, etc). I now think that this should make the error for pseudo-element selectors a TypeError for consistency and that changing them to the more specific codes should be for another issue. |
@birtles @stephenmcgruer what do you think? |
I had a quick skim through the spec yesterday and the only two places where I thought SyntaxError would make sense were Regarding So I would be happy with making But all in all, I don't mind too much either way. |
Sounds good to me. Patch is ready on my end. |
Update web-animations WPT tests to incorporate the error handling fix w3c/csswg-drafts#4829 Clean-up incorrect test cases which matched neither the old or new error handling procedures. Make KeyFrameEffect() reject the empty string as a pseudo-selector as in the spec. Delete two tests checking CSSPseudoElement identity (since we now return strings instead) and replace with a tect checking the returned string against a literal. These should have been removed in https://chromium-review.googlesource.com/c/chromium/src/+/1894477 but were overlooked. Change-Id: I5e9edc498bf3dad68ae683cd466ad41554cf10e4
Since
TypeError
is not a valid DOMException error name, change it toSyntaxError
(the code for this kind of type error).