npm.io
1.0.1 • Published 10 years ago

copy-event-attributes

Licence
MIT
Version
1.0.1
Deps
0
Vulns
0
Weekly
0
Stars
1

copy-event-attributes

This was pulled out of yo-yo because I wanted the nicer morphdom it provides, but without the dependency on bel

usage

var copyEvents = require('copy-event-attributes')

copyEvents(fromEl, toEl)

usage with morphdom

var copyEvents = require('copy-event-attributes')
var morphdom = require('morphdom')

morphdom(fromEl, toEl, {
  onBeforeMorphEl: copyEvents
})
usage with custom events
var copyEvents = require('copy-event-attributes')
var morphdom = require('morphdom')

function copyCustomEvents (fromEl, toEl) {
  return copyEvents(fromEl, toEl, ['onmyevent'])
}

morphdom(fromEl, toEl, {
  onBeforeMorphEl: copyCustomEvents
})

Keywords