v160 · javascript · cssom

type vs selectorText lab

Feed any pseudo-element string to element.pseudo() and compare the two strings the returned CSSPseudoElement gives back: type is only the base name ("::view-transition-group"), selectorText is the full, normalized, round-trippable selector ("::view-transition-group(hero)"). Legacy :before normalizes to ::before; whitespace inside the parentheses is dropped; identifiers that need escaping come back escaped.

Probing this browser…

Originating elements

#subject

has ::before and ::after

#list li

  • styled ::marker

#scroller

one
two
three

<html>

originates every ::view-transition-* pseudo-element

Presets

Or type your own

Pick a preset or call pseudo() to see type and selectorText side by side.
Every pseudo() call made on this page
calltypeselectorTextspec expects
no calls yet

what the lab proves

const g = document.documentElement.pseudo("::view-transition-group(hero)");
g.type          // "::view-transition-group"         — kind only
g.selectorText  // "::view-transition-group(hero)"   — kind + argument

el.pseudo(":before").selectorText               // "::before"  (legacy colon normalized)
scroller.pseudo("::scroll-button( inline-start )").selectorText
                                                 // "::scroll-button(inline-start)"
html.pseudo("::view-transition-group(\\31 st-card)").selectorText
                                                 // "::view-transition-group(\\31 st-card)"  (escaped ident)

The “spec expects” column is copied from the explainer’s table and Chromium’s serializer (SerializeIdentifier for view-transition names, keywords verbatim for scroll buttons). It is a reference, never substituted for the browser’s answer: if selectorText is not exposed the selectorText column says so.

see also