<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>310398</bug_id>
          
          <creation_ts>2026-03-20 15:18:55 -0700</creation_ts>
          <short_desc>[css-anchor-position-1] Accommodate pseudo-elements when sorting anchor elements by tree order</short_desc>
          <delta_ts>2026-04-01 19:51:52 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Layout and Rendering</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://github.com/web-platform-tests/wpt/pull/58900</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Kiet Ho">kiet.ho</reporter>
          <assigned_to name="Kiet Ho">kiet.ho</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>kiet.ho</cc>
    
    <cc>maikelkrause</cc>
    
    <cc>santoshpavan.666</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2192195</commentid>
    <comment_count>0</comment_count>
    <who name="Kiet Ho">kiet.ho</who>
    <bug_when>2026-03-20 15:18:55 -0700</bug_when>
    <thetext>[css-anchor-position-1] Accommodate pseudo-elements when sorting anchor elements by tree order</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2192196</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2026-03-20 15:19:05 -0700</bug_when>
    <thetext>&lt;rdar://problem/173032203&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2192203</commentid>
    <comment_count>2</comment_count>
    <who name="">maikelkrause</who>
    <bug_when>2026-03-20 15:46:06 -0700</bug_when>
    <thetext>Relevant test: https://codepen.io/maikelkrause/pen/raMOVNN?editors=1100

The second (purple) chain uses `::after` pseudo-elements anchored to one another.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2192310</commentid>
    <comment_count>3</comment_count>
    <who name="Kiet Ho">kiet.ho</who>
    <bug_when>2026-03-20 23:16:39 -0700</bug_when>
    <thetext>If there are multiple matching anchors with the same, the spec says we should sort them by tree order and take the last one.
The bug is that the current sorting code can&apos;t figure out which pseudo-element is before another pseudo element. So if you have a chain like 1 &lt;- 2 &lt;- 3, and they both have the same anchor name, it&apos;s possible for 3 to chain to 1 or 2.
The behavior is sorta non-deterministic, so it&apos;s possible for 3 to chain to 2 sometimes and to 1 some other times.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2193404</commentid>
    <comment_count>4</comment_count>
    <who name="Kiet Ho">kiet.ho</who>
    <bug_when>2026-03-24 22:12:42 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/61306</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2195800</commentid>
    <comment_count>5</comment_count>
    <who name="Kiet Ho">kiet.ho</who>
    <bug_when>2026-03-31 23:37:08 -0700</bug_when>
    <thetext>Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/58900</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2196088</commentid>
    <comment_count>6</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2026-04-01 17:38:10 -0700</bug_when>
    <thetext>Committed 310407@main (8c2cc6504c16): &lt;https://commits.webkit.org/310407@main&gt;

Reviewed commits have been landed. Closing PR #61306 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2196122</commentid>
    <comment_count>7</comment_count>
    <who name="">santoshpavan.666</who>
    <bug_when>2026-04-01 19:51:52 -0700</bug_when>
    <thetext>(In reply to Kiet Ho from comment #0)
&gt; [css-anchor-position-1] Accommodate pseudo-elements when sorting anchor
&gt; elements by tree order
&gt;CSS Anchor Positioning (from the css-anchor-position-1 spec) handles pseudo-elements like ::before and ::after during anchor retrieval by treating them as implicitly anchored to their originating element, unless explicitly overridden. When sorting potential anchors (via steps like checking layout order, top layers, and containing blocks), pseudo-elements qualify only if they&apos;re &quot;fully styleable tree-abiding&quot; (e.g., ::before, ::after), and the originating element often serves as the fallback in auto mode.
&gt;Anchor Retrieval Basics
The spec sorts candidate anchors by criteria like flat tree order and containing block ancestry, laid out before the positioned element. Pseudo-elements don&apos;t disrupt this; their originating element steps in for implicit positioning (e.g., position-anchor: auto). This ensures stable retrieval even if pseudos are named anchors.
&gt;Pseudo-Element Handling
Valid pseudos (e.g., ::before) use the parent as default anchor, avoiding retrieval conflicts. For multiples with shared anchor-name, DOM order picks the last (or nearest ancestor), but anchor-scope limits visibility per subtree. No special &quot;accommodation&quot; step exists—pseudos integrate via originating element fallback.

Practical Tips
Set position-anchor: none on unwanted pseudos (e.g., ::picker) to exclude them. Test in Chrome (full support); pseudos like ::marker may fail as non-styleable. Use unique names or scopes for complex sorting</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>