Skip to content

Instantly share code, notes, and snippets.

@KOBA789
Created November 3, 2024 01:53
Show Gist options
  • Save KOBA789/5283f3161938f2e82f4b753dba4e1544 to your computer and use it in GitHub Desktop.
Save KOBA789/5283f3161938f2e82f4b753dba4e1544 to your computer and use it in GitHub Desktop.
e.js
function E (tagName, attrs, children) {
const el = document.createElement(tagName);
attrs = attrs || {};
Object.keys(attrs).forEach(function (key) {
el.setAttribute(key, attrs[key]);
});
for (let child of children) {
if (child instanceof Node) {
el.appendChild(child);
} else {
el.appendChild(child.$elem);
}
}
return el;
}
function T (text) {
return document.createTextNode(text);
}
@1inguini
Copy link

1inguini commented Nov 3, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment