
Security News
rv Is a New Rust-Powered Ruby Version Manager Inspired by Python's uv
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
eventlistener-polyfill
Advanced tools
This tiny polyfill aims to add the once
and passive
event listener options to IE11 and Edge.
For more on those options, read the mdn documentation on EventListener
The main file is a UMD wrapper, so if you use requirejs, commonjs, or no module system you can load it in:
define('mymodule', ['eventlistener-polyfill'], function (polyfillEventTarget) {
// While the polyfill will automatically try to polyfill EventTarget, you may
// want to polyfill another class
polyfillEventTarget(MyCustomEventTarget)
})
// Just requiring the file is enough to register the polyfill
require('eventlistener-polyfill')
// While the polyfill will automatically try to polyfill EventTarget, you may
// want to polyfill another class
const polyfillEventTarget = require('eventlistener-polyfill')
polyfillEventTarget(MyCustomEventTarget)
<script src="node_modules/eventlistener-polyfill/index.js"></script>
<script>
// While the polyfill will automatically try to polyfill EventTarget, you may
// want to polyfill another class
window.polyfillEventTarget(MyCustomEventTarget)
</script>
We detect support for once
and passive
by making an object with getters for those options. If the browser were to retrieve those values, the getters would trigger and we would know the browser would (in some way) support them. This is working successfully for now - our tests pass in the browsers weve tested, even those where the polyfill is disabled.
When passing once: true
as an option, this polyfill simply wraps your callback in a function which calls removeEventListener
. You don't need to do anything special here - and removeEventListener
still works if you call it manually.
passive: true
is meant to hint to the browser to optimise these EventListeners, at the sacrifice of being unable to run preventDefault
. In browsers where this works, running preventDefault
will log an error to the console. This polyfill will not log anything to the console - as it is expected you'll be doing your own cross browser testing and notice this elsewhere. However, just in case, this polyfill does turn preventDefault
into a noop.
FAQs
Polyfills EventListener behaviours from IE11 onward
The npm package eventlistener-polyfill receives a total of 8,792 weekly downloads. As such, eventlistener-polyfill popularity was classified as popular.
We found that eventlistener-polyfill 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
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.