- Refactoring: Add utilities $q and $qq for querySelector/querySelectorAll
This commit is contained in:
@@ -137,6 +137,7 @@ module.exports = {
|
||||
'document.evaluate',
|
||||
'document.head',
|
||||
'document.importNode',
|
||||
'document.querySelector',
|
||||
'document.querySelectorAll',
|
||||
'DOMParser',
|
||||
'Error',
|
||||
|
||||
@@ -45,6 +45,8 @@ import {
|
||||
} from './locale/locale.js';
|
||||
import loadStylesheets from './external/load-stylesheets/index-es.js';
|
||||
|
||||
const {$q} = Utils;
|
||||
|
||||
const editor = {};
|
||||
|
||||
const $ = [
|
||||
@@ -5765,7 +5767,7 @@ editor.init = function () {
|
||||
// Bind function to button
|
||||
let btn;
|
||||
if (opts.sel) {
|
||||
btn = document.querySelector(opts.sel);
|
||||
btn = $q(opts.sel);
|
||||
if (btn === null) { return true; } // Skip if markup does not exist
|
||||
if (opts.evt) {
|
||||
// `touch.js` changes `touchstart` to `mousedown`,
|
||||
|
||||
@@ -1408,3 +1408,6 @@ export const mock = ({
|
||||
setHref = setHrefUser;
|
||||
getRotationAngle = getRotationAngleUser;
|
||||
};
|
||||
|
||||
export const $q = (sel) => document.querySelector(sel);
|
||||
export const $qq = (sel) => [...document.querySelectorAll(sel)];
|
||||
|
||||
Reference in New Issue
Block a user