Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Oct 26, 2020
1 parent 340a921 commit 1648731
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions js/src/dom/polyfill.js
Expand Up @@ -13,7 +13,7 @@ let find = Element.prototype.querySelectorAll
let findOne = Element.prototype.querySelector

const scopeSelectorRegex = /:scope\b/
const supportScopeQuery = (() => {
const supportsScopeQuery = (() => {
const element = document.createElement('div')

try {
Expand All @@ -25,7 +25,7 @@ const supportScopeQuery = (() => {
return true
})()

if (!supportScopeQuery) {
if (!supportsScopeQuery) {
find = function (selector) {
if (!scopeSelectorRegex.test(selector)) {
return this.querySelectorAll(selector)
Expand Down Expand Up @@ -57,11 +57,7 @@ if (!supportScopeQuery) {

const matches = find.call(this, selector)

if (typeof matches[0] !== 'undefined') {
return matches[0]
}

return null
return matches[0] ? matches[0] : null
}
}

Expand Down

0 comments on commit 1648731

Please sign in to comment.