This adds a new API to document, but given the sequence<ShadowRoot> shadowRoots = []; it seems as though it would be possible to include shadowdom children by passing references to their roots; however if I just wanted to get elements intersecting a Rect inside my shadowroot, I'd have to do something like:
for(const node of document.nodesFromRect(rect, { shadowRoots: [myshadow] })) {
if (node.getRootNode() != myShadow) continue;
// logic
}
Of course this code looks easy but it's giving the user more data than they needed, which they are then discarding. Simple would be if it was on DocumentOrShadowRoot, then one could do:
for(const node of myshadow.nodesFromRect(rect)) {
// logic
}
Of course this may beg the question: why DocumentOrShadowRoot? Why not simply add it to Node? I think that's something also worth exploring!
This adds a new API to
document, but given thesequence<ShadowRoot> shadowRoots = [];it seems as though it would be possible to include shadowdom children by passing references to their roots; however if I just wanted to get elements intersecting a Rect inside my shadowroot, I'd have to do something like:Of course this code looks easy but it's giving the user more data than they needed, which they are then discarding. Simple would be if it was on
DocumentOrShadowRoot, then one could do:Of course this may beg the question: why
DocumentOrShadowRoot? Why not simply add it toNode? I think that's something also worth exploring!