-
Notifications
You must be signed in to change notification settings - Fork 669
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] Error handling in KeyframeEffect.pseudoElement #4586
Comments
There's also the option of making it read-only. (i.e. you can only animate pseudos via CSS animations/transitions.) Otherwise I'd lean towards 4 with a console warning. |
Is there any way to add error detection to 4? |
In my current patch do far I do 4 with the but it throws an exception if the selector does not start with a double-colon. An unknown selector gets stored and not animated. |
Look up the computed style for the pseudo and see if it is being animated? What's the use case where you want to do error detection on a if a pseudo is valid or not? Given you can't set style on an arbitrary pseudo from JS presently with constructing a stylesheet, I wonder if being able to animate an arbitrary pseudo from Web Animations API is necessary. Can we make this read-only initially and then make it writable later? |
If we drew a parallel to Of course, detecting support then becomes a problem; what if the web author wants to animate the const div = document.createElement('div');
const anim = div.animate({ top: ['100px', '100px']}, { pseudoElement: myPseudoElement });
const supported = getComputedStyle(div, myPseudoElement).top === '100px';
div.remove();
return supported; Given that, I think I'm coming down on 4. Console warning is an interesting question; I tend to lean away from adding them as each one lowers the chance that developers will actually pay attention to the console. But if a given browser felt it was important to warn the developer, they of course could do so?
It feels weird to me to say that one of the goals of Web Animations is to give authors much finer control over their animations, and then say "but only for animations of non-pseudo elements". |
Note that there are resolutions to get |
Right, I think Amelia's comment here sums gCS up best: #3980 (comment) . However we don't have to worry about the compat questions, we 'just' have to get it right to avoid problems when a given pseudo-element is supported in some browsers but not others or when a new pseudo-element becomes supported in all browsers. In what way do you think you wouldn't emulate gCS @emilio ? |
In the "eating the error" when parsing a pseudo. I think throwing or other kind of error handling is fine :) |
So far in my pending implementation I'm doing as @stephenmcgruer suggests and throwing if it doesn't start with a colon, and eating the error otherwise. I think this will work at least as a transitional form. I share stephen's concerns about rolling out pseudo-elements (also blink's pseudo-element code is a bit flaky so this makes it merely fail to animate instead of crashing the page). |
FWIW, we also need to fix the spec text for
but it doesn't make any sense to claim that the selector must be valid. It's a dictionary so the author can set it to whatever they like. If we want to restrict the set of valid values we need to define the behavior at the points where it is accepted. Presumably that behavior will match what we do here for the |
Fixup of w3c#4437 addressing w3c#4301. * Add pseudoElement option to KeyframeEffect constructor body * Fix w3c#4502 adding catch-all pseudo-element case to composite order * Fix w3c#4586 adding error handling to KeyframeEffect.pseudoElement * Fix w3c#4701 making note of case when property values cannot be calculated
…change. (#4616) Fixup of #4437 addressing #4301. * Add pseudoElement option to KeyframeEffect constructor body * Fixes #4502 by adding catch-all pseudo-element case to composite order * Fixes #4586 by adding error handling to KeyframeEffect.pseudoElement * Fixes #4701 by handling cases when property values cannot be calculated
What should KeyframeEffect.pseudoElement do if it is set in an invalid or unsupported value? I can see a few possibilities here.
Throw an exception. This can easily break backwards compatibility as the set of pseudo-elements is not currently fixed. Running an animation with a new pseudoelement on an old browser can crash the whole script. I think it makes sense for inputs that don't start with "::" though.
Set pseudoElement to null. This fails without crashing but has the disadvantage of causing animations to happen on the wrong element in the case of an unsupported pseudo-element.
Leave pseudoElement unchanged. Again, can cause false positives.
Set pseudoElement to the text given and do not animate.
Set pseudoElement to s sentinel value (such as
::unknown
) which has no effect. Allows for error detection without the possibility of crashes.My personal preference is for option 5.
The text was updated successfully, but these errors were encountered: