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.7 to 1.1.8

tests/config.json

52

event-listener-polyfill.js

@@ -22,7 +22,29 @@ (function() {

var testFullScreenEventTypeCallback = function(target, type) {
if(testOnEventTypeCallback(target, type)) {
return true;
} else {
if(/^ms/.test(type.toLowerCase())) {
return !!document.body.msRequestFullscreen;
} else if(/^moz/.test(type)) {
return !!document.body.mozRequestFullscreen;
} else if(/^webkit/.test(type)) {
return !!document.body.webkitRequestFullscreen;
} else {
return false;
}
}
};
var prefixes = ['', 'webkit', 'moz', 'ms', 'o'];
var eventTypes = {
wheel: ['wheel', 'mousewheel', 'DOMMouseScroll'].map(function(type) {
'wheel': ['wheel', 'mousewheel', 'DOMMouseScroll'].map(function(type) {
return { type: type, test: testOnEventTypeCallback } ;
}),
'fullscreenchange': ['fullscreenchange', 'mozfullscreenchange', 'webkitfullscreenchange', 'MSFullscreenChange', 'msfullscreenchange'].map(function(type) {
return { type: type, test: testFullScreenEventTypeCallback } ;
}),
'fullscreenerror': ['fullscreenerror', 'mozfullscreenerror', 'webkitfullscreenerror', 'MSFullscreenError', 'msfullscreenerror'].map(function(type) {
return { type: type, test: testFullScreenEventTypeCallback } ;
})

@@ -33,3 +55,2 @@ };

'pointerlockchange', 'pointerlockerror',
'fullscreenchange', 'fullscreenerror',
'animationstart', 'animationiteration', 'animationend',

@@ -52,2 +73,3 @@ 'pointercancel', 'pointerdown', 'pointerhover', 'pointermove', 'pointerout', 'pointerover', 'pointerup'

var polyfillEventTypesName = function(type, target) {

@@ -60,3 +82,4 @@ var eventTypesPolyfiller = eventTypes[type];

for(; i < eventTypesPolyfiller.length; i++) {
if(eventTypesPolyfiller[i].test(target, type)) {
if(eventTypesPolyfiller[i].test(target, eventTypesPolyfiller[i].type)) {
console.log('use' + eventTypesPolyfiller[i].type);
return eventTypesPolyfiller[i].type;

@@ -467,3 +490,2 @@ }

vendorArguments.type = formattedArguments.options.polyfill ?

@@ -546,24 +568,2 @@ polyfillEventTypesName(formattedArguments.type, this) :

// var div = document.createElement('div');
// document.body.innerHTML = '';
// document.body.appendChild(div);
// div.style.height = '500px';
// div.style.background = 'red';
//
// var cb = function(event) {
// console.log('click', event);
// };
//
// div.addEventListener('click', cb, { passive: true, once: true, capture: false });
// div.removeEventListener('click', cb, false);
// div.addEventListener('click', cb, { passive: true, once: true, capture: true });
//
// div.addEventListener('wheel', function(event) {
// console.log('wheeliiing', event);
// }, { once: true });
//
// document.addEventListener('pointerlockchange', function(event) {
// console.log('pointerlockchange', event);
// });
})();

@@ -1,1 +0,1 @@

(function(){if(typeof EventTarget==="undefined"){window.EventTarget=Node}var e=function(e,n){return"on"+n in e};var n=function(n,l){return e(n,l)||n.style["transition"]!==void 0};var l=["","webkit","moz","ms","o"];var t={wheel:["wheel","mousewheel","DOMMouseScroll"].map(function(n){return{type:n,test:e}})};["pointerlockchange","pointerlockerror","fullscreenchange","fullscreenerror","animationstart","animationiteration","animationend","pointercancel","pointerdown","pointerhover","pointermove","pointerout","pointerover","pointerup"].forEach(function(n){t[n]=l.map(function(l){return{type:l+n,test:e}})});["transitionstart","transitionrun","transitionend"].forEach(function(e){t[e]=l.map(function(l){return{type:l+e,test:n}})});var u=function(e,n){var l=t[e];if(l===void 0){return e}else{var u=0;for(;u<l.length;u++){if(l[u].test(n,e)){return l[u].type}}if(u===l.length){throw new Error("Not supported type <"+e+">")}}};var r={once:false,passive:false,capture:false};document.createDocumentFragment().addEventListener("test",function(){},{get once(){r.once=true;return false},get passive(){r.passive=true;return false},get capture(){r.capture=true;return false}});r.all=r.once&&r.passive&&r.capture;r.some=r.once||r.passive||r.capture;var o=[null,null,null,null,null,null,null,null,"Backspace","Tab",null,null,"Numpad5","NumpadEnter",null,null,"ShiftLeft","ControlRight","AltRight","Pause","CapsLock",null,null,null,null,null,null,"Escape",null,null,null,null,"Space","PageUp","PageDown","End","Home","ArrowLeft","ArrowUp","ArrowRight","ArrowDown",null,null,null,null,"Insert","Delete",null,"Digit0","Digit1","Digit2","Digit3","Digit4","Digit5","Digit6","Digit7","Digit8","Digit9",null,null,null,null,null,null,null,"KeyA","KeyB","KeyC","KeyD","KeyE","KeyF","KeyG","KeyH","KeyI","KeyJ","KeyK","KeyL","KeyM","KeyN","KeyO","KeyP","KeyQ","KeyR","KeyS","KeyT","KeyU","KeyV","KeyW","KeyX","KeyZ","KeyY","MetaLeft","MetaRight","ContextMenu",null,null,"Numpad0","Numpad1","Numpad2","Numpad3","Numpad4","Numpad5","Numpad6","Numpad7","Numpad8","Numpad9","NumpadMultiply","NumpadAdd",null,"NumpadSubtract","NumpadDecimal","NumpadDivide","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"NumLock","ScrollLock",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"BracketLeft",null,"Comma","Slash","Period","Backquote","BracketRight",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"Minus","Quote","Equal","Semicolon","Backslash",null,null,"IntlBackslash"];var i=function(e){if(typeof e==="function"){return e}else if(typeof e==="object"&&typeof e.handleEvent==="function"){return e.handleEvent}else{return function(n){e(n)}}};var a=function(e){switch(typeof e){case"boolean":e={capture:e};break;case"undefined":e={capture:false};break;case"object":break;default:throw new Error("Unsupported options type for addEventListener");break}e.once=typeof e.once==="boolean"?e.once:false;e.passive=typeof e.passive==="boolean"?e.passive:false;e.capture=typeof e.capture==="boolean"?e.capture:false;e.polyfill=typeof e.polyfill==="boolean"?e.polyfill:true;return e};var s=function(e,n,l){return{type:e,listener:i(n),options:a(l)}};var p=function(e,n){var l=n.type+"-"+(n.options.capture?"1":"0");if(e.__eventListeners===void 0){e.__eventListeners={}}if(e.__eventListeners[l]===void 0){e.__eventListeners[l]=[]}e.__eventListeners[l].push(n)};var c=function(e,n){var l=n.type+"-"+(n.options.capture?"1":"0");if(e.__eventListeners!==void 0&&e.__eventListeners[l]!==void 0){var t=e.__eventListeners[l];for(var u=0;u<t.length;u++){if(t[u].listener===n.listener){t.splice(u,1)}}if(t.length===0){delete e.__eventListeners[l]}}};var f=function(e,n){var l=n.type+"-"+(n.options.capture?"1":"0");if(e.__eventListeners!==void 0&&e.__eventListeners[l]!==void 0){var t=e.__eventListeners[l];for(var u=0;u<t.length;u++){if(t[u].listener===n.listener){return t[u]}}}return null};var v=function(e){var n=e.prototype.addEventListener;e.prototype.addEventListener=function(e,l,t){var i=s(e,l,t);var a=f(this,i);if(!a){var c={};c.type=i.options.polyfill?u(i.type,this):i.type;c.listener=function(n){if(i.options.once&&!r.once){this.removeEventListener(e,l,t)}if(i.options.passive&&!r.passive){n.preventDefault=function(){throw new Error("Unable to preventDefault inside passive event listener invocation.")}}if(i.options.polyfill){n.type=i.type;if(n instanceof KeyboardEvent){if(!("code"in n)){n.code=o[n.keyCode]}}}return i.listener.call(this,n)};c.options=r.some?i.options:i.options.capture;i.vendorArguments=c;p(this,i);n.call(this,c.type,c.listener,c.options)}};var l=e.prototype.removeEventListener;e.prototype.removeEventListener=function(e,n,t){var u=s(e,n,t);var r=f(this,u);if(r){c(this,u);l.call(this,r.vendorArguments.type,r.vendorArguments.listener,r.vendorArguments.options)}else{l.call(this,e,n,t)}}};v(EventTarget);if(!(window instanceof EventTarget)){v(Window)}})();
(function(){if(typeof EventTarget==="undefined"){window.EventTarget=Node}var e=function(e,n){return"on"+n in e};var n=function(n,l){return e(n,l)||n.style["transition"]!==void 0};var l=function(n,l){if(e(n,l)){return true}else{if(/^ms/.test(l.toLowerCase())){return!!document.body.msRequestFullscreen}else if(/^moz/.test(l)){return!!document.body.mozRequestFullscreen}else if(/^webkit/.test(l)){return!!document.body.webkitRequestFullscreen}else{return false}}};var t=["","webkit","moz","ms","o"];var u={wheel:["wheel","mousewheel","DOMMouseScroll"].map(function(n){return{type:n,test:e}}),fullscreenchange:["fullscreenchange","mozfullscreenchange","webkitfullscreenchange","MSFullscreenChange","msfullscreenchange"].map(function(e){return{type:e,test:l}}),fullscreenerror:["fullscreenerror","mozfullscreenerror","webkitfullscreenerror","MSFullscreenError","msfullscreenerror"].map(function(e){return{type:e,test:l}})};["pointerlockchange","pointerlockerror","animationstart","animationiteration","animationend","pointercancel","pointerdown","pointerhover","pointermove","pointerout","pointerover","pointerup"].forEach(function(n){u[n]=t.map(function(l){return{type:l+n,test:e}})});["transitionstart","transitionrun","transitionend"].forEach(function(e){u[e]=t.map(function(l){return{type:l+e,test:n}})});var r=function(e,n){var l=u[e];if(l===void 0){return e}else{var t=0;for(;t<l.length;t++){if(l[t].test(n,l[t].type)){console.log("use"+l[t].type);return l[t].type}}if(t===l.length){throw new Error("Not supported type <"+e+">")}}};var o={once:false,passive:false,capture:false};document.createDocumentFragment().addEventListener("test",function(){},{get once(){o.once=true;return false},get passive(){o.passive=true;return false},get capture(){o.capture=true;return false}});o.all=o.once&&o.passive&&o.capture;o.some=o.once||o.passive||o.capture;var i=[null,null,null,null,null,null,null,null,"Backspace","Tab",null,null,"Numpad5","NumpadEnter",null,null,"ShiftLeft","ControlRight","AltRight","Pause","CapsLock",null,null,null,null,null,null,"Escape",null,null,null,null,"Space","PageUp","PageDown","End","Home","ArrowLeft","ArrowUp","ArrowRight","ArrowDown",null,null,null,null,"Insert","Delete",null,"Digit0","Digit1","Digit2","Digit3","Digit4","Digit5","Digit6","Digit7","Digit8","Digit9",null,null,null,null,null,null,null,"KeyA","KeyB","KeyC","KeyD","KeyE","KeyF","KeyG","KeyH","KeyI","KeyJ","KeyK","KeyL","KeyM","KeyN","KeyO","KeyP","KeyQ","KeyR","KeyS","KeyT","KeyU","KeyV","KeyW","KeyX","KeyZ","KeyY","MetaLeft","MetaRight","ContextMenu",null,null,"Numpad0","Numpad1","Numpad2","Numpad3","Numpad4","Numpad5","Numpad6","Numpad7","Numpad8","Numpad9","NumpadMultiply","NumpadAdd",null,"NumpadSubtract","NumpadDecimal","NumpadDivide","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"NumLock","ScrollLock",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"BracketLeft",null,"Comma","Slash","Period","Backquote","BracketRight",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"Minus","Quote","Equal","Semicolon","Backslash",null,null,"IntlBackslash"];var s=function(e){if(typeof e==="function"){return e}else if(typeof e==="object"&&typeof e.handleEvent==="function"){return e.handleEvent}else{return function(n){e(n)}}};var a=function(e){switch(typeof e){case"boolean":e={capture:e};break;case"undefined":e={capture:false};break;case"object":break;default:throw new Error("Unsupported options type for addEventListener");break}e.once=typeof e.once==="boolean"?e.once:false;e.passive=typeof e.passive==="boolean"?e.passive:false;e.capture=typeof e.capture==="boolean"?e.capture:false;e.polyfill=typeof e.polyfill==="boolean"?e.polyfill:true;return e};var p=function(e,n,l){return{type:e,listener:s(n),options:a(l)}};var c=function(e,n){var l=n.type+"-"+(n.options.capture?"1":"0");if(e.__eventListeners===void 0){e.__eventListeners={}}if(e.__eventListeners[l]===void 0){e.__eventListeners[l]=[]}e.__eventListeners[l].push(n)};var f=function(e,n){var l=n.type+"-"+(n.options.capture?"1":"0");if(e.__eventListeners!==void 0&&e.__eventListeners[l]!==void 0){var t=e.__eventListeners[l];for(var u=0;u<t.length;u++){if(t[u].listener===n.listener){t.splice(u,1)}}if(t.length===0){delete e.__eventListeners[l]}}};var v=function(e,n){var l=n.type+"-"+(n.options.capture?"1":"0");if(e.__eventListeners!==void 0&&e.__eventListeners[l]!==void 0){var t=e.__eventListeners[l];for(var u=0;u<t.length;u++){if(t[u].listener===n.listener){return t[u]}}}return null};var y=function(e){var n=e.prototype.addEventListener;e.prototype.addEventListener=function(e,l,t){var u=p(e,l,t);var s=v(this,u);if(!s){var a={};a.type=u.options.polyfill?r(u.type,this):u.type;a.listener=function(n){if(u.options.once&&!o.once){this.removeEventListener(e,l,t)}if(u.options.passive&&!o.passive){n.preventDefault=function(){throw new Error("Unable to preventDefault inside passive event listener invocation.")}}if(u.options.polyfill){n.type=u.type;if(n instanceof KeyboardEvent){if(!("code"in n)){n.code=i[n.keyCode]}}}return u.listener.call(this,n)};a.options=o.some?u.options:u.options.capture;u.vendorArguments=a;c(this,u);n.call(this,a.type,a.listener,a.options)}};var l=e.prototype.removeEventListener;e.prototype.removeEventListener=function(e,n,t){var u=p(e,n,t);var r=v(this,u);if(r){f(this,u);l.call(this,r.vendorArguments.type,r.vendorArguments.listener,r.vendorArguments.options)}else{l.call(this,e,n,t)}}};y(EventTarget);if(!(window instanceof EventTarget)){y(Window)}})();
{
"name": "events-polyfill",
"version": "1.1.7",
"version": "1.1.8",
"description": "Polyfill event : EventListener, EventTarget, CustomEvent, MouseEvent, KeyboardEvent",

@@ -9,3 +9,5 @@ "main": "event-constructor-polyfill.js",

"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"
"min.constructor": "uglifyjs event-constructor-polyfill.js --stats -m -o event-constructor-polyfill.min.js",
"test": "mocha ./tests/test.js",
"serve": "http-server ./"
},

@@ -19,4 +21,7 @@ "repository": {

"devDependencies": {
"http-server": "^0.9.0",
"mocha": "^3.2.0",
"selenium-webdriver": "^3.3.0",
"uglify-js": "^2.7.5"
}
}
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