UNPKG

@medyll/idae-be

Version:

A modern, lightweight, and extensible DOM manipulation library built with TypeScript. Designed for precise element targeting and manipulation using a callback-based approach. Features include advanced DOM traversal, event handling, style management, attri

19 lines (18 loc) 557 B
const nodesList = {}; export class Fragments { static fragments = {}; create(tag, attributes) { if (!nodesList[tag]) { nodesList[tag] = document.createElement(tag); } const fragment = document.createDocumentFragment(); const cloned = nodesList[tag].cloneNode(true); if (attributes) { Object.entries(attributes).forEach(([key, value]) => { cloned.setAttribute(key, value); }); } fragment.appendChild(cloned); return fragment; } }