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

18 lines (17 loc) 697 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var insertAfter_1 = __importDefault(require("./insertAfter")); function findEmptyElm(elm) { var child = elm === null || elm === void 0 ? void 0 : elm.firstElementChild; return child ? findEmptyElm(child) : elm; } exports.default = (function (elm, html) { if (html) { var wrapElm = findEmptyElm((0, insertAfter_1.default)(elm, html)); wrapElm === null || wrapElm === void 0 ? void 0 : wrapElm.appendChild(elm); } return elm; });