v160 · javascript · cssom · carousels
Scroll-button directions
The subtle edge case (CSSWG #14528). ::scroll-button() accepts physical directions (left right up down) and logical ones (inline-start inline-end block-start block-end). A CSSPseudoElement you create with pseudo() keeps the coordinate space you wrote; one the browser hands you through event.pseudoTarget always uses the logical name. Flip the carousel to right-to-left and the “left” button becomes inline-end.
Probing this browser…
Two flags gate this page.
selectorText needs CSSPseudoElementSelectorText, and returning ::scroll-button() as a CSSPseudoElement at all needs CSSPseudoElementScrollButton (both experimental in Chromium’s runtime_enabled_features.json5). Enable both at once with chrome://flags/#enable-experimental-web-platform-features and relaunch, or launch with --enable-blink-features=CSSPseudoElementSelectorText,CSSPseudoElementScrollButton. Without them, pseudo("::scroll-button(…)") returns null and the table says so.
1 · pseudo() keeps your coordinate space
| d | returned | selectorText | spec expects |
|---|---|---|---|
| pick a direction | |||
2 · pseudoTarget uses logical names
one
two
three
four
Click the black CSS arrow buttons under the track (the ::scroll-button() pseudo-elements). The HTML buttons are the keyboard path and the production-safe controls.
No scroll-button click yet.
migration note
// Pre-160 code often did this — it breaks on scroll buttons:
const key = pseudo.selectorText ?? pseudo.type; // "::scroll-button" → matches nothing
// Compare against the LOGICAL name for browser-created objects:
carousel.addEventListener("click", (e) => {
const p = e.pseudoTarget;
if (p?.selectorText === "::scroll-button(inline-end)") track("next");
});
// …but a user-created one keeps what you passed:
carousel.pseudo("::scroll-button(left)").selectorText; // "::scroll-button(left)"