upfront-editable
Version:
Friendly contenteditable API
36 lines (28 loc) • 951 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.domSelector = exports.domArray = void 0;
/**
* @param {HTMLElement | Array | String} target
* @param {Document} document
*/
var domArray = function domArray(target, document) {
if (typeof target === 'string') return Array.from(document.querySelectorAll(target));
if (target.tagName) return [target];
if (Array.isArray(target)) return target; // Support NodeList and jQuery arrays
return Array.from(target);
};
/**
* @param { HTMLElement | String } target
* @param { Document } document
* @returns { HTMLElement }
*/
exports.domArray = domArray;
var domSelector = function domSelector(target, document) {
if (typeof target === 'string') return document.querySelector(target);
if (target.tagName) return target; // Support NodeList and jQuery arrays
if (target[0]) return target[0];
return target;
};
exports.domSelector = domSelector;