Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function l (type, content, ...attr) {
- // 'Type', 'content' / ['content', l(another)], - [{className: 'className', {id: 'idName'}]
- const r = document.createElement(type);
- attr !== undefined ? attr.forEach(x => {r.setAttribute(Object.keys(x)[0], Object.values(x)[0]);}) : 'pass';
- Array.isArray(content) ? content.forEach(append) : append(content);
- function append(node) {
- typeof node === 'string' ? node = document.createTextNode(node) : 'do nothing';
- r.appendChild(node);
- }
- return r
- }
Add Comment
Please, Sign In to add comment