[whatwg/dom] Scope-match a selectors string including a pseudo-element selector (Issue #1497)

cdoublev created an issue (whatwg/dom#1497)

### What is the issue with the DOM Standard?

Quoting @tabatkins in #185:

  > `querySelector()` does need to pass an empty list of allowed pseudo-elements, tho, since otherwise you get nonsensical results (there's no way to reflect a pseudo-element as a JS object right now).

Indeed, [`querySelector()`](https://dom.spec.whatwg.org/#dom-parentnode-queryselector) and [`querySelectorAll()`](https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall) invoke [scope-match a selectors string](https://dom.spec.whatwg.org/#scope-match-a-selectors-string) with a selector and the element, but without an empty list of allowed pseudo-elements. Then scope-match a selectors string invokes [match a selector against a tree](https://drafts.csswg.org/selectors-4/#match-a-selector-against-a-tree) without this empty list, which is defaulted to a list of all pseudo-elements in match a selector against a tree:

  > [APIs using this algorithm] may optionally provide:
  >
  > - A list of pseudo-elements that are allowed to show up in the match list. **If not specified, this defaults to allowing all pseudo-elements.**

So I wonder if:

  1. the procedures for `querySelector()` and `querySelectorAll()` should invoke scope-match a selectors string with an empty list of allowed pseudo-elements
  2. scope-match a selectors string should always invoke match a tree against selector with an empty list of allowed pseudo-elements
  3. match a selector against a tree should default to an empty list of allowed pseudo-elements
  4. the WHATWG and CSSWG do not want to make a change because there is a plan to return pseudo-elements from `querySelector()` and `querySelectorAll()` in the future

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

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

Received on Tuesday, 21 July 2026 06:04:25 UTC