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.

Probing this browser…

1 · click the generated content

Release notes
Origin trial sign-up
  1. Tap the number (::marker)
  2. …or this one

Pseudo-elements cannot take keyboard focus, so these buttons run the same inspector on objects fetched with pseudo():

No hit yet. Click a badge, an arrow or a list number.

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.

Pick a name to walk its chain.

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
});

see also