SimeonTs

l

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