(selector, ...args)
| 575 | // } |
| 576 | |
| 577 | const el = (selector, ...args) => { |
| 578 | var attrs = (args[0] && typeof args[0] === 'object' && !Array.isArray(args[0]) && !(args[0] instanceof HTMLElement)) ? args.shift() : {}; |
| 579 | |
| 580 | let classes = selector.split("."); |
| 581 | if (classes.length > 0) selector = classes.shift(); |
| 582 | if (classes.length) attrs.className = classes.join(" ") |
| 583 | |
| 584 | let id = selector.split("#"); |
| 585 | if (id.length > 0) selector = id.shift(); |
| 586 | if (id.length) attrs.id = id[0]; |
| 587 | |
| 588 | var node = document.createElement(selector.length > 0 ? selector : "div"); |
| 589 | for (let prop in attrs) { |
| 590 | if (attrs.hasOwnProperty(prop) && attrs[prop] != undefined) { |
| 591 | if (prop.indexOf("data-") == 0) { |
| 592 | let dataProp = prop.substring(5).replace(/-([a-z])/g, function(g) { return g[1].toUpperCase(); }); |
| 593 | node.dataset[dataProp] = attrs[prop]; |
| 594 | } else { |
| 595 | node[prop] = attrs[prop]; |
| 596 | } |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | const append = (child) => { |
| 601 | if (Array.isArray(child)) return child.forEach(append); |
| 602 | if (typeof child == "string") child = document.createTextNode(child); |
| 603 | if (child) node.appendChild(child); |
| 604 | }; |
| 605 | args.forEach(append); |
| 606 | |
| 607 | return node; |
| 608 | }; |
| 609 | |
| 610 | export { |
| 611 | DataURL, |
no outgoing calls
no test coverage detected