Socket
Socket
Sign inDemoInstall

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.4 to 1.1.5

34

event-listener-polyfill.js

@@ -14,18 +14,38 @@ (function() {

var prefixes = ['', 'webkit', 'moz', 'ms', 'o'];
var eventTypes = {
wheel: ['wheel', 'mousewheel', 'DOMMouseScroll']
wheel: ['wheel', 'mousewheel', 'DOMMouseScroll'].map(function(type) {
return { type: type, test: testOnEventTypeCallback } ;
})
};
var testOnEventTypeCallback = function(target, type) {
return (('on' + type) in target);
};
var testTransitionEventTypeCallback = function(target, type) {
return testOnEventTypeCallback(target, type) || (target.style['transition'] !== void 0);
};
[
'pointerlockchange', 'pointerlockerror',
'fullscreenchange', 'fullscreenerror',
'animationend', 'animationiteration', 'animationstart', 'transitionend',
'animationstart', 'animationiteration', 'animationend',
'pointercancel', 'pointerdown', 'pointerhover', 'pointermove', 'pointerout', 'pointerover', 'pointerup'
].forEach(function(type) {
eventTypes[type] = ['', 'webkit', 'moz', 'ms', 'o']
eventTypes[type] = prefixes
.map(function(prefix) {
return prefix + type;
return { type: (prefix + type), test: testOnEventTypeCallback } ;
});
});
['transitionstart', 'transitionrun', 'transitionend'].forEach(function(type) {
eventTypes[type] = prefixes
.map(function(prefix) {
return { type: (prefix + type), test: testTransitionEventTypeCallback } ;
});
});
var polyfillEventTypesName = function(type, target) {

@@ -38,4 +58,4 @@ var eventTypesPolyfiller = eventTypes[type];

for(; i < eventTypesPolyfiller.length; i++) {
if(('on' + eventTypesPolyfiller[i]) in target) {
return eventTypesPolyfiller[i];
if(eventTypesPolyfiller[i].test(target, type)) {
return eventTypesPolyfiller[i].type;
}

@@ -447,3 +467,3 @@ }

vendorArguments.type = formattedArguments.options.polyfill ?
polyfillEventTypesName(formattedArguments.type) :
polyfillEventTypesName(formattedArguments.type, this) :
formattedArguments.type

@@ -450,0 +470,0 @@ ;

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

(function(){if(typeof EventTarget==="undefined"){window.EventTarget=Node}var e={wheel:["wheel","mousewheel","DOMMouseScroll"]};["pointerlockchange","pointerlockerror","fullscreenchange","fullscreenerror","animationend","animationiteration","animationstart","transitionend","pointercancel","pointerdown","pointerhover","pointermove","pointerout","pointerover","pointerup"].forEach(function(n){e[n]=["","webkit","moz","ms","o"].map(function(e){return e+n})});var n=function(n,l){var t=e[n];if(t===void 0){return n}else{var u=0;for(;u<t.length;u++){if("on"+t[u]in l){return t[u]}}if(u===t.length){throw new Error("Not supported type <"+n+">")}}};var l={once:false,passive:false,capture:false};document.createDocumentFragment().addEventListener("test",function(){},{get once(){l.once=true;return false},get passive(){l.passive=true;return false},get capture(){l.capture=true;return false}});l.all=l.once&&l.passive&&l.capture;l.some=l.once||l.passive||l.capture;var t=[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 u=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 o=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 r=function(e,n,l){return{type:e,listener:u(n),options:o(l)}};var i=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 a=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 s=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 p=function(e){var u=e.prototype.addEventListener;e.prototype.addEventListener=function(e,o,a){var p=r(e,o,a);var c=s(this,p);if(!c){var f={};f.type=p.options.polyfill?n(p.type):p.type;f.listener=function(n){if(p.options.once&&!l.once){this.removeEventListener(e,o,a)}if(p.options.passive&&!l.passive){n.preventDefault=function(){throw new Error("Unable to preventDefault inside passive event listener invocation.")}}if(p.options.polyfill){n.type=p.type;if(n instanceof KeyboardEvent){if(!("code"in n)){n.code=t[n.keyCode]}}}return p.listener.call(this,n)};f.options=l.some?p.options:p.options.capture;p.vendorArguments=f;i(this,p);u.call(this,f.type,f.listener,f.options)}};var o=e.prototype.removeEventListener;e.prototype.removeEventListener=function(e,n,l){var t=r(e,n,l);var u=s(this,t);if(u){a(this,t);o.call(this,u.vendorArguments.type,u.vendorArguments.listener,u.vendorArguments.options)}else{o.call(this,e,n,l)}}};p(EventTarget);if(!(window instanceof EventTarget)){p(Window)}})();
(function(){if(typeof EventTarget==="undefined"){window.EventTarget=Node}var e=["","webkit","moz","ms","o"];var n={wheel:["wheel","mousewheel","DOMMouseScroll"].map(function(e){return{type:e,test:l}})};var l=function(e,n){return"on"+n in e};var t=function(e,n){return l(e,n)||e.style["transition"]!==void 0};["pointerlockchange","pointerlockerror","fullscreenchange","fullscreenerror","animationstart","animationiteration","animationend","pointercancel","pointerdown","pointerhover","pointermove","pointerout","pointerover","pointerup"].forEach(function(t){n[t]=e.map(function(e){return{type:e+t,test:l}})});["transitionstart","transitionrun","transitionend"].forEach(function(l){n[l]=e.map(function(e){return{type:e+l,test:t}})});var u=function(e,l){var t=n[e];if(t===void 0){return e}else{var u=0;for(;u<t.length;u++){if(t[u].test(l,e)){return t[u].type}}if(u===t.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)}})();
{
"name": "events-polyfill",
"version": "1.1.4",
"version": "1.1.5",
"description": "Polyfill event : EventListener, EventTarget, CustomEvent, MouseEvent, KeyboardEvent",

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

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