Skip to content

[web-animations-2] Enable using Web Animations API with nested pseudo elements #7469

@khushalsagar

Description

@khushalsagar

The WA-API allows targeting pseudo elements originating from a DOM element using pseudoElement in KeyframeEffectOptions. See the following description in the spec here:

"pseudoElement, of type CSSOMString, nullable, defaulting to null
The pseudo-element selector (which must be valid or null) used to specify the effect target given the target element."

This is currently limited to pseudo elements which are direct descendants of the target element. The proposal is to allow using any pseudo element selector to target nested pseudo elements originating from the target element. For example,

The following could be use to target a marker nested inside the before pseudo element.

element.animate(keyframes, {
      ...animationOptions,
      pseudoElement: "::before::marker",
});

Or with the new selectors introduced in #7346, the above could be this instead.

element.animate(keyframes, {
      ...animationOptions,
      pseudoElement: "::>>marker",
});

Since the selector above could match multiple elements, the effect target would resolve to the first element matching the selector (similar to 'document.querySelector').

The above use-case will be common with shared element transitions which generates a tree of pseudo elements to animate.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions