UNPKG

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) 720 B
"use strict"; 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 ((0, isString_1.default)(elm) || Array.isArray(elm)) { [elm, tagNames] = [document, elm]; } return (0, findUniqueNodeCollection_1.default)(tagNames, byTag(elm)); } exports.default = findByTagName;