dom-delegation-stream
streaming DOM event delegation
Last updated 5 years ago by jarofghosts .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install dom-delegation-stream 
SYNC missed versions from official npm registry.

dom-delegation-stream

Build Status npm install npm version License

simple streaming DOM event delegation

example

var events = require('dom-delegation-stream')
var values = require('dom-value-stream')

events(document.body, 'input', 'input[type=text]')
  .pipe(values())
  .pipe(wherever())

API

events(element, eventName[, selector, options]) -> ReadableStream

  • if selector is provided, delegation will be used, otherwise it will not.
  • valid options are:
    • preventDefault <boolean>: will call preventDefault() on all matched events. Defaults to false.
    • stopPropagation <boolean>: will call stopPropagation() on all matched events. Defaults to false.
    • useCapture <boolean>: will initiate capture for matched events. Defaults to false.

notes

  • when using delegation, the element that matches your selector will be available as event.delegationTarget.
  • calling .end() or otherwise ending the stream returned by dom-delegation-stream will remove the listeners added for event handling.
  • there are some alternative options for event handling on npm, a couple that even support delegation, and even some that are streaming. this module was created as an effort to provide a better balance of simplicity and flexibility.

license

MIT

Current Tags

  • 1.0.1                                ...           latest (5 years ago)

4 Versions

  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
  • 0.1.0                                ...           6 years ago
  • 0.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (2)
Dev Dependencies (10)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |