[whatwg/dom] Proposal: querySelector() take many selectors (#817)

Hi,

I have a proposal for the `querySelector` method: it could take a list of selectors and return the element from the first matching selectors.

Here is a polyfill of this new implementation ([JS Bin](https://jsbin.com/yobularahi/edit?html,js,console)):

```javascript
const querySelector = (that, ...selectors) => {
    return selectors.map((s) => that.querySelector(s))
                    .find((e) => undefined !== e) ?? null;
};
```

The point is to be able to prioritize the selectors. For example to return the secure URL of the video or by default the standard version (in Open Graph metadata):

```javascript
document.querySelector(`meta[property="og:video:secure_url"]`,
                       `meta[property="og:video:url"]`);
```

-- 
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/817

Received on Thursday, 9 January 2020 11:12:56 UTC