load-mutation

1.0.3 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i load-mutation

Weekly Downloads

2

Version

1.0.3

License

Apache-2.0

Last publish

Collaborators

  • dam