fix scoped js util initialization
This commit is contained in:
parent
5f6ab41ad8
commit
fc8f37882e
@ -62,7 +62,7 @@
|
|||||||
console.log('setting up util', { util });
|
console.log('setting up util', { util });
|
||||||
}
|
}
|
||||||
|
|
||||||
scope = scope || document;
|
scope = scope || document.body;
|
||||||
|
|
||||||
if (util && typeof util.setup === 'function') {
|
if (util && typeof util.setup === 'function') {
|
||||||
const elements = _findUtilElements(util, scope);
|
const elements = _findUtilElements(util, scope);
|
||||||
@ -96,6 +96,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _findUtilElements(util, scope) {
|
function _findUtilElements(util, scope) {
|
||||||
|
if (scope && scope.matches(util.selector)) {
|
||||||
|
return [scope];
|
||||||
|
}
|
||||||
return Array.from(scope.querySelectorAll(util.selector));
|
return Array.from(scope.querySelectorAll(util.selector));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user