NEW332060
Transition of an anchor-positioned ::after does not start when a :has() rule matches its originating element
https://bugs.webkit.org/show_bug.cgi?id=332060
Summary Transition of an anchor-positioned ::after does not start when a :has() rule ...
Takahiro Arai
Reported 2026-11-17 17:25:03 PST

STEPS TO REPRODUCE

  1. Open the attached testcase (also available at https://tak-dcxi.github.io/css-browser-bugs/bugs/anchor-pseudo-transition-has-originating/repro.html).
  2. Look at groups 1 to 5 and the result lines at the top of the page. After the page loads, the script moves anchor-name from the link "One" to the link "Three". The left of the highlight is anchor(left) and has a transition with a very long duration and a negative delay of half the duration, so a running transition stays at its midpoint (over "Two").
  3. For a manual check, move the pointer from "One" to "Three" in lists H1 to H5.

The relevant part of group 2:

ul { position: relative; }
ul .current { anchor-name: --a2; }
ul::after {
content: "";
position: absolute;
position-anchor: --a2;
left: anchor(left);
transition: left 10000s linear -5000s;
}
ul:has(a.current) { --flag: on; } /* any rule; the value is never used */

ACTUAL RESULTS

In group 2 the highlight jumps to "Three", and no transition is created:

Group 2: left 0px -> 192px, running transitions of left: 0

The only difference from group 1 (control, passes) is the :has() rule that matches the ul, the originating element of the ::after. The declarations in the rule do not matter: a declaration of an unused custom property is enough. In my own page, a rule that changes color had the same effect (not included in the testcase).

The transition does start in these cases:

  • Group 3 / H4: the same :has() rule on the parent of the ul.
  • Group 4 / H5: a real child element positioned with anchor() instead of ::after, with the :has() rule on the ul.
  • H3: ul:hover instead of ul:has(a:hover).
  • Group 5: an ::after whose left changes through a class, without anchor positioning, with the :has() rule on the ul.

With :hover (H2, ul:has(a:hover)), the highlight also jumps from link to link instead of sliding, while it slides in H1, H3, H4 and H5.

EXPECTED RESULTS

In groups 1 to 5 the highlight should be over "Two", the same as in the Reference, with one running transition of left in each group:

Expected: left 0px -> 96px, running transitions of left: 1

In H1 to H5 the highlight should slide over 1 second.

SPECIFICATION

CSS Anchor Positioning Module Level 1, 3.2 Anchor-relative Insets: the anchor() function
https://drafts.csswg.org/css-anchor-position-1/#anchor-pos

A resolvable anchor() function "resolves at computed value time (using style & layout interleaving)" to a <length>. The note in the same section says that transitions of a property using an anchor function work for changes such as "the anchor-name property being changed on anchors". So moving anchor-name changes the computed value of left on the ::after, and a transition starts (CSS Transitions Level 1, 3 Starting of transitions: https://drafts.csswg.org/css-transitions-1/#starting). Whether a :has() rule matches the originating element does not change the before-change or after-change value of left.

ENVIRONMENT

  • Safari 26.5 (21624.2.5.11.4), macOS 26.5.1: fails (group 2 and H2).
  • Safari Technology Preview 27.0 (21627.1.6.3), macOS 26.5.1: fails (group 2 and H2).
  • No settings changed.

OTHER BROWSERS

  • Chrome 157.0.8103.80 and Chrome Canary 160.0.8168.0: pass (a transition starts in all groups).
  • Firefox 160.0.1 and Firefox Nightly 162.0a1: transitions of anchor() values are not supported yet, with or without :has() (https://bugzilla.mozilla.org/show_bug.cgi?id=1924226). Group 5, without anchor positioning, passes.

Possibly related WebKit bugs:

  • https://bugs.webkit.org/show_bug.cgi?id=314641 (Transition does not work properly for anchor positioning): an anchor-positioned fieldset::before whose anchor is set by label:has(:checked) transitions only some of the time. The :has() there matches the anchor, not the originating element, so I am filing this separately.
  • https://bugs.webkit.org/show_bug.cgi?id=300845: while a display transition runs, left: anchor(...) fails to resolve; its description points at the code in StyleTreeResolver.cpp that skips applying animations while the anchor position is unresolved.
  • https://bugs.webkit.org/show_bug.cgi?id=328203: the anchor-positioned element's resolution is restarted on each style update, and anchor() first computes to auto before the interleaved layout resolves it. I have not checked whether this is the cause here.

WEB PLATFORM TESTS

No test covers a transition of an anchor-positioned pseudo-element, or a :has() rule on the originating element. The closest tests in css/css-anchor-position/ pass in Safari Technology Preview 256 on wpt.fyi (2026-11-16):

The testcase is released under CC0 and can be turned into a WPT test.

Attachments
Takahiro Arai
Comment 1 2026-11-17 19:13:16 PST

Additional findings on macOS 27.2.1 with Safari 27.2 (22625.2.8.11.9). Group 2 and H2 still fail in the same way. Safari Technology Preview 27.0 (22627.1.6.3) gives the same result for group 2 and H2.

The condition is broader than a :has() rule on the originating element. Lists H3 (ul:hover { --flag: on; }) and H4 (:has(a:hover) { --flag: on; } on the parent of the ul) also skip the transition, but only when the pointer enters or leaves the list:

  • Pointer moves between links inside the list (One -> Two -> Three -> Two -> One): H1, H3, H4 and H5 transition; H2 jumps.
  • Pointer enters the list directly onto a link (outside -> Two, outside -> Three): H1 and H5 transition; H3 and H4 jump.
  • Pointer leaves the list from a link: H1 and H5 transition; H3 and H4 jump.

When the pointer enters or leaves the list, the anchor changes in the same update in which ul:hover (H3) or the parent's :has(a:hover) (H4) starts or stops matching. While the pointer moves inside the list, those rules keep matching and the transition starts. In H2, ul:has(a:hover) keeps matching too, but the transition is skipped on every move.

So it looks like the transition of the anchor-positioned ::after is skipped when, in the same update as the anchor change, a selector on the originating element or its parent changes its match result, or a :has() rule on the originating element is re-evaluated. I have not confirmed this in the engine. H5, which positions a real child element instead of ::after, transitions in every case.

How this was measured: I drove Safari with the Safari MCP server (safaridriver --mcp), moved the pointer by viewport coordinates, and logged transitionrun events and the computed left of the highlight two frames after each mouseenter. In the "jumps" cases no transitionrun event fired and left was already at the end value (96px or 192px) two frames later. In the "transitions" cases transitionrun fired and left was between the start and end values.

Testcase: https://tak-dcxi.github.io/css-browser-bugs/bugs/anchor-pseudo-transition-has-originating/repro.html

Note You need to log in before you can comment on or make changes to this bug.