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

event-target-shim

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

event-target-shim - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

274

dist/event-target-shim.js

@@ -9,8 +9,8 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.eventTargetShim = f()}})(function(){var define,module,exports;return (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){

var _LISTENERS$ATTRIBUTE$newNode = require("./commons");
var _commons = require("./commons");
function getAttributeListener(eventTarget, type) {
var node = eventTarget[_LISTENERS$ATTRIBUTE$newNode.LISTENERS][type];
var node = eventTarget[_commons.LISTENERS][type];
while (node != null) {
if (node.kind === _LISTENERS$ATTRIBUTE$newNode.ATTRIBUTE) {
if (node.kind === _commons.ATTRIBUTE) {
return node.listener;

@@ -29,8 +29,8 @@ }

var prev = null;
var node = eventTarget[_LISTENERS$ATTRIBUTE$newNode.LISTENERS][type];
var node = eventTarget[_commons.LISTENERS][type];
while (node != null) {
if (node.kind === _LISTENERS$ATTRIBUTE$newNode.ATTRIBUTE) {
if (node.kind === _commons.ATTRIBUTE) {
// Remove old value.
if (prev == null) {
eventTarget[_LISTENERS$ATTRIBUTE$newNode.LISTENERS][type] = node.next;
eventTarget[_commons.LISTENERS][type] = node.next;
} else {

@@ -49,5 +49,5 @@ prev.next = node.next;

if (prev == null) {
eventTarget[_LISTENERS$ATTRIBUTE$newNode.LISTENERS][type] = _LISTENERS$ATTRIBUTE$newNode.newNode(listener, _LISTENERS$ATTRIBUTE$newNode.ATTRIBUTE);
eventTarget[_commons.LISTENERS][type] = (0, _commons.newNode)(listener, _commons.ATTRIBUTE);
} else {
prev.next = _LISTENERS$ATTRIBUTE$newNode.newNode(listener, _LISTENERS$ATTRIBUTE$newNode.ATTRIBUTE);
prev.next = (0, _commons.newNode)(listener, _commons.ATTRIBUTE);
}

@@ -87,3 +87,3 @@ }

}
},{"./commons":4}],2:[function(require,module,exports){
},{"./commons":3}],2:[function(require,module,exports){
"use strict";

@@ -94,9 +94,124 @@

});
exports.createEventWrapper = createEventWrapper;
var _commons = require("./commons");
var STOP_IMMEDIATE_PROPAGATION_FLAG = (0, _commons.symbol)("stop_immediate_propagation_flag");
exports.STOP_IMMEDIATE_PROPAGATION_FLAG = STOP_IMMEDIATE_PROPAGATION_FLAG;
var CANCELED_FLAG = (0, _commons.symbol)("canceled_flag");
var ORIGINAL_EVENT = (0, _commons.symbol)("original_event");
var wrapperPrototypeDefinition = {
stopPropagation: {
value: function stopPropagation() {
var e = this[ORIGINAL_EVENT];
if (typeof e.stopPropagation === "function") {
e.stopPropagation();
}
},
writable: true,
configurable: true
},
stopImmediatePropagation: {
value: function stopImmediatePropagation() {
this[STOP_IMMEDIATE_PROPAGATION_FLAG] = true;
var e = this[ORIGINAL_EVENT];
if (typeof e.stopImmediatePropagation === "function") {
e.stopImmediatePropagation();
}
},
writable: true,
configurable: true
},
preventDefault: {
value: function preventDefault() {
if (this.cancelable === true) {
this[CANCELED_FLAG] = true;
}
var e = this[ORIGINAL_EVENT];
if (typeof e.preventDefault === "function") {
e.preventDefault();
}
},
writable: true,
configurable: true
},
defaultPrevented: {
get: function get() {
return this[CANCELED_FLAG];
},
enumerable: true,
configurable: true
}
};
function createEventWrapper(event, eventTarget) {
var timeStamp = typeof event.timeStamp === "number" ? event.timeStamp : Date.now();
var props = {
type: { value: event.type, enumerable: true },
target: { value: eventTarget, enumerable: true },
currentTarget: { value: eventTarget, enumerable: true },
eventPhase: { value: 2, enumerable: true },
bubbles: { value: Boolean(event.bubbles), enumerable: true },
cancelable: { value: Boolean(event.cancelable), enumerable: true },
timeStamp: { value: timeStamp, enumerable: true },
isTrusted: { value: false, enumerable: true }
};
if (typeof event.detail !== "undefined") {
props.detail = { value: event.detail, enumerable: true };
}
var retv = Object.create(Object.create(event, wrapperPrototypeDefinition), props);
Object.defineProperty(retv, STOP_IMMEDIATE_PROPAGATION_FLAG, { value: false, writable: true });
Object.defineProperty(retv, CANCELED_FLAG, { value: false, writable: true });
Object.defineProperty(retv, ORIGINAL_EVENT, { value: event });
return retv;
}
},{"./commons":3}],3:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.newNode = newNode;
var symbol = typeof Symbol !== "undefined" ? Symbol : function Symbol(name) {
return "[[" + name + "_" + Math.random().toFixed(8).slice(2) + "]]";
};
exports.symbol = symbol;
var LISTENERS = symbol("listeners");
exports.LISTENERS = LISTENERS;
var CAPTURE = 1;
exports.CAPTURE = CAPTURE;
var BUBBLE = 2;
exports.BUBBLE = BUBBLE;
var ATTRIBUTE = 3;
exports.ATTRIBUTE = ATTRIBUTE;
// Create a LinkedList structure for EventListener.
function newNode(listener, kind) {
return { listener: listener, kind: kind, next: null };
}
},{}],4:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = EventTarget;
var _LISTENERS$CAPTURE$BUBBLE$newNode = require("./commons");
var _commons = require("./commons");
var _defineCustomEventTarget = require("./CustomEventTarget");
var _CustomEventTarget = require("./CustomEventTarget");
var _createEventWrapper$STOP_IMMEDIATE_PROPAGATION_FLAG = require("./EventWrapper");
var _EventWrapper = require("./EventWrapper");

@@ -120,3 +235,3 @@ var HAS_EVENTTARGET_INTERFACE = typeof window !== "undefined" && typeof window.EventTarget !== "undefined";

// }
Object.defineProperty(this, _LISTENERS$CAPTURE$BUBBLE$newNode.LISTENERS, { value: Object.create(null) });
Object.defineProperty(this, _commons.LISTENERS, { value: Object.create(null) });
} else if (types.length > 0) {

@@ -128,3 +243,3 @@ // To use to extend with attribute listener properties.

// }
return _defineCustomEventTarget.defineCustomEventTarget(EventTarget, types);
return (0, _CustomEventTarget.defineCustomEventTarget)(EventTarget, types);
} else {

@@ -153,6 +268,6 @@ throw new TypeError("Cannot call a class as a function");

var kind = capture ? _LISTENERS$CAPTURE$BUBBLE$newNode.CAPTURE : _LISTENERS$CAPTURE$BUBBLE$newNode.BUBBLE;
var node = this[_LISTENERS$CAPTURE$BUBBLE$newNode.LISTENERS][type];
var kind = capture ? _commons.CAPTURE : _commons.BUBBLE;
var node = this[_commons.LISTENERS][type];
if (node == null) {
this[_LISTENERS$CAPTURE$BUBBLE$newNode.LISTENERS][type] = _LISTENERS$CAPTURE$BUBBLE$newNode.newNode(listener, kind);
this[_commons.LISTENERS][type] = (0, _commons.newNode)(listener, kind);
return true;

@@ -171,3 +286,3 @@ }

prev.next = _LISTENERS$CAPTURE$BUBBLE$newNode.newNode(listener, kind);
prev.next = (0, _commons.newNode)(listener, kind);
return true;

@@ -187,9 +302,9 @@ },

var kind = capture ? _LISTENERS$CAPTURE$BUBBLE$newNode.CAPTURE : _LISTENERS$CAPTURE$BUBBLE$newNode.BUBBLE;
var kind = capture ? _commons.CAPTURE : _commons.BUBBLE;
var prev = null;
var node = this[_LISTENERS$CAPTURE$BUBBLE$newNode.LISTENERS][type];
var node = this[_commons.LISTENERS][type];
while (node != null) {
if (node.listener === listener && node.kind === kind) {
if (prev == null) {
this[_LISTENERS$CAPTURE$BUBBLE$newNode.LISTENERS][type] = node.next;
this[_commons.LISTENERS][type] = node.next;
} else {

@@ -214,3 +329,3 @@ prev.next = node.next;

// If listeners aren't registered, terminate.
var node = this[_LISTENERS$CAPTURE$BUBBLE$newNode.LISTENERS][event.type];
var node = this[_commons.LISTENERS][event.type];
if (node == null) {

@@ -221,3 +336,3 @@ return true;

// Since we cannot rewrite several properties, so wrap object.
event = _createEventWrapper$STOP_IMMEDIATE_PROPAGATION_FLAG.createEventWrapper(event, this);
event = (0, _EventWrapper.createEventWrapper)(event, this);

@@ -228,3 +343,3 @@ // This doesn't process capturing phase and bubbling phase.

node.listener.call(this, event);
if (event[_createEventWrapper$STOP_IMMEDIATE_PROPAGATION_FLAG.STOP_IMMEDIATE_PROPAGATION_FLAG]) {
if (event[_EventWrapper.STOP_IMMEDIATE_PROPAGATION_FLAG]) {
break;

@@ -242,112 +357,3 @@ }

module.exports = exports["default"];
},{"./CustomEventTarget":1,"./EventWrapper":3,"./commons":4}],3:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createEventWrapper = createEventWrapper;
var _symbol = require("./commons");
var STOP_IMMEDIATE_PROPAGATION_FLAG = _symbol.symbol("stop_immediate_propagation_flag");
exports.STOP_IMMEDIATE_PROPAGATION_FLAG = STOP_IMMEDIATE_PROPAGATION_FLAG;
var CANCELED_FLAG = _symbol.symbol("canceled_flag");
var ORIGINAL_EVENT = _symbol.symbol("original_event");
var wrapperPrototypeDefinition = {
stopPropagation: {
value: function stopPropagation() {
var e = this[ORIGINAL_EVENT];
if (typeof e.stopPropagation === "function") {
e.stopPropagation();
}
},
writable: true,
configurable: true
},
stopImmediatePropagation: {
value: function stopImmediatePropagation() {
this[STOP_IMMEDIATE_PROPAGATION_FLAG] = true;
var e = this[ORIGINAL_EVENT];
if (typeof e.stopImmediatePropagation === "function") {
e.stopImmediatePropagation();
}
},
writable: true,
configurable: true
},
preventDefault: {
value: function preventDefault() {
if (this.cancelable === true) {
this[CANCELED_FLAG] = true;
}
var e = this[ORIGINAL_EVENT];
if (typeof e.preventDefault === "function") {
e.preventDefault();
}
},
writable: true,
configurable: true
},
defaultPrevented: {
get: function get() {
return this[CANCELED_FLAG];
},
enumerable: true,
configurable: true
}
};
function createEventWrapper(event, eventTarget) {
var timeStamp = typeof event.timeStamp === "number" ? event.timeStamp : Date.now();
var retv = Object.create(Object.create(event, wrapperPrototypeDefinition), {
type: { value: event.type, enumerable: true },
target: { value: eventTarget, enumerable: true },
currentTarget: { value: eventTarget, enumerable: true },
eventPhase: { value: 2, enumerable: true },
bubbles: { value: Boolean(event.bubbles), enumerable: true },
cancelable: { value: Boolean(event.cancelable), enumerable: true },
timeStamp: { value: timeStamp, enumerable: true },
isTrusted: { value: false, enumerable: true }
});
Object.defineProperty(retv, STOP_IMMEDIATE_PROPAGATION_FLAG, { value: false, writable: true });
Object.defineProperty(retv, CANCELED_FLAG, { value: false, writable: true });
Object.defineProperty(retv, ORIGINAL_EVENT, { value: event });
return retv;
}
},{"./commons":4}],4:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
// Create a LinkedList structure for EventListener.
exports.newNode = newNode;
var symbol = typeof Symbol !== "undefined" ? Symbol : function Symbol(name) {
return "[[" + name + "_" + Math.random().toFixed(8).slice(2) + "]]";
};
exports.symbol = symbol;
var LISTENERS = symbol("listeners");
exports.LISTENERS = LISTENERS;
var CAPTURE = 1;
exports.CAPTURE = CAPTURE;
var BUBBLE = 2;
exports.BUBBLE = BUBBLE;
var ATTRIBUTE = 3;exports.ATTRIBUTE = ATTRIBUTE;
function newNode(listener, kind) {
return { listener: listener, kind: kind, next: null };
}
},{}]},{},[2])(2)
},{"./CustomEventTarget":1,"./EventWrapper":2,"./commons":3}]},{},[4])(4)
});

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

