Last active
February 19, 2023 02:58
-
-
Save MarekZeman91/b74d31eda1001f8380109ab5c1606108 to your computer and use it in GitHub Desktop.
One of the laziest EL implementations, but with cache
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
export const el = (nodeName, props = {}, children = []) => { | |
const $el = (el.cache[nodeName] || ( | |
el.cache[nodeName] = document.createElement(nodeName) | |
)).cloneNode(true); | |
Object.assign($el, props).append(...children); | |
return $el; | |
}; | |
el.cache = {}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment