The Web Animations specification has added a `pseudoElement` property on `KeyframeEffect`, see bug 207290 tracking its implementation in WebKit. However, `Element` currently only exposes `beforePseudoElement` and `afterPseudoElement` and these are only created under certain circumstances, mostly if `content` is set for one of those pseudo-elements. It appears that pseudo-elements should also be created as needed to be the target of an animation, regardless of what `content` is set to. Specifically, the specification for `content: none` says: On elements, this inhibits the children of the element from being rendered as children of this element, as if the element was empty. On pseudo-elements it inhibits the creation of the pseudo-element as if it had display: none. In neither case does it prevent any pseudo-elements which have this element or pseudo-element as an originating element from being generated. It would be great to have a method along the lines of `Element::ensurePseudoElement(PseudoId)` where we can get a `PseudoElement` for any of our known pseudo-elements.
<rdar://problem/59199400>
PseudoElement class in general is extremely underspec’ed (e.g. lifetime of these objects is completely unspecified or badly specified). So we need to figure out how PseudoElement’s lifecycle is managed.
Note that this request is unrelated to exposing PseudoElement, the Web Animations API only exposes an Element/CSSOMString pair.
PseudoElement is an implementation detail, not exposed to web in any direct way. It was a bad idea from the start.
I think it was originally added to make before/after animatable. The right way to do that would have been to make Element/pseudo pairs animatable rather adding a confusing internal Element subclass.
Note that only before/after generate PseudoElements. I deliberately got rid of ensurePseudoElement(PseudoId) functions at some point to reduce confusion and prevent people from writing code that would create PseudoElements in other cases. The right direction here is to eliminate PseudoElement completely. Should be easier when the new animation system is fully in place.