Re: [whatwg/dom] Element.matches and :scope (Issue #1081)

lifaon74 left a comment (whatwg/dom#1081)

> Write down a description of the underlying problem you’re trying to solve. What are the use cases? A use case is an actual user wanting to do something. Then list requirements for each use case.

Perform a css selector match from a child to a parent instead of the opposite. Example:

```ts
// assume `child` is a variable on an HTMLElement, and `this` a variable on a CustomElement.
if (child.matches(':scope > ul > li:nth-child(even)', { scope: this.shadowRoot })) {
  // is `child` an even element into a list present in this custom-element ?
  child.dataset['even'] = '';
}
```

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

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

Received on Tuesday, 23 June 2026 07:00:09 UTC