dom-event-helpers
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -0,1 +1,3 @@ | ||
import delegate from './src/delegate'; | ||
import dispatch from './src/dispatch'; | ||
import off from './src/off'; | ||
@@ -5,2 +7,2 @@ import on from './src/on'; | ||
export {off, on, ready}; | ||
export {delegate, dispatch, off, on, ready}; |
{ | ||
"name": "dom-event-helpers", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A super tiny DOM event helper library.", | ||
@@ -49,23 +49,25 @@ "repository": "https://github.com/jsor/dom-event-helpers.git", | ||
}, | ||
"dependencies": { | ||
"dom-query-helpers": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"babel-core": "^6.26.0", | ||
"babel-loader": "^7.1.4", | ||
"babel-preset-env": "^1.6.1", | ||
"babel-core": "^6.26.3", | ||
"babel-loader": "^7.1.5", | ||
"babel-preset-env": "^1.7.0", | ||
"chai": "^4.1.2", | ||
"istanbul-instrumenter-loader": "^3.0.0", | ||
"karma": "^2.0.0", | ||
"istanbul-instrumenter-loader": "^3.0.1", | ||
"karma": "^2.0.4", | ||
"karma-chai": "^0.1.0", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-coverage": "^1.1.1", | ||
"karma-coverage-istanbul-reporter": "^1.4.2", | ||
"karma-coverage": "^1.1.2", | ||
"karma-coverage-istanbul-reporter": "^2.0.1", | ||
"karma-firefox-launcher": "^1.1.0", | ||
"karma-mocha": "^1.3.0", | ||
"karma-mocha-reporter": "^2.2.5", | ||
"karma-sauce-launcher": "^1.2.0", | ||
"karma-webpack": "^2.0.13", | ||
"mocha": "^4.1.0", | ||
"karma-webpack": "^3.0.0", | ||
"mocha": "^5.2.0", | ||
"simulant": "^0.2.2", | ||
"webpack": "^4.1.1", | ||
"xo": "^0.20.3" | ||
"webpack": "^4.15.1", | ||
"xo": "^0.21.1" | ||
} | ||
} |
@@ -41,3 +41,3 @@ dom-event-helpers | ||
```javascript | ||
import { ready, on, off } from 'dom-event-helpers'; | ||
import { ready, on, off, delegate, dispatch } from 'dom-event-helpers'; | ||
``` | ||
@@ -123,2 +123,62 @@ | ||
### delegate() | ||
``` | ||
delegate(target: EventTarget, type: string, selector: string, listener: EventListener[, options: object]): function | ||
``` | ||
Registers a `listener` for the event `type` on `target` with `options` that | ||
processes events from descendant elements of `target` matching the specified | ||
`selector`. | ||
The function returns another function which can be used to unregister the event listener. | ||
#### Example | ||
```javascript | ||
const listener = function () { | ||
console.log('My Button clicked'); | ||
}; | ||
const options = { | ||
passive: true | ||
}; | ||
const remove = delegate( | ||
document, // Listen on document | ||
'click', | ||
'.my-button', | ||
listener, | ||
options | ||
); | ||
remove(); // Remove event listener | ||
``` | ||
### dispatch() | ||
``` | ||
dispatch(target: EventTarget, type: string[, eventInit: CustomEventInit]): function | ||
``` | ||
Dispatches a [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent) | ||
`type` at the specified `target` optionally using the `eventInit` options. | ||
#### Example | ||
```javascript | ||
dispatch(document, 'click'); | ||
dispatch( | ||
document.querySelector('.my-button'), | ||
'my:event', | ||
{ | ||
bubbles: true, | ||
cancelable: true, | ||
detail: { | ||
foo: 'bar' | ||
} | ||
} | ||
); | ||
``` | ||
License | ||
@@ -125,0 +185,0 @@ ------- |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9953
18
11
129
187
1
+ Addeddom-query-helpers@^1.0.0
+ Addeddom-query-helpers@1.1.0(transitive)