xxxxxxxxxx
const isSelectorValid = ((dummyElement) =>
(selector) => {
try { dummyElement.querySelector(selector) } catch { return false }
return true
})(document.createDocumentFragment())
console.assert(isSelectorValid('p > > > a') === false)
console.assert(isSelectorValid('p > a') === true)
console.log('Test passed')