events-polyfill
Advanced tools
Comparing version 2.0.1 to 2.0.2
78
index.js
@@ -472,3 +472,3 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
} catch(error) { | ||
var EventOriginal = window.CustomEvent || window.Event; | ||
var EventOriginal = window.Event; | ||
var Event = function(eventName, params) { | ||
@@ -627,2 +627,73 @@ params = params || {}; | ||
},{}],9:[function(require,module,exports){ | ||
(function() { | ||
/** | ||
* Polyfill PointerEvent | ||
* - pointerId ✓ | ||
* - width ✓ | ||
* - height ✓ | ||
* - pressure ✓ | ||
* - tangentialPressure ✓ | ||
* - tiltX ✓ | ||
* - tiltY ✓ | ||
* - twist ✓ | ||
* - pointerType ✓ | ||
* - isPrimary ✓ | ||
*/ | ||
try { | ||
var event = new window.PointerEvent('event', { bubbles: true, cancelable: true }); | ||
} catch (error) { | ||
var PointerEventOriginal = window.PointerEvent || window.Event; | ||
var PointerEvent = function(eventName, params) { | ||
params = params || {}; | ||
var event = document.createEvent('PointerEvent'); | ||
// https://msdn.microsoft.com/en-us/library/jj192039(v=vs.85).aspx | ||
event.initPointerEvent( | ||
eventName, | ||
(params.bubbles === void 0) ? false : params.bubbles, | ||
(params.cancelable === void 0) ? false : params.cancelable, | ||
(params.view === void 0) ? window : params.view, | ||
(params.detail === void 0) ? 0 : params.detail, | ||
(params.screenX === void 0) ? 0 : params.screenX, | ||
(params.screenY === void 0) ? 0 : params.screenY, | ||
(params.clientX === void 0) ? 0 : params.clientX, | ||
(params.clientY === void 0) ? 0 : params.clientY, | ||
(params.ctrlKey === void 0) ? false : params.ctrlKey, | ||
(params.altKey === void 0) ? false : params.altKey, | ||
(params.shiftKey === void 0) ? false : params.shiftKey, | ||
(params.metaKey === void 0) ? false : params.metaKey, | ||
(params.button === void 0) ? 0 : params.button, | ||
(params.relatedTarget === void 0) ? null : params.relatedTarget, | ||
(params.offsetX === void 0) ? 0 : params.offsetX, | ||
(params.offsetY === void 0) ? 0 : params.offsetY, | ||
(params.width === void 0) ? 1 : params.width, | ||
(params.height === void 0) ? 1 : params.height, | ||
(params.pressure === void 0) ? 0 : params.pressure, | ||
(params.twist === void 0) ? 0 : params.twist, | ||
(params.tiltX === void 0) ? 0 : params.tiltX, | ||
(params.tiltY === void 0) ? 0 : params.tiltY, | ||
(params.pointerId === void 0) ? 0 : params.pointerId, | ||
(params.pointerType === void 0) ? '' : params.pointerType, | ||
(params.hwTimestamp === void 0) ? 0 : params.hwTimestamp, | ||
(params.isPrimary === void 0) ? false : params.isPrimary | ||
); | ||
event.tangentialPressure = (params.tangentialPressure === void 0) ? 0 : params.tangentialPressure; | ||
return event; | ||
}; | ||
PointerEvent.prototype = PointerEventOriginal.prototype; | ||
Object.defineProperty( | ||
PointerEvent.prototype, | ||
'twist', | ||
Object.getOwnPropertyDescriptor(PointerEvent.prototype, 'rotation') | ||
); | ||
window.PointerEvent = PointerEvent; | ||
} | ||
})(); | ||
},{}],10:[function(require,module,exports){ | ||
require('./Event.js'); | ||
@@ -633,3 +704,4 @@ require('./CustomEvent.js'); | ||
require('./FocusEvent.js'); | ||
},{"./CustomEvent.js":4,"./Event.js":5,"./FocusEvent.js":6,"./KeyboardEvent.js":7,"./MouseEvent.js":8}],10:[function(require,module,exports){ | ||
require('./PointerEvent.js'); | ||
},{"./CustomEvent.js":4,"./Event.js":5,"./FocusEvent.js":6,"./KeyboardEvent.js":7,"./MouseEvent.js":8,"./PointerEvent.js":9}],11:[function(require,module,exports){ | ||
require('./constructors/index.js'); | ||
@@ -639,2 +711,2 @@ require('./ListenerOptions.js'); | ||
},{"./ListenerEventTypes.js":2,"./ListenerOptions.js":3,"./constructors/index.js":9}]},{},[10]); | ||
},{"./ListenerEventTypes.js":2,"./ListenerOptions.js":3,"./constructors/index.js":10}]},{},[11]); |
@@ -1,1 +0,1 @@ | ||
(function e(t,n,r){function i(s,p){if(!n[s]){if(!t[s]){var l=typeof require=="function"&&require;if(!p&&l)return l(s,!0);if(o)return o(s,!0);var a=new Error("Cannot find module '"+s+"'");throw a.code="MODULE_NOT_FOUND",a}var u=n[s]={exports:{}};t[s][0].call(u.exports,function(e){var n=t[s][1][e];return i(n?n:e)},u,u.exports,e,t,n,r)}return n[s].exports}var o=typeof require=="function"&&require;for(var s=0;s<r.length;s++)i(r[s]);return i})({1:[function(e,t,n){t.exports=function(){if(typeof EventTarget==="undefined"){window.EventTarget=Node}var e={interceptors:[]};e.getRegisteredEventListener=function(e,t){var n=t.type+"-"+(t.options.capture?"1":"0");if(e.__eventListeners!==void 0&&e.__eventListeners[n]!==void 0){var r=e.__eventListeners[n];for(var i=0;i<r.length;i++){if(r[i].listener===t.listener){return r[i]}}}return null};e.registerEventListener=function(e,t){var n=t.type+"-"+(t.options.capture?"1":"0");if(e.__eventListeners===void 0){e.__eventListeners={}}if(e.__eventListeners[n]===void 0){e.__eventListeners[n]=[]}e.__eventListeners[n].push(t)};e.unregisterEventListener=function(e,t){var n=t.type+"-"+(t.options.capture?"1":"0");if(e.__eventListeners!==void 0&&e.__eventListeners[n]!==void 0){var r=e.__eventListeners[n];for(var i=0;i<r.length;i++){if(r[i].listener===t.listener){r.splice(i,1)}}if(r.length===0){delete e.__eventListeners[n]}}};e.normalizeListenerCallback=function(e){if(typeof e==="function"){return e}else if(typeof e==="object"&&typeof e.handleEvent==="function"){return e.handleEvent}else{return function(t){e(t)}}};e.normalizeListenerOptions=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")}e.once=Boolean(e.once);e.passive=Boolean(e.passive);e.capture=Boolean(e.capture);return e};e.normalizeListenerArguments=function(e,t,n){return{type:e,listener:this.normalizeListenerCallback(t),options:this.normalizeListenerOptions(n)}};e.intercept=function(e,t){var n=null;for(var r=0;r<this.interceptors.length;r++){if(this.interceptors[r].target===e){n=this.interceptors[r]}}if(n===null){n={target:e,interceptors:[t]};this.interceptors.push(n);this.interceptAddEventListener(e,n);this.interceptRemoveEventListener(e,n)}else{n.interceptors.push(t)}};e.interceptAddEventListener=function(e,t){var n=this;var r=e.prototype.addEventListener;e.prototype.addEventListener=function(e,i,o){var s=n.normalizeListenerArguments(e,i,o);var p=n.getRegisteredEventListener(this,s);if(!p){s.polyfilled={type:s.type,listener:s.listener,options:{capture:s.options.capture,once:s.options.once,passive:s.options.passive}};for(var l=0;l<t.interceptors.length;l++){var a=t.interceptors[l];if(typeof a.add==="function"){a.add(s)}}n.registerEventListener(this,s);r.call(this,s.polyfilled.type,s.polyfilled.listener,s.polyfilled.options)}};return function(){e.prototype.addEventListener=r}};e.interceptRemoveEventListener=function(e,t){var n=this;var r=e.prototype.removeEventListener;e.prototype.removeEventListener=function(e,t,i){var o=n.normalizeListenerArguments(e,t,i);var s=n.getRegisteredEventListener(this,o);if(s){n.unregisterEventListener(this,o);r.call(this,s.polyfilled.type,s.polyfilled.listener,s.polyfilled.options)}else{r.call(this,e,t,i)}};return function(){e.prototype.removeEventListener=r}};e.interceptAll=function(e){this.intercept(EventTarget,e);if(!(window instanceof EventTarget)){this.intercept(Window,e)}};e.releaseAll=function(){for(var e=0,t=this.interceptors.length;e<t;e++){this.interceptors()}};return e}()},{}],2:[function(e,t,n){(function(e){e.isSupportedOnEvent=function(e,t){return"on"+t in e};e.isSupportedTransitionEvent=function(t,n){return e.isSupportedOnEvent(t,n)||t.style["transition"]!==void 0};e.isSupportedFullScreenEvent=function(t,n){if(e.isSupportedOnEvent(t,n)){return true}else{if(/^ms/.test(n.toLowerCase())){return"msRequestFullscreen"in document.body}else if(/^moz/.test(n)){return"mozRequestFullscreen"in document.body}else if(/^webkit/.test(n)){return"webkitRequestFullscreen"in document.body}else{return false}}};e.generateEventTypes=function(){var e=this;this.eventTypes={};this.vendorPrefixes=["","webkit","moz","ms","o"];this.eventTypes["wheel"]=["wheel","mousewheel","DOMMouseScroll"].map(function(t){return{type:t,isSupported:e.isSupportedOnEvent}});this.eventTypes["fullscreenchange"]=["fullscreenchange","mozfullscreenchange","webkitfullscreenchange","MSFullscreenChange","msfullscreenchange"].map(function(t){return{type:t,isSupported:e.isSupportedFullScreenEvent}});this.eventTypes["fullscreenerror"]=["fullscreenerror","mozfullscreenerror","webkitfullscreenerror","MSFullscreenError","msfullscreenerror"].map(function(t){return{type:t,isSupported:e.isSupportedFullScreenEvent}});["pointerlockchange","pointerlockerror","animationstart","animationiteration","animationend","pointercancel","pointerdown","pointerhover","pointermove","pointerout","pointerover","pointerup"].forEach(function(t){e.eventTypes[t]=e.vendorPrefixes.map(function(n){return{type:n+t,isSupported:e.isSupportedOnEvent}})});["transitionstart","transitionrun","transitionend"].forEach(function(t){e.eventTypes[t]=e.vendorPrefixes.map(function(n){return{type:n+t,isSupported:e.isSupportedTransitionEvent}})})};e.getSupportedEventType=function(e,t){var n=this.eventTypes[t];if(n===void 0){return t}else{var r;for(var i=0;i<n.length;i++){r=n[i];if(r.isSupported(e,r.type)){return r.type}}throw new Error("Event listener type "+String(t)+" on "+String(e)+" is not supported by current environment")}};e.polyfillListenerEventTypes=function(){this.generateEventTypes();var e=this;this.interceptAll({add:function(t){t.polyfilled.type=e.getSupportedEventType(this,t.polyfilled.type)}})};e.polyfillListenerEventTypes()})(e("./EventListenerInterceptor.js"))},{"./EventListenerInterceptor.js":1}],3:[function(e,t,n){(function(e){e.detectSupportedOptions=function(){var e=this;this.supportedOptions={once:false,passive:false,capture:false,all:false,some:false};document.createDocumentFragment().addEventListener("test",function(){},{get once(){e.supportedOptions.once=true;return false},get passive(){e.supportedOptions.passive=true;return false},get capture(){e.supportedOptions.capture=true;return false}});this.supportedOptions.all=this.supportedOptions.once&&this.supportedOptions.passive&&this.supportedOptions.capture;this.supportedOptions.some=this.supportedOptions.once||this.supportedOptions.passive||this.supportedOptions.capture};e.polyfillListenerOptions=function(){this.detectSupportedOptions();if(!this.supportedOptions.all){var e=this;this.interceptAll({add:function(t){var n=t.options.once&&!e.supportedOptions.once;var r=t.options.passive&&!e.supportedOptions.passive;if(n||r){var i=t.polyfilled.listener;t.polyfilled.listener=function(e){if(n){this.removeEventListener(t.type,t.listener,t.options)}if(r){e.preventDefault=function(){throw new Error("Unable to preventDefault inside passive event listener invocation.")}}return i.call(this,e)}}if(!e.supportedOptions.some){t.polyfilled.options=t.options.capture}}})}};e.polyfillListenerOptions()})(e("./EventListenerInterceptor.js"))},{"./EventListenerInterceptor.js":1}],4:[function(e,t,n){(function(){try{var e=new window.CustomEvent("event",{bubbles:true,cancelable:true})}catch(e){var t=window.CustomEvent||window.Event;var n=function(e,t){t=t||{};var n=document.createEvent("CustomEvent");n.initCustomEvent(e,t.bubbles===void 0?false:t.bubbles,t.cancelable===void 0?false:t.cancelable,t.detail===void 0?{}:t.detail);return n};n.prototype=t.prototype;window.CustomEvent=n}})()},{}],5:[function(e,t,n){(function(){try{var e=new window.Event("event",{bubbles:true,cancelable:true})}catch(e){var t=window.CustomEvent||window.Event;var n=function(e,t){t=t||{};var n=document.createEvent("Event");n.initEvent(e,t.bubbles===void 0?false:t.bubbles,t.cancelable===void 0?false:t.cancelable,t.detail===void 0?{}:t.detail);return n};n.prototype=t.prototype;window.Event=n}})()},{}],6:[function(e,t,n){(function(){try{var e=new window.FocusEvent("event",{bubbles:true,cancelable:true})}catch(e){var t=window.FocusEvent||window.Event;var n=function(e,t){t=t||{};var n=document.createEvent("FocusEvent");n.initFocusEvent(e,t.bubbles===void 0?false:t.bubbles,t.cancelable===void 0?false:t.cancelable,t.view===void 0?window:t.view,t.detail===void 0?{}:t.detail,t.relatedTarget===void 0?null:t.relatedTarget);return n};n.prototype=t.prototype;window.FocusEvent=n}})()},{}],7:[function(e,t,n){(function(){try{var e=new window.KeyboardEvent("event",{bubbles:true,cancelable:true})}catch(e){var t=window.KeyboardEvent||window.Event;var n=function(e,t){t=t||{};var n=document.createEvent("KeyboardEvent");n.initKeyboardEvent(e,t.bubbles===void 0?false:t.bubbles,t.cancelable===void 0?false:t.cancelable,t.view===void 0?window:t.view,t.key===void 0?"":t.key,t.location===void 0?0:t.location,(t.ctrlKey===true?"Control ":"")+(t.altKey===true?"Alt ":"")+(t.shiftKey===true?"Shift ":"")+(t.metaKey===true?"Meta ":""),t.repeat===void 0?false:t.repeat,t.locale===void 0?navigator.language:t.locale);n.keyCode=t.keyCode===void 0?0:t.keyCode;n.code=t.code===void 0?"":t.code;n.charCode=t.charCode===void 0?0:t.charCode;n.char=t.charCode===void 0?"":t.charCode;n.which=t.which===void 0?0:t.which;return n};n.prototype=t.prototype;window.KeyboardEvent=n}})()},{}],8:[function(e,t,n){(function(){try{var e=new window.MouseEvent("event",{bubbles:true,cancelable:true})}catch(e){var t=window.MouseEvent||window.Event;var n=function(e,t){t=t||{};var n=document.createEvent("MouseEvent");n.initMouseEvent(e,t.bubbles===void 0?false:t.bubbles,t.cancelable===void 0?false:t.cancelable,t.view===void 0?window:t.view,t.detail===void 0?0:t.detail,t.screenX===void 0?0:t.screenX,t.screenY===void 0?0:t.screenY,t.clientX===void 0?0:t.clientX,t.clientY===void 0?0:t.clientY,t.ctrlKey===void 0?false:t.ctrlKey,t.altKey===void 0?false:t.altKey,t.shiftKey===void 0?false:t.shiftKey,t.metaKey===void 0?false:t.metaKey,t.button===void 0?0:t.button,t.relatedTarget===void 0?null:t.relatedTarget);n.buttons=t.buttons===void 0?0:t.buttons;n.region=t.region===void 0?null:t.region;return n};n.prototype=t.prototype;window.MouseEvent=n}})()},{}],9:[function(e,t,n){e("./Event.js");e("./CustomEvent.js");e("./MouseEvent.js");e("./KeyboardEvent.js");e("./FocusEvent.js")},{"./CustomEvent.js":4,"./Event.js":5,"./FocusEvent.js":6,"./KeyboardEvent.js":7,"./MouseEvent.js":8}],10:[function(e,t,n){e("./constructors/index.js");e("./ListenerOptions.js");e("./ListenerEventTypes.js")},{"./ListenerEventTypes.js":2,"./ListenerOptions.js":3,"./constructors/index.js":9}]},{},[10]); | ||
(function e(t,n,i){function r(s,a){if(!n[s]){if(!t[s]){var l=typeof require=="function"&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);var p=new Error("Cannot find module '"+s+"'");throw p.code="MODULE_NOT_FOUND",p}var v=n[s]={exports:{}};t[s][0].call(v.exports,function(e){var n=t[s][1][e];return r(n?n:e)},v,v.exports,e,t,n,i)}return n[s].exports}var o=typeof require=="function"&&require;for(var s=0;s<i.length;s++)r(i[s]);return r})({1:[function(e,t,n){t.exports=function(){if(typeof EventTarget==="undefined"){window.EventTarget=Node}var e={interceptors:[]};e.getRegisteredEventListener=function(e,t){var n=t.type+"-"+(t.options.capture?"1":"0");if(e.__eventListeners!==void 0&&e.__eventListeners[n]!==void 0){var i=e.__eventListeners[n];for(var r=0;r<i.length;r++){if(i[r].listener===t.listener){return i[r]}}}return null};e.registerEventListener=function(e,t){var n=t.type+"-"+(t.options.capture?"1":"0");if(e.__eventListeners===void 0){e.__eventListeners={}}if(e.__eventListeners[n]===void 0){e.__eventListeners[n]=[]}e.__eventListeners[n].push(t)};e.unregisterEventListener=function(e,t){var n=t.type+"-"+(t.options.capture?"1":"0");if(e.__eventListeners!==void 0&&e.__eventListeners[n]!==void 0){var i=e.__eventListeners[n];for(var r=0;r<i.length;r++){if(i[r].listener===t.listener){i.splice(r,1)}}if(i.length===0){delete e.__eventListeners[n]}}};e.normalizeListenerCallback=function(e){if(typeof e==="function"){return e}else if(typeof e==="object"&&typeof e.handleEvent==="function"){return e.handleEvent}else{return function(t){e(t)}}};e.normalizeListenerOptions=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")}e.once=Boolean(e.once);e.passive=Boolean(e.passive);e.capture=Boolean(e.capture);return e};e.normalizeListenerArguments=function(e,t,n){return{type:e,listener:this.normalizeListenerCallback(t),options:this.normalizeListenerOptions(n)}};e.intercept=function(e,t){var n=null;for(var i=0;i<this.interceptors.length;i++){if(this.interceptors[i].target===e){n=this.interceptors[i]}}if(n===null){n={target:e,interceptors:[t]};this.interceptors.push(n);this.interceptAddEventListener(e,n);this.interceptRemoveEventListener(e,n)}else{n.interceptors.push(t)}};e.interceptAddEventListener=function(e,t){var n=this;var i=e.prototype.addEventListener;e.prototype.addEventListener=function(e,r,o){var s=n.normalizeListenerArguments(e,r,o);var a=n.getRegisteredEventListener(this,s);if(!a){s.polyfilled={type:s.type,listener:s.listener,options:{capture:s.options.capture,once:s.options.once,passive:s.options.passive}};for(var l=0;l<t.interceptors.length;l++){var p=t.interceptors[l];if(typeof p.add==="function"){p.add(s)}}n.registerEventListener(this,s);i.call(this,s.polyfilled.type,s.polyfilled.listener,s.polyfilled.options)}};return function(){e.prototype.addEventListener=i}};e.interceptRemoveEventListener=function(e,t){var n=this;var i=e.prototype.removeEventListener;e.prototype.removeEventListener=function(e,t,r){var o=n.normalizeListenerArguments(e,t,r);var s=n.getRegisteredEventListener(this,o);if(s){n.unregisterEventListener(this,o);i.call(this,s.polyfilled.type,s.polyfilled.listener,s.polyfilled.options)}else{i.call(this,e,t,r)}};return function(){e.prototype.removeEventListener=i}};e.interceptAll=function(e){this.intercept(EventTarget,e);if(!(window instanceof EventTarget)){this.intercept(Window,e)}};e.releaseAll=function(){for(var e=0,t=this.interceptors.length;e<t;e++){this.interceptors()}};return e}()},{}],2:[function(e,t,n){(function(e){e.isSupportedOnEvent=function(e,t){return"on"+t in e};e.isSupportedTransitionEvent=function(t,n){return e.isSupportedOnEvent(t,n)||t.style["transition"]!==void 0};e.isSupportedFullScreenEvent=function(t,n){if(e.isSupportedOnEvent(t,n)){return true}else{if(/^ms/.test(n.toLowerCase())){return"msRequestFullscreen"in document.body}else if(/^moz/.test(n)){return"mozRequestFullscreen"in document.body}else if(/^webkit/.test(n)){return"webkitRequestFullscreen"in document.body}else{return false}}};e.generateEventTypes=function(){var e=this;this.eventTypes={};this.vendorPrefixes=["","webkit","moz","ms","o"];this.eventTypes["wheel"]=["wheel","mousewheel","DOMMouseScroll"].map(function(t){return{type:t,isSupported:e.isSupportedOnEvent}});this.eventTypes["fullscreenchange"]=["fullscreenchange","mozfullscreenchange","webkitfullscreenchange","MSFullscreenChange","msfullscreenchange"].map(function(t){return{type:t,isSupported:e.isSupportedFullScreenEvent}});this.eventTypes["fullscreenerror"]=["fullscreenerror","mozfullscreenerror","webkitfullscreenerror","MSFullscreenError","msfullscreenerror"].map(function(t){return{type:t,isSupported:e.isSupportedFullScreenEvent}});["pointerlockchange","pointerlockerror","animationstart","animationiteration","animationend","pointercancel","pointerdown","pointerhover","pointermove","pointerout","pointerover","pointerup"].forEach(function(t){e.eventTypes[t]=e.vendorPrefixes.map(function(n){return{type:n+t,isSupported:e.isSupportedOnEvent}})});["transitionstart","transitionrun","transitionend"].forEach(function(t){e.eventTypes[t]=e.vendorPrefixes.map(function(n){return{type:n+t,isSupported:e.isSupportedTransitionEvent}})})};e.getSupportedEventType=function(e,t){var n=this.eventTypes[t];if(n===void 0){return t}else{var i;for(var r=0;r<n.length;r++){i=n[r];if(i.isSupported(e,i.type)){return i.type}}throw new Error("Event listener type "+String(t)+" on "+String(e)+" is not supported by current environment")}};e.polyfillListenerEventTypes=function(){this.generateEventTypes();var e=this;this.interceptAll({add:function(t){t.polyfilled.type=e.getSupportedEventType(this,t.polyfilled.type)}})};e.polyfillListenerEventTypes()})(e("./EventListenerInterceptor.js"))},{"./EventListenerInterceptor.js":1}],3:[function(e,t,n){(function(e){e.detectSupportedOptions=function(){var e=this;this.supportedOptions={once:false,passive:false,capture:false,all:false,some:false};document.createDocumentFragment().addEventListener("test",function(){},{get once(){e.supportedOptions.once=true;return false},get passive(){e.supportedOptions.passive=true;return false},get capture(){e.supportedOptions.capture=true;return false}});this.supportedOptions.all=this.supportedOptions.once&&this.supportedOptions.passive&&this.supportedOptions.capture;this.supportedOptions.some=this.supportedOptions.once||this.supportedOptions.passive||this.supportedOptions.capture};e.polyfillListenerOptions=function(){this.detectSupportedOptions();if(!this.supportedOptions.all){var e=this;this.interceptAll({add:function(t){var n=t.options.once&&!e.supportedOptions.once;var i=t.options.passive&&!e.supportedOptions.passive;if(n||i){var r=t.polyfilled.listener;t.polyfilled.listener=function(e){if(n){this.removeEventListener(t.type,t.listener,t.options)}if(i){e.preventDefault=function(){throw new Error("Unable to preventDefault inside passive event listener invocation.")}}return r.call(this,e)}}if(!e.supportedOptions.some){t.polyfilled.options=t.options.capture}}})}};e.polyfillListenerOptions()})(e("./EventListenerInterceptor.js"))},{"./EventListenerInterceptor.js":1}],4:[function(e,t,n){(function(){try{var e=new window.CustomEvent("event",{bubbles:true,cancelable:true})}catch(e){var t=window.CustomEvent||window.Event;var n=function(e,t){t=t||{};var n=document.createEvent("CustomEvent");n.initCustomEvent(e,t.bubbles===void 0?false:t.bubbles,t.cancelable===void 0?false:t.cancelable,t.detail===void 0?{}:t.detail);return n};n.prototype=t.prototype;window.CustomEvent=n}})()},{}],5:[function(e,t,n){(function(){try{var e=new window.Event("event",{bubbles:true,cancelable:true})}catch(e){var t=window.Event;var n=function(e,t){t=t||{};var n=document.createEvent("Event");n.initEvent(e,t.bubbles===void 0?false:t.bubbles,t.cancelable===void 0?false:t.cancelable,t.detail===void 0?{}:t.detail);return n};n.prototype=t.prototype;window.Event=n}})()},{}],6:[function(e,t,n){(function(){try{var e=new window.FocusEvent("event",{bubbles:true,cancelable:true})}catch(e){var t=window.FocusEvent||window.Event;var n=function(e,t){t=t||{};var n=document.createEvent("FocusEvent");n.initFocusEvent(e,t.bubbles===void 0?false:t.bubbles,t.cancelable===void 0?false:t.cancelable,t.view===void 0?window:t.view,t.detail===void 0?{}:t.detail,t.relatedTarget===void 0?null:t.relatedTarget);return n};n.prototype=t.prototype;window.FocusEvent=n}})()},{}],7:[function(e,t,n){(function(){try{var e=new window.KeyboardEvent("event",{bubbles:true,cancelable:true})}catch(e){var t=window.KeyboardEvent||window.Event;var n=function(e,t){t=t||{};var n=document.createEvent("KeyboardEvent");n.initKeyboardEvent(e,t.bubbles===void 0?false:t.bubbles,t.cancelable===void 0?false:t.cancelable,t.view===void 0?window:t.view,t.key===void 0?"":t.key,t.location===void 0?0:t.location,(t.ctrlKey===true?"Control ":"")+(t.altKey===true?"Alt ":"")+(t.shiftKey===true?"Shift ":"")+(t.metaKey===true?"Meta ":""),t.repeat===void 0?false:t.repeat,t.locale===void 0?navigator.language:t.locale);n.keyCode=t.keyCode===void 0?0:t.keyCode;n.code=t.code===void 0?"":t.code;n.charCode=t.charCode===void 0?0:t.charCode;n.char=t.charCode===void 0?"":t.charCode;n.which=t.which===void 0?0:t.which;return n};n.prototype=t.prototype;window.KeyboardEvent=n}})()},{}],8:[function(e,t,n){(function(){try{var e=new window.MouseEvent("event",{bubbles:true,cancelable:true})}catch(e){var t=window.MouseEvent||window.Event;var n=function(e,t){t=t||{};var n=document.createEvent("MouseEvent");n.initMouseEvent(e,t.bubbles===void 0?false:t.bubbles,t.cancelable===void 0?false:t.cancelable,t.view===void 0?window:t.view,t.detail===void 0?0:t.detail,t.screenX===void 0?0:t.screenX,t.screenY===void 0?0:t.screenY,t.clientX===void 0?0:t.clientX,t.clientY===void 0?0:t.clientY,t.ctrlKey===void 0?false:t.ctrlKey,t.altKey===void 0?false:t.altKey,t.shiftKey===void 0?false:t.shiftKey,t.metaKey===void 0?false:t.metaKey,t.button===void 0?0:t.button,t.relatedTarget===void 0?null:t.relatedTarget);n.buttons=t.buttons===void 0?0:t.buttons;n.region=t.region===void 0?null:t.region;return n};n.prototype=t.prototype;window.MouseEvent=n}})()},{}],9:[function(e,t,n){(function(){try{var e=new window.PointerEvent("event",{bubbles:true,cancelable:true})}catch(e){var t=window.PointerEvent||window.Event;var n=function(e,t){t=t||{};var n=document.createEvent("PointerEvent");n.initPointerEvent(e,t.bubbles===void 0?false:t.bubbles,t.cancelable===void 0?false:t.cancelable,t.view===void 0?window:t.view,t.detail===void 0?0:t.detail,t.screenX===void 0?0:t.screenX,t.screenY===void 0?0:t.screenY,t.clientX===void 0?0:t.clientX,t.clientY===void 0?0:t.clientY,t.ctrlKey===void 0?false:t.ctrlKey,t.altKey===void 0?false:t.altKey,t.shiftKey===void 0?false:t.shiftKey,t.metaKey===void 0?false:t.metaKey,t.button===void 0?0:t.button,t.relatedTarget===void 0?null:t.relatedTarget,t.offsetX===void 0?0:t.offsetX,t.offsetY===void 0?0:t.offsetY,t.width===void 0?1:t.width,t.height===void 0?1:t.height,t.pressure===void 0?0:t.pressure,t.twist===void 0?0:t.twist,t.tiltX===void 0?0:t.tiltX,t.tiltY===void 0?0:t.tiltY,t.pointerId===void 0?0:t.pointerId,t.pointerType===void 0?"":t.pointerType,t.hwTimestamp===void 0?0:t.hwTimestamp,t.isPrimary===void 0?false:t.isPrimary);n.tangentialPressure=t.tangentialPressure===void 0?0:t.tangentialPressure;return n};n.prototype=t.prototype;Object.defineProperty(n.prototype,"twist",Object.getOwnPropertyDescriptor(n.prototype,"rotation"));window.PointerEvent=n}})()},{}],10:[function(e,t,n){e("./Event.js");e("./CustomEvent.js");e("./MouseEvent.js");e("./KeyboardEvent.js");e("./FocusEvent.js");e("./PointerEvent.js")},{"./CustomEvent.js":4,"./Event.js":5,"./FocusEvent.js":6,"./KeyboardEvent.js":7,"./MouseEvent.js":8,"./PointerEvent.js":9}],11:[function(e,t,n){e("./constructors/index.js");e("./ListenerOptions.js");e("./ListenerEventTypes.js")},{"./ListenerEventTypes.js":2,"./ListenerOptions.js":3,"./constructors/index.js":10}]},{},[11]); |
{ | ||
"name": "events-polyfill", | ||
"version": "2.0.1", | ||
"description": "Polyfill event : EventListener, EventTarget, Event, CustomEvent, MouseEvent, KeyboardEvent, FocusEvent", | ||
"version": "2.0.2", | ||
"description": "Polyfill event : EventListener, EventTarget, Event, CustomEvent, MouseEvent, KeyboardEvent, FocusEvent, PointerEvent and add support for options (like 'once')", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -23,2 +23,3 @@ ### Polyfill different events classes and methods to match last ES7 specifications | ||
[FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent) | ||
[PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent) | ||
@@ -25,0 +26,0 @@ #### src/ListenerOptions.js |
@@ -10,3 +10,3 @@ (function() { | ||
} catch(error) { | ||
var EventOriginal = window.CustomEvent || window.Event; | ||
var EventOriginal = window.Event; | ||
var Event = function(eventName, params) { | ||
@@ -13,0 +13,0 @@ params = params || {}; |
@@ -5,2 +5,3 @@ require('./Event.js'); | ||
require('./KeyboardEvent.js'); | ||
require('./FocusEvent.js'); | ||
require('./FocusEvent.js'); | ||
require('./PointerEvent.js'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93066
19
1870
64