v160 · javascript · cssom
pseudoTarget inspector
An inspection tool, devtools-style. Click or tap generated content — a ::before badge, an ::after arrow, a list ::marker — and the page reads event.pseudoTarget, the CSSPseudoElement the hit landed on. It prints type, the new selectorText, the parent/element chain, and whether pseudoTarget.element.pseudo(selectorText) hands back the very same object. A second panel walks a nested view-transition chain, where every level shares a type and only selectorText tells you which snapshot you are holding.
chrome://flags/#enable-experimental-web-platform-features and relaunch, or start Chrome/Canary with --enable-blink-features=CSSPseudoElementSelectorText (Finch name: --enable-features=CSSPseudoElementSelectorText). event.pseudoTarget and type keep working without it; the readout labels selectorText as not exposed rather than inventing one.
1 · click the generated content
- Tap the number (::marker)
- …or this one
Pseudo-elements cannot take keyboard focus, so these buttons run the same inspector on objects fetched with pseudo():
2 · walk a view-transition chain
Choose a transition name, then walk html.pseudo("::view-transition-group(N)") → .pseudo("::view-transition-image-pair(N)") → .pseudo("::view-transition-old(N)") and back up through .parent.
the inspector, verbatim
document.addEventListener("click", (e) => {
const p = e.pseudoTarget; // CSSPseudoElement or null
if (!p) return;
log(p.type, p.selectorText); // "::before", "::before"
for (let n = p; n instanceof CSSPseudoElement; n = n.parent)
log(" ↳", n.selectorText); // nested pseudo chain, innermost first
p.element.pseudo(p.selectorText) === p; // true — same object back
});