v160 · css · view transitions
::part() workaround & edge cases
Migrating from the old workaround and the ways the option can fail. Every button below makes a real startViewTransition() call scoped to its own lane and prints what the browser did — captured names, a rejected ready promise, or a TypeError thrown while converting the options dictionary.
shadowRoots dictionary member…1 · Workaround vs. option
Before this feature the only way to animate a shadow-tree element was to export it with part="label" and name it from the page: edge-chip::part(label) { view-transition-name: … }. That works in every browser with view transitions, but the name now lives in the consumer’s stylesheet and the component has to publish its internals.
2 · Duplicate names across trees
Tree scoping used to keep a component’s dup-hero separate from the page’s dup-hero. Once the root is listed, both names share the transition’s single namespace — and a duplicate view-transition-name skips the whole transition with an InvalidStateError.
3 · Invalid entries and closed roots
The member is typed sequence<ShadowRoot>: anything else — an element, null — is a TypeError before the transition is created. For a closed root, outside code only ever sees host.shadowRoot === null, so it cannot opt someone else’s component in; only the component, holding the reference from attachShadow(), can.
migrating
/* Before: leak the name through an exported part (page stylesheet) */
my-chip::part(label) { view-transition-name: chip-label; }
/* After: keep it inside the component's shadow stylesheet */
.label { view-transition-name: chip-label; }
// …and opt the root in where the transition starts
document.startViewTransition({ update, shadowRoots: [chip.shadowRoot] });
// Browsers without the member ignore it, so the label simply stops
// morphing there. If you still need it to morph in those browsers, keep
// the ::part() rule as well: it is ordinary cascade, so the outer-tree
// declaration wins over the shadow one and the label keeps a single name.