Polyfill for the getEventListeners method available in dev tools.
Includes a) extended event listener options such as 'first', 'last' and 'unstoppable' and b) a patch that will scope calls to 'stopPropagation()' to only apply to other event listeners under the same propagation root (ie. under the same ShadowRoot/window). These additions are separated in different modules.
- WhatIs EventTarget
- WhatIs EquivalentEventListener
- Why ExtendEventTarget
- Pattern EventTargetRegistry
- Pattern HasAndGetEventListeners
- WhatIs onclickEtc
- Pattern OnceEventListenerOption
- Pattern FirstEventListener
- Pattern EventListenerPriority
- Pattern Event IsStopped
- Pattern UnstoppableEventListeners
- Pattern LastEventListenerOption
- Pattern ScopedStopProp
- Pattern GuaranteedBubbleListener
- Pattern ImmediateOnlyEventListenerOption
x. make a chapter about the getEventListeners() method in Chrome dev tools. y. we need a discussion about the safety of the getEventListeners() method.
- functions can be retrieved from the dom elements. this means that there source can be printed. to avoid that, wrap them inside anoter function that calls them, or bind them.
- hide the access to the getEventListeners method, do not make it available via the window object for example, but keep its reference locked inside your framework js files.
The simple getEventListener(eventTarget)
supports the native once
event listener option. The ES6 import
returns an addEventTargetRegistry()
function that should be run before any event listeners are added to the DOM.
import {addEventTargetRegistry} from "https://cdn.jsdelivr.net/gh/orstavik/getEventListeners@1.0.1/src/getEventListeners_once.js";
window.getEventListeners = addEventTargetRegistry();
To enable full development of web components that act like native web components you MUST have something like this.
import {addGetEventListeners_allOptions} from "https://cdn.jsdelivr.net/gh/orstavik/getEventListeners@1.1.2/src/getEventListeners_allOptions.js";
const {getEventListeners, isStopped} = addGetEventListeners_allOptions();