Re: [whatwg/dom] Add an optional options dictionary to `closest` to allow jumping across shadow boundaries (Issue #1265)

gijsk left a comment (whatwg/dom#1265)

> So you want to stop traversing at a certain point

I don't, actually. `closest` returning null if it can't find anything between the node on which it's invoked and the document root is fine for my usecases (and existing behaviour). Adding a boundary condition to `closest` seems like it has some overlap with this request but either that or this issue could be fixed without fixing the other, so I'd suggest filing a separate issue.

There is also an existing practical workaround for adding a boundary condition, which is to add whatever boundary condition you want into the selector (assuming it can be expressed in CSS), and then checking whether the element you got was the boundary or the thing you wanted to find. That doesn't help for _extending_ the set of elements it iterates to cross the shadow DOM boundary, which is what this issue is about.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/1265#issuecomment-4648100455
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/1265/4648100455@github.com>

Received on Monday, 8 June 2026 10:50:51 UTC