Sean Hogan wrote:
Hi Lachy,

Here's a proposal.

querySelector*(selector, context) // allows selectors with :scope pseudo-class queryScopedSelector*(selector, context) // allows selectors with implied :scope matchesSelector(selector, context) // allows selectors with :scope pseudo-class

To check if the :scope pseudo-class is available, use:

try { document.body.matchesSelector(":scope", document.body); }
catch (error) { /* not supported */ }

 OR

try { document.querySelector(":scope", document.body); }
catch (error) { /* not supported */ }

Sorry. Replace document.body with document.documentElement. That should be more efficient for the querySelector test.

Reply via email to