UNPKG

orvex

Version:

A lightweight TypeScript library to create and manipulate HTML elements with ease.

28 lines (27 loc) 686 B
export function apply(obj, options) { let target = document.body; if (!options.id) { target.appendChild(obj); return; } if (options.id) { for (const name of options.id) { const next = target.querySelector(`#${name}`); if (!next) return; target = next; } target.appendChild(obj); return; } if (options.className) { for (const name of options.className) { const next = target.querySelector(`.${name}`); if (!next) return; target = next; } target.appendChild(obj); return; } }