Skip to content

[nodesFromRect] why only on document? #53

Description

@keithamus

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions