Re: [csswg-drafts] [web-animations-1] Dependency on CSSPseudoElement (#4301)

We discussed this issue today at the cross-browser Animations sync. Motivated by #4398 , we agreed that for compatibility with what we _expect_ events will evolve to for `CSSPseudoElement`, we are going to drop web-animations-1's dependency on `CSSPseudoElement` and instead modify `KeyframeEffect` to have both a `target` and a `pseudoElement` selector string. To animate a pseudo-element, the web author would do something like:

`element.animate(keyframes, { duration: 1000, pseudoElement: '::before' });`

This is a significant change, and does have an impact on both web developers mental model of animations as well as arguably the ergonomics of the API. For example a given `animation` would not necessarily target its `` - one must consider the `animation.effect.pseudoElement` selector too. Note that it is not (afaik) currently possible in any browser to obtain a JS handle to an animation on a pseudo-element, so we shouldn't be regressing on anything there.

Given the significance of the chance, adding this to CSSWG agenda to make sure it is visible and that the justification based on expected EventTarget changes (see below) are reasonable.

**Event Target Justification**

There are (many) existing events today that can be aimed at pseudo elements; 'click' being an obvious case. It is our understanding that currently such events have a `target` of the parent `Element`, rather than the (non-existent) `CSSPseudoElement` object.

In a world where `CSSPseudoElement` ships, it seems too breaking to have events (e.g. click) that target pseudo elements now return the `CSSPseudoElement` object for their `target`. Instead, we assume that they would follow the same style as [css-transitions-1]( or [css-animations-1]( events and add a `pseudoElement` selector to the event IDL  (or we could just continue to rely on [lovely hacks such as these?]( :D).

GitHub Notification of comment by stephenmcgruer
Please view or discuss this issue at using your GitHub account

Received on Tuesday, 8 October 2019 21:55:51 UTC