Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/allouis/copy-event-attributes
🔥 copies event attributes between DOM elements 🔥 🔥 designed for use with morphdom 🔥
https://github.com/allouis/copy-event-attributes
Last synced: 24 days ago
JSON representation
🔥 copies event attributes between DOM elements 🔥 🔥 designed for use with morphdom 🔥
- Host: GitHub
- URL: https://github.com/allouis/copy-event-attributes
- Owner: allouis
- Created: 2016-04-23T12:49:53.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-13T11:21:33.000Z (almost 8 years ago)
- Last Synced: 2024-08-09T10:02:38.068Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# copy-event-attributes
This was pulled out of [yo-yo](https://github.com/maxogden/yo-yo) because I wanted the nicer [morphdom](https://github.com/patrick-steele-idem/morphdom) it provides, but without the dependency on [bel](https://github.com/shama/bel)
### install
###### yarn
```shell
yarn add copy-event-attributes
```###### npm
```shell
npm install --save copy-event-attributes
```### usage
```javascript
var copyEvents = require('copy-event-attributes')copyEvents(fromEl, toEl)
```### usage with morphdom
```javascript
var copyEvents = require('copy-event-attributes')
var morphdom = require('morphdom')morphdom(fromEl, toEl, {
onBeforeElUpdated: copyEvents
})
```### usage with custom events
```javascript
var copyEvents = require('copy-event-attributes')
var morphdom = require('morphdom')function copyCustomEvents (fromEl, toEl) {
return copyEvents(fromEl, toEl, ['onmyevent'])
}morphdom(fromEl, toEl, {
onBeforeElUpdated: copyCustomEvents
})
```