
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
event-listener-helper
Advanced tools
This library allows you to get a list of event listeners attached to the target node, confirms the existence of event listener registered on the target node, deletes all event listeners registered on the target node, registers event listeners with listene
This library allows you to:
These benefits can be received by calling addEventListener and removeEventListener via this library.
MIT License
const eh = new EventListenerHelper();
const btn = document.querySelector('#myButton');
eh.addEventListener(btn, 'click', () => {
alert('Hello!');
}, { listenerName: 'my-listener' });
const eh = new EventListenerHelper();
const btn = document.querySelector('#myButton');
eh.addEventListener(btn, 'click', () => {
alert('Hello!');
}, { listenerName: 'my-listener' });
eh.clearEventListener(btn, 'click', 'my-listener');
eh.getEventListeners(btn, 'click');
eh.hasEventListeners(btn, 'click');
https://riversun.github.io/event-listener-helper/
npm install event-listener-helper
or
<script>
tag from CDN <script src="https://cdn.jsdelivr.net/npm/event-listener-helper/lib/event-listener-helper.js"></script>
Kind: global class
Author: Tom Misawa (riversun.org@gmail.com,https://github.com/riversun)
function
boolean
boolean
This library allows you to: get a list of event listeners attached to the target node, confirms the existence of event listener registered on the target node, deletes all event listeners registered on the target node, registers event listeners with name (rather than a reference). These benefits can be received by calling addEventListener and removeEventListener through this library.
MIT License
Kind: instance method of EventListenerHelper
Param | Type | Description |
---|---|---|
eventTarget | EventTarget | EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them. EventTarget by Mozilla Contributors is licensed under CC-BY-SA 2.5. |
eventType | String | A case-sensitive string representing the event type to listen for. |
listener | function | The object which receives a notification (an object that implements the Event interface) when an event of the specified type occurs. This must be an object implementing the EventListener interface, or a JavaScript function. See The event listener callback for details on the callback itself. |
[options] | Object | An options object specifies characteristics about the event listener. The available options are:
addEventListener by Mozilla Contributors is licensed under CC-BY-SA 2.5. |
The EventListenerHelper#removeEventListener method removes from the EventTarget an event listener previously registered with EventListenerHelper#addEventListener. The event listener to be removed is identified using option. listenerName and a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal
Kind: instance method of EventListenerHelper
Param | Type | Description |
---|---|---|
eventTarget | EventTarget | EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them. EventTarget by Mozilla Contributors is licensed under CC-BY-SA 2.5. |
eventType | String | A string which specifies the type of event for which to remove an event listener. |
[listener] | function | (Either the listener or options.listenerName must be specified. If both are specified, options.listenerName takes precedence.) The object which receives a notification (an object that implements the Event interface) when an event of the specified type occurs. This must be an object implementing the EventListener interface, or a JavaScript function. See The event listener callback for details on the callback itself. |
[options] | Object | (Either the listener or options.listenerName must be specified. If both are specified, options.listenerName takes precedence.) An options object specifies characteristics about the event listener. The available options are:
removeEventListener by Mozilla Contributors is licensed under CC-BY-SA 2.5. |
Get a listener definition matching the specified eventTarget and eventType (optional). Please note that the return value is immutable.
Kind: instance method of EventListenerHelper
Returns: Example of the returned value when only eventTarget is specified:
[
{
eventType:click,
listener:[
{
listener:func,
options:{
listenerName:my-test-listener-1
}
},
{
listener:func,
options:{
capture:true,
listenerName:my-test-listener-2
}
}
]
},
{
eventType:mousemove,
listener:[
{
listener:func,
options:{
once:true,
listenerName:my-test-listener-3
}
}
]
}
]
[
{
options:{
listenerName:my-test-listener-1
},
listener:func1
},
{
options:{
capture:true,
listenerName:my-test-listener-2
},
listener:func2
},
{
options:{
once:true,
listenerName:my-test-listener-3
},
listener:func3
}
]
Param | Type | Description |
---|---|---|
eventTarget | EventTarget | EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them. EventTarget by Mozilla Contributors is licensed under CC-BY-SA 2.5. |
[eventType] | String | A case-sensitive string representing the event type to listen for. |
You can get listeners for "inputElement" 's "click" event by map chain.
Kind: instance method of EventListenerHelper
Returns: const listeners=result.get(inputElement).get('click');
function
Get a listener with the specified eventTarget, eventType and listenerName. The listenerName must be unique for one eventTarget and eventType combination, but it does not have to be unique for different eventTargets or different eventTypes.
Kind: instance method of EventListenerHelper
Returns: function
- Returns null if no listener function is found
Param | Type | Description |
---|---|---|
eventTarget | EventTarget | EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them. EventTarget by Mozilla Contributors is licensed under CC-BY-SA 2.5. |
eventType | String | A case-sensitive string representing the event type to listen for. |
listenerName | String | The listener name of the listener you want to find |
boolean
Returns whether or not there are more than one event listener for the given eventTarget and eventType.
Kind: instance method of EventListenerHelper
Param |
---|
eventTarget |
eventType |
boolean
Returns whether a listenerName exists for the specified eventTarget and eventType.
Kind: instance method of EventListenerHelper
Param | Type | Description |
---|---|---|
eventTarget | EventTarget | EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them. EventTarget by Mozilla Contributors is licensed under CC-BY-SA 2.5. |
eventType | String | A case-sensitive string representing the event type to listen for. |
listenerName | String | The listener name of the listener you want to find |
Removes all registered events through the addEventListener method.
Kind: instance method of EventListenerHelper
Remove all listeners matching the specified eventTarget and eventType (optional).
Kind: instance method of EventListenerHelper
Param | Type | Description |
---|---|---|
eventTarget | EventTarget | EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them. EventTarget by Mozilla Contributors is licensed under CC-BY-SA 2.5. |
[eventType] | String | A case-sensitive string representing the event type to listen for. |
Removes the eventListener with eventTarget, eventType, and listenerName as arguments. The functions are the same as those of removeEventListener, except for the way to give arguments.
Kind: instance method of EventListenerHelper
Param | Type | Description |
---|---|---|
eventTarget | EventTarget | EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them. EventTarget by Mozilla Contributors is licensed under CC-BY-SA 2.5. |
[eventType] | String | A case-sensitive string representing the event type to listen for. |
listenerName | String | The listener name of the listener you want to find |
Get all registered eventTargets through the #addEventListener method.
Kind: instance method of EventListenerHelper
Get all listeners(listener definition) with a given listenerName. Since listeners need only be unique to the eventTarget and eventType, it is possible to have the same listenerName for different eventTargets and eventTypes.
Kind: instance method of EventListenerHelper
Returns:
[ { options: { listenerName: 'my-test-listener' },
listener: [Function: func] },
{ options: { capture: true, listenerName: 'my-test-listener' },
listener: [Function: func] },
{ options: { once: true, listenerName: 'my-test-listener' },
listener: [Function: func] },
{ options: { once: true, listenerName: 'my-test-listener' },
listener: [Function: func] } ]
Param | Type | Description |
---|---|---|
listenerName | String | The listener name of the listener you want to find |
FAQs
This library allows you to get a list of event listeners attached to the target node, confirms the existence of event listener registered on the target node, deletes all event listeners registered on the target node, registers event listeners with listene
The npm package event-listener-helper receives a total of 0 weekly downloads. As such, event-listener-helper popularity was classified as not popular.
We found that event-listener-helper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.