Re: [whatwg/dom] A faster way to find open shadow roots (or shadow hosts) (#665)

For TreeWalker API, probably no one so far proposed anything concrete for Shadow DOM, as far as I know.  As TreeWalker is based on node iteration, it may not be as fast as we expect, although we may be able to optimize `nextNode()` specifically only for when the shadow host flag is specified.  To achieve the original motivation, a pseudo class is much simpler solution to implement.

The below is a dump of my thoughts, you can skip reading:

My first naive idea was to add a new flag (e.g. `SHOW_SHADOW_HOST`), in [NodeFilter](https://dom.spec.whatwg.org/#interface-nodefilter) to match a shadow host even though the flag becomes non mutually-exclusive against existing ones (`SHOW_ELEMENT`).
The next idea was to add `SHOW_SHADOW_ROOT` flag which is not mutually-exclusive against `SHOW_DOCUMENT_FRAGMENT` either, and [traversing algorithm](https://dom.spec.whatwg.org/#concept-nodeiterator-traverse) needs to be updated to visit shadow root.
Probably extending the node traversal algorithm to support shadow trees are too much for what we can get from there.

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

Received on Thursday, 12 July 2018 07:03:10 UTC