Last active
June 9, 2021 09:49
-
-
Save misebox/994cf6070bb6450d8e76ecb6839c5131 to your computer and use it in GitHub Desktop.
Shorthand function for document.createElement
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 default (function(doc) { | |
function element(elmName, attrs={}) { | |
const elm = doc.createElement(elmName); | |
Object.keys(attrs).map(k => elm.setAttribute(k,attrs[k])); | |
return elm; | |
} | |
function divAs(className, attrs={}) { | |
return element('div', {class: className, ...attrs}); | |
} | |
return { | |
element, | |
divAs, | |
}; | |
})(document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment