vanillajs-browser-helpers
Version:
Collection of convenience code snippets (helpers) that aims to make it a little easier to work with vanilla JS in the browser
16 lines (15 loc) • 695 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const isString_1 = __importDefault(require("vanillajs-helpers/isString"));
const findUniqueNodeCollection_1 = __importDefault(require("./findUniqueNodeCollection"));
const byTag = (elm) => (tag) => elm.getElementsByTagName(tag);
function findByTagName(elm, tagNames) {
if (isString_1.default(elm) || Array.isArray(elm)) {
[elm, tagNames] = [document, elm];
}
return findUniqueNodeCollection_1.default(tagNames, byTag(elm));
}
exports.default = findByTagName;