Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

events-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

events-polyfill - npm Package Compare versions

Comparing version 1.1.11 to 2.0.0

index.js

22

package.json
{
"name": "events-polyfill",
"version": "1.1.11",
"version": "2.0.0",
"description": "Polyfill event : EventListener, EventTarget, Event, CustomEvent, MouseEvent, KeyboardEvent, FocusEvent",
"main": "event-constructor-polyfill.js",
"main": "index.js",
"scripts": {
"start": "npm run min.listener && npm run min.constructor",
"min.listener": "uglifyjs event-listener-polyfill.js --stats -m -o event-listener-polyfill.min.js",
"min.constructor": "uglifyjs event-constructor-polyfill.js --stats -m -o event-constructor-polyfill.min.js",
"test": "mocha ./tests/test.js",
"start": "npm run build.min",
"build": "browserify ./src/index.js -o index.js",
"build.min": "npm run build && npm run min",
"min": "uglifyjs index.js --stats -m -o index.min.js",
"test": "node ./tests/test.js",
"serve": "http-server ./"

@@ -20,7 +21,8 @@ },

"devDependencies": {
"http-server": "^0.9.0",
"mocha": "^3.2.0",
"selenium-webdriver": "^3.3.0",
"uglify-js": "^2.7.5"
"browserify": "^15.2.0",
"http-server": "^0.10.0",
"mocha": "^3.4.2",
"selenium-webdriver": "^4.0.0-alpha.1",
"uglify-js": "^3.0.14"
}
}

@@ -10,3 +10,9 @@ ### Polyfill different events classes and methods to match last ES7 specifications

#### event-constructor-polyfill.js
For fast use `import 'events-polyfill'` (will import index.js).
**[INFO]** New release v2 that allow you to import specific polyfills only:
- you can use webpack (or any bundler) to import only required polyfills from `src/`.
- or you can import index.js (or index.min.js) at the root to polyfill everything.
#### src/constructors/*.js
Polyfill for :

@@ -19,4 +25,4 @@ [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event),

#### event-listener-polyfill.js
Polyfill for :
#### src/ListenerOptions.js
Polyfill for the `options` argument of :
```js

@@ -27,11 +33,26 @@ EventTarget.prototype.addEventListener(type, listener[, options]);

**type** : name of the event
**options** : last parameter which replace boolean useCapture
* [once](https://developers.google.com/web/updates/2016/10/addeventlistener-once) : trigger only once this event (default: false)
* [passive](https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md) : allow browser to continue animations (ex: while scrolling) by 'disabling' event.preventDefault() (default: false)
* capture : replace useCapture (default: false)
#### Example:
```js
document.addEventListener('click', function() {
console.log('clicked once');
}, { once: true });
```
#### src/ListenerEventTypes.js
Polyfill for the `type` argument of :
```js
EventTarget.prototype.addEventListener(type, listener[, options]);
EventTarget.prototype.removeEventListener(type, listener[, options]);
```
Polyfill vendor prefixed events like 'pointerlockchange' (try 'pointerlockchange', 'mozpointerlockchange' and 'webkitpointerlockchange') and some *'experimental'* events like 'wheel' (try 'wheel', 'mousewheel', 'DOMMouseScroll')
* **[INFO]** If option can't be polyfilled : throw an error (allow you to check is event type is supported)
* If option 'polyfill' set to false : disable polyfill (ex: for custom events)
* If option 'polyfill' set to true AND can't be polyfilled : throw an error (allow you to check is event type is supported)
Polyfilled types :
Currently polyfilled types :
```js

@@ -45,21 +66,2 @@ [

]
```
**listener** : the callback
**options** : last parameter which replace boolean useCapture
* [once](https://developers.google.com/web/updates/2016/10/addeventlistener-once) : trigger only once this event (default: false)
* [passive](https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md) : allow browser to continue animations (ex: while scrolling) by 'disabling' event.preventDefault() (default: false)
* capture : replace useCapture (default: false)
* polyfill : custorm property which tell if vendor properties should be auto prefixed (default: true)
#### Example:
```js
document.addEventListener('pointerlockchange', function(event) {
console.log('pointerlockchange', event);
}, { polyfill: true }); // here polyfill: true could be omited because it's the default value
document.addEventListener('click', function() {
document.body.requestPointerLock();
}, { once: true });
```
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc