Created
September 1, 2024 01:13
-
-
Save henriquegogo/0fb36f804b57c029ba4a7b19280bc040 to your computer and use it in GitHub Desktop.
HTML createElement with arguments and nested children
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'a abbr address area article aside audio b base bdi bdo blockquote body br \ | |
button canvas caption cite code col colgroup data datalist dd del details dfn \ | |
dialog div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 \ | |
h5 h6 head header hgroup hr html i iframe img input ins kbd label legend li \ | |
link main map mark math menu meta meter nav noscript object ol optgroup option \ | |
output p param picture pre progress q rp rt ruby s samp script section select \ | |
slot small source span strong style sub summary sup svg table tbody td \ | |
template textarea tfoot th thead time title tr track u ul var video wbr \ | |
'.split(' ').forEach(tag => window[tag] = (...args) => { | |
const el = Object.assign(document.createElement(tag), ...args); | |
el.append(...args.filter(arg => arg.constructor !== Object)); | |
return el; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment