dom icon indicating copy to clipboard operation
dom copied to clipboard

Allow 'lower-boundary' scoping argument in querySelector()

Open mirisuzanne opened this issue 2 years ago • 2 comments
trafficstars

The CSSWG is working on new 'scoping' functionality, that allows authors to establish both upper (root) and lower boundaries on a 'scoped' selector. The result is that selectors match within a tree fragment starting at the root, and containing all descendants up until a lower boundary selector is matched.

It would be great to have this option available for authors in querySelector() as well. In our discussions, @tabatkins suggested the following:

In particular, the current second argument to qS() is, effectively, the upper bound of scoping; we could expand the argument to be an options bag with {upper: [nodes], lower: [nodes]} to accommodate both directions.

mirisuzanne avatar Mar 20 '23 17:03 mirisuzanne

It currently doesn't have a second argument?

Also, https://whatwg.org/faq#adding-new-features applies here. In addition to what is stated there it would be good to know if this is a frequent issue developers face (e.g., questions on Stack Overflow) and whether libraries are addressing this problem.

annevk avatar Mar 22 '23 11:03 annevk

It currently doesn't have a second argument?

Oh lol, I'm still remembering the original form of querySelector from a decade ago. Well, what I mean is really the context argument is the upper boundary.

tabatkins avatar Mar 23 '23 20:03 tabatkins