load-mutation
v1.0.3
Published
Tiny utility module that calss a registered element's onload/onunload method when added or removed from the DOM
Downloads
3
Readme
load-mutation
Tiny utility that calls an element's onload / onunload method when added or removed from an observed root element.
install
npm i load-mutation --save
usage
var LoadMutation = require('load-mutation')
var bel = require('bel')
var root = bel`<div><div>`
var subscribe = LoadMutation(root)
var element = bel`<div onload=${load} onunload=${unload}></div>`
element = subscribe(element)
window.appendChild(root)
root.appendChild(element)
root.removeChild(element)
function load (el) {
console.log('LOADED!')
}
function unload (el) {
console.log('UNLOADED!')
}
test
npm it