onmount
Version:
Run something when a DOM element appears and when it exits
13 lines (11 loc) • 375 B
JavaScript
exports.el = function el (name, options) {
if (!options) options = {}
var div = document.createElement(name)
if (options['class']) div.className = options['class']
if (options.role) div.setAttribute('role', options.role)
document.body.appendChild(div)
return div
}
exports.remove = function remove (el) {
el && el.parentNode && el.parentNode.removeChild(el)
}