Re: [csswg-drafts] [css-anchor-position-1] Better reusability of anchor names (#9045)

Defining `closest` as either ancestor or preceding sibling sounds a bit arbitrary to me.
We could define `closest` as the last element before this one in the document order. This would include any elements for which the opening tag appears before this element, including ancestors previous siblings and their decedents. I don't think this would be an ideal solution tough. It can produce some unexpected results, such as having the anchor somewhere deep inside the preceding sibling.
Instead of joining the ancestor and preceding sibling selection in one keyword, why not split:
- `closest` - for ancestor
- `preceding` or `previous` - for any preceding sibling
- `following` or `next` - for any following sibling
- maybe even `sibling` - for any sibling.
To insure familiarity and predictability `closest` will act in accordance with `Element.closest()` method. The above is also similar to [how tree traversing works in jQuery](https://api.jquery.com/category/traversing/tree-traversal/).

P. S. All the containing block stuff was pretty confusing to me. Sorry 😅

-- 
GitHub Notification of comment by tigrr
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9045#issuecomment-1645206072 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 21 July 2023 08:26:11 UTC