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