CSSPseudoElement is currently only defined for ::after, ::before and ::marker, but ::backdrop and ::view-transitions also make sense to be added there.
E.g. ::backdrop is useful to close a dialog when its backdrop is clicked, without interfering with clicks inside the dialog content.
dialog.addEventListener('click', (event) => {
if (event.pseudoTarget?.type === '::backdrop') {
dialog.close();
}
});
without involving any intersection code to determine if the dialog itself vs ::backdrop has been clicked.
And ::view-transitions can be used to do a geometry-aware view transition we can read the bounding rect of ::view-transition-old to set a custom animation origin.
document.addEventListener('transitionstart', (event) => {
if (event.pseudoTarget?.type === '::view-transition-old') {
const rect = event.pseudoTarget.getBoundingClientRect();
setTransformOrigin(rect);
}
});
or intercept VT mid-flight to start a new one, while knowing the coordinates of the currently aminating element to avoid sudden jumps and such.
CSSPseudoElement is currently only defined for ::after, ::before and ::marker, but
::backdropand::view-transitions also make sense to be added there.E.g.
::backdropis useful to close a dialog when its backdrop is clicked, without interfering with clicks inside the dialog content.without involving any intersection code to determine if the dialog itself vs
::backdrophas been clicked.And
::view-transitions can be used to do a geometry-aware view transition we can read the bounding rect of::view-transition-oldto set a custom animation origin.or intercept VT mid-flight to start a new one, while knowing the coordinates of the currently aminating element to avoid sudden jumps and such.