From e6f8428b2850418474649006641c7fc4c0326eff Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sun, 1 Nov 2020 07:38:55 +0200 Subject: polyfill.js minor tweaks (#32011) * rename function to `supportsScopeQuery` * use a ternary in `findOne` function return value --- js/src/dom/polyfill.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'js') diff --git a/js/src/dom/polyfill.js b/js/src/dom/polyfill.js index 55bc5d694e..61e75eccd0 100644 --- a/js/src/dom/polyfill.js +++ b/js/src/dom/polyfill.js @@ -27,7 +27,7 @@ const defaultPreventedPreservedOnDispatch = (() => { })() const scopeSelectorRegex = /:scope\b/ -const supportScopeQuery = (() => { +const supportsScopeQuery = (() => { const element = document.createElement('div') try { @@ -39,7 +39,7 @@ const supportScopeQuery = (() => { return true })() -if (!supportScopeQuery) { +if (!supportsScopeQuery) { find = function (selector) { if (!scopeSelectorRegex.test(selector)) { return this.querySelectorAll(selector) @@ -71,11 +71,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 } } -- cgit v1.2.3