Detalhes do pacote

load-mutation

dam3Apache-2.01.0.3

Tiny utility module that calss a registered element's onload/onunload method when added or removed from the DOM

readme (leia-me)

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