!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.eventTargetShim=e()}}(function(){return function e(t,n,r){function o(a,i){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!i&&l)return l(a,!0);if(u)return u(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[a]={exports:{}};t[a][0].call(c.exports,function(e){var n=t[a][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[a].exports}for(var u="function"==typeof require&&require,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(e,t,n){"use strict";function r(e,t){for(var n=e[a.LISTENERS][t];null!=n;){if(n.kind===a.ATTRIBUTE)return n.listener;n=n.next}return null}function o(e,t,n){if(null!=n&&"function"!=typeof n)throw new TypeError("listener should be a function.");for(var r=null,o=e[a.LISTENERS][t];null!=o;)o.kind===a.ATTRIBUTE?null==r?e[a.LISTENERS][t]=o.next:r.next=o.next:r=o,o=o.next;null!=n&&(null==r?e[a.LISTENERS][t]=a.newNode(n,a.ATTRIBUTE):r.next=a.newNode(n,a.ATTRIBUTE))}function u(e,t){function n(){e.call(this)}var u={constructor:{value:n,configurable:!0,writable:!0}};return t.forEach(function(e){u["on"+e]={get:function(){return r(this,e)},set:function(t){o(this,e,t)},configurable:!0,enumerable:!0}}),n.prototype=Object.create(e.prototype,u),n}Object.defineProperty(n,"__esModule",{value:!0}),n.defineCustomEventTarget=u;var a=e("./commons")},{"./commons":4}],2:[function(e,t,n){"use strict";function r(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];if(!(this instanceof r)){if(t.length>0)return u.defineCustomEventTarget(r,t);throw new TypeError("Cannot call a class as a function")}Object.defineProperty(this,o.LISTENERS,{value:Object.create(null)})}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=r;var o=e("./commons"),u=e("./CustomEventTarget"),a=e("./EventWrapper"),i="undefined"!=typeof window&&"undefined"!=typeof window.EventTarget;r.prototype=Object.create((i?window.EventTarget:Object).prototype,{constructor:{value:r,writable:!0,configurable:!0},addEventListener:{value:function(e,t){var n=void 0===arguments[2]?!1:arguments[2];if(null==t)return!1;if("function"!=typeof t)throw new TypeError("listener should be a function.");var r=n?o.CAPTURE:o.BUBBLE,u=this[o.LISTENERS][e];if(null==u)return this[o.LISTENERS][e]=o.newNode(t,r),!0;for(var a=null;null!=u;){if(u.listener===t&&u.kind===r)return!1;a=u,u=u.next}return a.next=o.newNode(t,r),!0},configurable:!0,writable:!0},removeEventListener:{value:function(e,t){var n=void 0===arguments[2]?!1:arguments[2];if(null==t)return!1;for(var r=n?o.CAPTURE:o.BUBBLE,u=null,a=this[o.LISTENERS][e];null!=a;){if(a.listener===t&&a.kind===r)return null==u?this[o.LISTENERS][e]=a.next:u.next=a.next,!0;u=a,a=a.next}return!1},configurable:!0,writable:!0},dispatchEvent:{value:function(e){var t=this[o.LISTENERS][e.type];if(null==t)return!0;for(e=a.createEventWrapper(e,this);null!=t&&(t.listener.call(this,e),!e[a.STOP_IMMEDIATE_PROPAGATION_FLAG]);)t=t.next;return!e.defaultPrevented},configurable:!0,writable:!0}}),t.exports=n["default"]},{"./CustomEventTarget":1,"./EventWrapper":3,"./commons":4}],3:[function(e,t,n){"use strict";function r(e,t){var n="number"==typeof e.timeStamp?e.timeStamp:Date.now(),r=Object.create(Object.create(e,l),{type:{value:e.type,enumerable:!0},target:{value:t,enumerable:!0},currentTarget:{value:t,enumerable:!0},eventPhase:{value:2,enumerable:!0},bubbles:{value:Boolean(e.bubbles),enumerable:!0},cancelable:{value:Boolean(e.cancelable),enumerable:!0},timeStamp:{value:n,enumerable:!0},isTrusted:{value:!1,enumerable:!0}});return Object.defineProperty(r,u,{value:!1,writable:!0}),Object.defineProperty(r,a,{value:!1,writable:!0}),Object.defineProperty(r,i,{value:e}),r}Object.defineProperty(n,"__esModule",{value:!0}),n.createEventWrapper=r;var o=e("./commons"),u=o.symbol("stop_immediate_propagation_flag");n.STOP_IMMEDIATE_PROPAGATION_FLAG=u;var a=o.symbol("canceled_flag"),i=o.symbol("original_event"),l={stopPropagation:{value:function(){var e=this[i];"function"==typeof e.stopPropagation&&e.stopPropagation()},writable:!0,configurable:!0},stopImmediatePropagation:{value:function(){this[u]=!0;var e=this[i];"function"==typeof e.stopImmediatePropagation&&e.stopImmediatePropagation()},writable:!0,configurable:!0},preventDefault:{value:function(){this.cancelable===!0&&(this[a]=!0);var e=this[i];"function"==typeof e.preventDefault&&e.preventDefault()},writable:!0,configurable:!0},defaultPrevented:{get:function(){return this[a]},enumerable:!0,configurable:!0}}},{"./commons":4}],4:[function(e,t,n){"use strict";function r(e,t){return{listener:e,kind:t,next:null}}Object.defineProperty(n,"__esModule",{value:!0}),n.newNode=r;var o="undefined"!=typeof Symbol?Symbol:function(e){return"[["+e+"_"+Math.random().toFixed(8).slice(2)+"]]"};n.symbol=o;var u=o("listeners");n.LISTENERS=u;var a=1;n.CAPTURE=a;var i=2;n.BUBBLE=i;var l=3;n.ATTRIBUTE=l},{}]},{},[2])(2)});
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.eventTargetShim=e()}}(function(){return function e(t,n,r){function o(u,i){if(!n[u]){if(!t[u]){var l="function"==typeof require&&require;if(!i&&l)return l(u,!0);if(a)return a(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[u]={exports:{}};t[u][0].call(c.exports,function(e){var n=t[u][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[u].exports}for(var a="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(e,t,n){"use strict";function r(e,t){for(var n=e[u.LISTENERS][t];null!=n;){if(n.kind===u.ATTRIBUTE)return n.listener;n=n.next}return null}function o(e,t,n){if(null!=n&&"function"!=typeof n)throw new TypeError("listener should be a function.");for(var r=null,o=e[u.LISTENERS][t];null!=o;)o.kind===u.ATTRIBUTE?null==r?e[u.LISTENERS][t]=o.next:r.next=o.next:r=o,o=o.next;null!=n&&(null==r?e[u.LISTENERS][t]=u.newNode(n,u.ATTRIBUTE):r.next=u.newNode(n,u.ATTRIBUTE))}function a(e,t){function n(){e.call(this)}var a={constructor:{value:n,configurable:!0,writable:!0}};return t.forEach(function(e){a["on"+e]={get:function(){return r(this,e)},set:function(t){o(this,e,t)},configurable:!0,enumerable:!0}}),n.prototype=Object.create(e.prototype,a),n}Object.defineProperty(n,"__esModule",{value:!0}),n.defineCustomEventTarget=a;var u=e("./commons")},{"./commons":3}],2:[function(e,t,n){"use strict";function r(e,t){var n="number"==typeof e.timeStamp?e.timeStamp:Date.now(),r={type:{value:e.type,enumerable:!0},target:{value:t,enumerable:!0},currentTarget:{value:t,enumerable:!0},eventPhase:{value:2,enumerable:!0},bubbles:{value:Boolean(e.bubbles),enumerable:!0},cancelable:{value:Boolean(e.cancelable),enumerable:!0},timeStamp:{value:n,enumerable:!0},isTrusted:{value:!1,enumerable:!0}};"undefined"!=typeof e.detail&&(r.detail={value:e.detail,enumerable:!0});var o=Object.create(Object.create(e,l),r);return Object.defineProperty(o,a,{value:!1,writable:!0}),Object.defineProperty(o,u,{value:!1,writable:!0}),Object.defineProperty(o,i,{value:e}),o}Object.defineProperty(n,"__esModule",{value:!0}),n.createEventWrapper=r;var o=e("./commons"),a=o.symbol("stop_immediate_propagation_flag");n.STOP_IMMEDIATE_PROPAGATION_FLAG=a;var u=o.symbol("canceled_flag"),i=o.symbol("original_event"),l={stopPropagation:{value:function(){var e=this[i];"function"==typeof e.stopPropagation&&e.stopPropagation()},writable:!0,configurable:!0},stopImmediatePropagation:{value:function(){this[a]=!0;var e=this[i];"function"==typeof e.stopImmediatePropagation&&e.stopImmediatePropagation()},writable:!0,configurable:!0},preventDefault:{value:function(){this.cancelable===!0&&(this[u]=!0);var e=this[i];"function"==typeof e.preventDefault&&e.preventDefault()},writable:!0,configurable:!0},defaultPrevented:{get:function(){return this[u]},enumerable:!0,configurable:!0}}},{"./commons":3}],3:[function(e,t,n){"use strict";function r(e,t){return{listener:e,kind:t,next:null}}Object.defineProperty(n,"__esModule",{value:!0}),n.newNode=r;var o="undefined"!=typeof Symbol?Symbol:function(e){return"[["+e+"_"+Math.random().toFixed(8).slice(2)+"]]"};n.symbol=o;var a=o("listeners");n.LISTENERS=a;var u=1;n.CAPTURE=u;var i=2;n.BUBBLE=i;var l=3;n.ATTRIBUTE=l},{}],4:[function(e,t,n){"use strict";function r(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];if(!(this instanceof r)){if(t.length>0)return a.defineCustomEventTarget(r,t);throw new TypeError("Cannot call a class as a function")}Object.defineProperty(this,o.LISTENERS,{value:Object.create(null)})}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=r;var o=e("./commons"),a=e("./CustomEventTarget"),u=e("./EventWrapper"),i="undefined"!=typeof window&&"undefined"!=typeof window.EventTarget;r.prototype=Object.create((i?window.EventTarget:Object).prototype,{constructor:{value:r,writable:!0,configurable:!0},addEventListener:{value:function(e,t){var n=void 0===arguments[2]?!1:arguments[2];if(null==t)return!1;if("function"!=typeof t)throw new TypeError("listener should be a function.");var r=n?o.CAPTURE:o.BUBBLE,a=this[o.LISTENERS][e];if(null==a)return this[o.LISTENERS][e]=o.newNode(t,r),!0;for(var u=null;null!=a;){if(a.listener===t&&a.kind===r)return!1;u=a,a=a.next}return u.next=o.newNode(t,r),!0},configurable:!0,writable:!0},removeEventListener:{value:function(e,t){var n=void 0===arguments[2]?!1:arguments[2];if(null==t)return!1;for(var r=n?o.CAPTURE:o.BUBBLE,a=null,u=this[o.LISTENERS][e];null!=u;){if(u.listener===t&&u.kind===r)return null==a?this[o.LISTENERS][e]=u.next:a.next=u.next,!0;a=u,u=u.next}return!1},configurable:!0,writable:!0},dispatchEvent:{value:function(e){var t=this[o.LISTENERS][e.type];if(null==t)return!0;for(e=u.createEventWrapper(e,this);null!=t&&(t.listener.call(this,e),!e[u.STOP_IMMEDIATE_PROPAGATION_FLAG]);)t=t.next;return!e.defaultPrevented},configurable:!0,writable:!0}}),t.exports=n["default"]},{"./CustomEventTarget":1,"./EventWrapper":2,"./commons":3}]},{},[4])(4)});

@@ -6,4 +6,2 @@ "use strict";

});
// Create a LinkedList structure for EventListener.
exports.newNode = newNode;

@@ -21,6 +19,9 @@ var symbol = typeof Symbol !== "undefined" ? Symbol : function Symbol(name) {

exports.BUBBLE = BUBBLE;
var ATTRIBUTE = 3;exports.ATTRIBUTE = ATTRIBUTE;
var ATTRIBUTE = 3;
exports.ATTRIBUTE = ATTRIBUTE;
// Create a LinkedList structure for EventListener.
function newNode(listener, kind) {
return { listener: listener, kind: kind, next: null };
}

@@ -8,8 +8,8 @@ "use strict";

var _LISTENERS$ATTRIBUTE$newNode = require("./commons");
var _commons = require("./commons");
function getAttributeListener(eventTarget, type) {
var node = eventTarget[_LISTENERS$ATTRIBUTE$newNode.LISTENERS][type];
var node = eventTarget[_commons.LISTENERS][type];
while (node != null) {
if (node.kind === _LISTENERS$ATTRIBUTE$newNode.ATTRIBUTE) {
if (node.kind === _commons.ATTRIBUTE) {
return node.listener;

@@ -28,8 +28,8 @@ }

var prev = null;
var node = eventTarget[_LISTENERS$ATTRIBUTE$newNode.LISTENERS][type];
var node = eventTarget[_commons.LISTENERS][type];
while (node != null) {
if (node.kind === _LISTENERS$ATTRIBUTE$newNode.ATTRIBUTE) {
if (node.kind === _commons.ATTRIBUTE) {
// Remove old value.
if (prev == null) {
eventTarget[_LISTENERS$ATTRIBUTE$newNode.LISTENERS][type] = node.next;
eventTarget[_commons.LISTENERS][type] = node.next;
} else {

@@ -48,5 +48,5 @@ prev.next = node.next;

if (prev == null) {
eventTarget[_LISTENERS$ATTRIBUTE$newNode.LISTENERS][type] = _LISTENERS$ATTRIBUTE$newNode.newNode(listener, _LISTENERS$ATTRIBUTE$newNode.ATTRIBUTE);
eventTarget[_commons.LISTENERS][type] = (0, _commons.newNode)(listener, _commons.ATTRIBUTE);
} else {
prev.next = _LISTENERS$ATTRIBUTE$newNode.newNode(listener, _LISTENERS$ATTRIBUTE$newNode.ATTRIBUTE);
prev.next = (0, _commons.newNode)(listener, _commons.ATTRIBUTE);
}

@@ -53,0 +53,0 @@ }

@@ -8,7 +8,7 @@ "use strict";

var _LISTENERS$CAPTURE$BUBBLE$newNode = require("./commons");
var _commons = require("./commons");
var _defineCustomEventTarget = require("./CustomEventTarget");
var _CustomEventTarget = require("./CustomEventTarget");
var _createEventWrapper$STOP_IMMEDIATE_PROPAGATION_FLAG = require("./EventWrapper");
var _EventWrapper = require("./EventWrapper");

@@ -32,3 +32,3 @@ var HAS_EVENTTARGET_INTERFACE = typeof window !== "undefined" && typeof window.EventTarget !== "undefined";

// }
Object.defineProperty(this, _LISTENERS$CAPTURE$BUBBLE$newNode.LISTENERS, { value: Object.create(null) });
Object.defineProperty(this, _commons.LISTENERS, { value: Object.create(null) });
} else if (types.length > 0) {

@@ -40,3 +40,3 @@ // To use to extend with attribute listener properties.

// }
return _defineCustomEventTarget.defineCustomEventTarget(EventTarget, types);
return (0, _CustomEventTarget.defineCustomEventTarget)(EventTarget, types);
} else {

@@ -65,6 +65,6 @@ throw new TypeError("Cannot call a class as a function");

var kind = capture ? _LISTENERS$CAPTURE$BUBBLE$newNode.CAPTURE : _LISTENERS$CAPTURE$BUBBLE$newNode.BUBBLE;
var node = this[_LISTENERS$CAPTURE$BUBBLE$newNode.LISTENERS][type];
var kind = capture ? _commons.CAPTURE : _commons.BUBBLE;
var node = this[_commons.LISTENERS][type];
if (node == null) {
this[_LISTENERS$CAPTURE$BUBBLE$newNode.LISTENERS][type] = _LISTENERS$CAPTURE$BUBBLE$newNode.newNode(listener, kind);
this[_commons.LISTENERS][type] = (0, _commons.newNode)(listener, kind);
return true;

@@ -83,3 +83,3 @@ }

prev.next = _LISTENERS$CAPTURE$BUBBLE$newNode.newNode(listener, kind);
prev.next = (0, _commons.newNode)(listener, kind);
return true;

@@ -99,9 +99,9 @@ },

var kind = capture ? _LISTENERS$CAPTURE$BUBBLE$newNode.CAPTURE : _LISTENERS$CAPTURE$BUBBLE$newNode.BUBBLE;
var kind = capture ? _commons.CAPTURE : _commons.BUBBLE;
var prev = null;
var node = this[_LISTENERS$CAPTURE$BUBBLE$newNode.LISTENERS][type];
var node = this[_commons.LISTENERS][type];
while (node != null) {
if (node.listener === listener && node.kind === kind) {
if (prev == null) {
this[_LISTENERS$CAPTURE$BUBBLE$newNode.LISTENERS][type] = node.next;
this[_commons.LISTENERS][type] = node.next;
} else {

@@ -126,3 +126,3 @@ prev.next = node.next;

// If listeners aren't registered, terminate.
var node = this[_LISTENERS$CAPTURE$BUBBLE$newNode.LISTENERS][event.type];
var node = this[_commons.LISTENERS][event.type];
if (node == null) {

@@ -133,3 +133,3 @@ return true;

// Since we cannot rewrite several properties, so wrap object.
event = _createEventWrapper$STOP_IMMEDIATE_PROPAGATION_FLAG.createEventWrapper(event, this);
event = (0, _EventWrapper.createEventWrapper)(event, this);

@@ -140,3 +140,3 @@ // This doesn't process capturing phase and bubbling phase.

node.listener.call(this, event);
if (event[_createEventWrapper$STOP_IMMEDIATE_PROPAGATION_FLAG.STOP_IMMEDIATE_PROPAGATION_FLAG]) {
if (event[_EventWrapper.STOP_IMMEDIATE_PROPAGATION_FLAG]) {
break;

@@ -143,0 +143,0 @@ }

@@ -8,9 +8,9 @@ "use strict";

var _symbol = require("./commons");
var _commons = require("./commons");
var STOP_IMMEDIATE_PROPAGATION_FLAG = _symbol.symbol("stop_immediate_propagation_flag");
var STOP_IMMEDIATE_PROPAGATION_FLAG = (0, _commons.symbol)("stop_immediate_propagation_flag");
exports.STOP_IMMEDIATE_PROPAGATION_FLAG = STOP_IMMEDIATE_PROPAGATION_FLAG;
var CANCELED_FLAG = _symbol.symbol("canceled_flag");
var ORIGINAL_EVENT = _symbol.symbol("original_event");
var CANCELED_FLAG = (0, _commons.symbol)("canceled_flag");
var ORIGINAL_EVENT = (0, _commons.symbol)("original_event");

@@ -69,3 +69,3 @@ var wrapperPrototypeDefinition = {

var retv = Object.create(Object.create(event, wrapperPrototypeDefinition), {
var props = {
type: { value: event.type, enumerable: true },

@@ -79,3 +79,8 @@ target: { value: eventTarget, enumerable: true },

isTrusted: { value: false, enumerable: true }
});
};
if (typeof event.detail !== "undefined") {
props.detail = { value: event.detail, enumerable: true };
}
var retv = Object.create(Object.create(event, wrapperPrototypeDefinition), props);
Object.defineProperty(retv, STOP_IMMEDIATE_PROPAGATION_FLAG, { value: false, writable: true });

@@ -82,0 +87,0 @@ Object.defineProperty(retv, CANCELED_FLAG, { value: false, writable: true });

{
"name": "event-target-shim",
"version": "1.0.4",
"version": "1.0.5",
"description": "A polyfill for W3C EventTarget Constructor.",

@@ -13,33 +13,29 @@ "main": "lib/EventTarget.js",

"lint": "eslint src",
"build": "npm-run-all clean lint build:lib build:dist build:dist-min",
"build": "npm-run-all clean lint build:*",
"build:lib": "babel src --out-dir lib",
"build:dist": "mkdirp dist && browserify lib/EventTarget.js --standalone event-target-shim > dist/event-target-shim.js",
"build:dist-min": "uglifyjs dist/event-target-shim.js --compress --mangle > dist/event-target-shim.min.js",
"test": "npm-run-all clean lint build:lib test:karma",
"test:karma": "karma start karma.conf.js --single-run",
"testing": "npm-run-all clean --parallel testing:build testing:karma",
"testing:build": "npm run build:lib -- --watch",
"testing:karma": "karma start karma.conf.js --auto-watch --reporters growl,progress"
"test": "npm run lint && karma start karma.conf.js --single-run",
"testing": "karma start karma.conf.js --auto-watch --reporters growl,progress"
},
"devDependencies": {
"babel": "^5.1.10",
"babel-core": "^5.1.10",
"babel-plugin-espower": "^0.1.0",
"babelify": "^6.0.2",
"browserify": "^9.0.8",
"eslint": "^0.19.0",
"karma": "^0.12.31",
"karma-browserify": "^4.1.2",
"karma-chrome-launcher": "^0.1.8",
"karma-firefox-launcher": "^0.1.4",
"babel": "^5.4.7",
"babel-plugin-espower": "^1.0.0",
"babelify": "^6.1.2",
"browserify": "^10.2.1",
"eslint": "^0.21.2",
"karma": "^0.12.33",
"karma-browserify": "^4.2.1",
"karma-chrome-launcher": "^0.1.12",
"karma-firefox-launcher": "^0.1.6",
"karma-growl-reporter": "^0.1.1",
"karma-ie-launcher": "^0.1.5",
"karma-mocha": "^0.1.10",
"mkdirp": "^0.5.0",
"mocha": "^2.2.4",
"npm-run-all": "^1.2.3",
"mkdirp": "^0.5.1",
"mocha": "^2.2.5",
"npm-run-all": "^1.2.5",
"power-assert": "^0.11.0",
"rimraf": "^2.3.2",
"rimraf": "^2.3.4",
"spy": "^0.1.3",
"uglify-js": "^2.4.20"
"uglify-js": "^2.4.23"
},

@@ -46,0 +42,0 @@ "repository": {

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