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.2 to 1.0.3

117

dist/event-target-shim.js
(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){
"use strict";
exports.defineCustomEventTarget = defineCustomEventTarget;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.defineCustomEventTarget = defineCustomEventTarget;
var _commons = require("./commons");
var _LISTENERS$ATTRIBUTE$newNode = require("./commons");
var LISTENERS = _commons.LISTENERS;
var ATTRIBUTE = _commons.ATTRIBUTE;
var newNode = _commons.newNode;
function getAttributeListener(eventTarget, type) {
var node = eventTarget[LISTENERS][type];
var node = eventTarget[_LISTENERS$ATTRIBUTE$newNode.LISTENERS][type];
while (node != null) {
if (node.kind === ATTRIBUTE) {
if (node.kind === _LISTENERS$ATTRIBUTE$newNode.ATTRIBUTE) {
return node.listener;

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

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

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

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

@@ -93,18 +89,13 @@ }

module.exports = EventTarget;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = EventTarget;
var _commons = require("./commons");
var _LISTENERS$CAPTURE$BUBBLE$newNode = require("./commons");
var LISTENERS = _commons.LISTENERS;
var CAPTURE = _commons.CAPTURE;
var BUBBLE = _commons.BUBBLE;
var newNode = _commons.newNode;
var _defineCustomEventTarget = require("./CustomEventTarget");
var defineCustomEventTarget = require("./CustomEventTarget").defineCustomEventTarget;
var _createEventWrapper$STOP_IMMEDIATE_PROPAGATION_FLAG = require("./EventWrapper");
var _EventWrapper = require("./EventWrapper");
var createEventWrapper = _EventWrapper.createEventWrapper;
var STOP_IMMEDIATE_PROPAGATION_FLAG = _EventWrapper.STOP_IMMEDIATE_PROPAGATION_FLAG;
var HAS_EVENTTARGET_INTERFACE = typeof window !== "undefined" && typeof window.EventTarget !== "undefined";

@@ -127,3 +118,3 @@

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

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

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

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

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

@@ -178,3 +169,3 @@ }

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

@@ -194,9 +185,9 @@ },

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

@@ -221,3 +212,3 @@ prev.next = node.next;

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

@@ -228,3 +219,3 @@ return true;

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

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

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

@@ -248,19 +239,18 @@ }

});
module.exports = exports["default"];
},{"./CustomEventTarget":1,"./EventWrapper":3,"./commons":4}],3:[function(require,module,exports){
"use strict";
var _defineProperty = function (obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); };
exports.createEventWrapper = createEventWrapper;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createEventWrapper = createEventWrapper;
var symbol = require("./commons").symbol;
var _symbol = require("./commons");
var STOP_IMMEDIATE_PROPAGATION_FLAG = symbol("stop_immediate_propagation_flag");
var STOP_IMMEDIATE_PROPAGATION_FLAG = _symbol.symbol("stop_immediate_propagation_flag");
exports.STOP_IMMEDIATE_PROPAGATION_FLAG = STOP_IMMEDIATE_PROPAGATION_FLAG;
var CANCELED_FLAG = symbol("canceled_flag");
var ORIGINAL_EVENT = symbol("original_event");
var CANCELED_FLAG = _symbol.symbol("canceled_flag");
var ORIGINAL_EVENT = _symbol.symbol("original_event");

@@ -319,32 +309,27 @@ var wrapperPrototypeDefinition = {

return Object.create(Object.create(event, wrapperPrototypeDefinition), (function () {
var _Object$create = {
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 } };
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 });
_defineProperty(_Object$create, STOP_IMMEDIATE_PROPAGATION_FLAG, { value: false, writable: true });
_defineProperty(_Object$create, CANCELED_FLAG, { value: false, writable: true });
_defineProperty(_Object$create, ORIGINAL_EVENT, { value: event });
return _Object$create;
})());
return retv;
}
},{"./commons":4}],4:[function(require,module,exports){
// Create a LinkedList structure for EventListener.
"use strict";
exports.newNode = newNode;
Object.defineProperty(exports, "__esModule", {
value: true
});
// Create a LinkedList structure for EventListener.
exports.newNode = newNode;
var symbol = typeof Symbol !== "undefined" ? Symbol : function Symbol(name) {

@@ -351,0 +336,0 @@ return "[[" + name + "_" + Math.random().toFixed(8).slice(2) + "]]";

@@ -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[i][t];null!=n;){if(n.kind===l)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[i][t];null!=o;)o.kind===l?null==r?e[i][t]=o.next:r.next=o.next:r=o,o=o.next;null!=n&&(null==r?e[i][t]=f(n,l):r.next=f(n,l))}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}n.defineCustomEventTarget=u,Object.defineProperty(n,"__esModule",{value:!0});var a=e("./commons"),i=a.LISTENERS,l=a.ATTRIBUTE,f=a.newNode},{"./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 f(r,t);throw new TypeError("Cannot call a class as a function")}Object.defineProperty(this,u,{value:Object.create(null)})}t.exports=r;var o=e("./commons"),u=o.LISTENERS,a=o.CAPTURE,i=o.BUBBLE,l=o.newNode,f=e("./CustomEventTarget").defineCustomEventTarget,c=e("./EventWrapper"),s=c.createEventWrapper,v=c.STOP_IMMEDIATE_PROPAGATION_FLAG,p="undefined"!=typeof window&&"undefined"!=typeof window.EventTarget;r.prototype=Object.create((p?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?a:i,o=this[u][e];if(null==o)return this[u][e]=l(t,r),!0;for(var f=null;null!=o;){if(o.listener===t&&o.kind===r)return!1;f=o,o=o.next}return f.next=l(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?a:i,o=null,l=this[u][e];null!=l;){if(l.listener===t&&l.kind===r)return null==o?this[u][e]=l.next:o.next=l.next,!0;o=l,l=l.next}return!1},configurable:!0,writable:!0},dispatchEvent:{value:function(e){var t=this[u][e.type];if(null==t)return!0;for(e=s(e,this);null!=t&&(t.listener.call(this,e),!e[v]);)t=t.next;return!e.defaultPrevented},configurable:!0,writable:!0}})},{"./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();return Object.create(Object.create(e,f),function(){var 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}};return o(r,a,{value:!1,writable:!0}),o(r,i,{value:!1,writable:!0}),o(r,l,{value:e}),r}())}var o=function(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})};n.createEventWrapper=r,Object.defineProperty(n,"__esModule",{value:!0});var u=e("./commons").symbol,a=u("stop_immediate_propagation_flag");n.STOP_IMMEDIATE_PROPAGATION_FLAG=a;var i=u("canceled_flag"),l=u("original_event"),f={stopPropagation:{value:function(){var e=this[l];"function"==typeof e.stopPropagation&&e.stopPropagation()},writable:!0,configurable:!0},stopImmediatePropagation:{value:function(){this[a]=!0;var e=this[l];"function"==typeof e.stopImmediatePropagation&&e.stopImmediatePropagation()},writable:!0,configurable:!0},preventDefault:{value:function(){this.cancelable===!0&&(this[i]=!0);var e=this[l];"function"==typeof e.preventDefault&&e.preventDefault()},writable:!0,configurable:!0},defaultPrevented:{get:function(){return this[i]},enumerable:!0,configurable:!0}}},{"./commons":4}],4:[function(e,t,n){"use strict";function r(e,t){return{listener:e,kind:t,next:null}}n.newNode=r,Object.defineProperty(n,"__esModule",{value:!0});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(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)});

@@ -1,10 +0,9 @@

// Create a LinkedList structure for EventListener.
"use strict";
exports.newNode = newNode;
Object.defineProperty(exports, "__esModule", {
value: true
});
// Create a LinkedList structure for EventListener.
exports.newNode = newNode;
var symbol = typeof Symbol !== "undefined" ? Symbol : function Symbol(name) {

@@ -11,0 +10,0 @@ return "[[" + name + "_" + Math.random().toFixed(8).slice(2) + "]]";

"use strict";
exports.defineCustomEventTarget = defineCustomEventTarget;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.defineCustomEventTarget = defineCustomEventTarget;
var _commons = require("./commons");
var _LISTENERS$ATTRIBUTE$newNode = require("./commons");
var LISTENERS = _commons.LISTENERS;
var ATTRIBUTE = _commons.ATTRIBUTE;
var newNode = _commons.newNode;
function getAttributeListener(eventTarget, type) {
var node = eventTarget[LISTENERS][type];
var node = eventTarget[_LISTENERS$ATTRIBUTE$newNode.LISTENERS][type];
while (node != null) {
if (node.kind === ATTRIBUTE) {
if (node.kind === _LISTENERS$ATTRIBUTE$newNode.ATTRIBUTE) {
return node.listener;

@@ -31,8 +27,8 @@ }

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

@@ -51,5 +47,5 @@ prev.next = node.next;

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

@@ -56,0 +52,0 @@ }

"use strict";
module.exports = EventTarget;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = EventTarget;
var _commons = require("./commons");
var _LISTENERS$CAPTURE$BUBBLE$newNode = require("./commons");
var LISTENERS = _commons.LISTENERS;
var CAPTURE = _commons.CAPTURE;
var BUBBLE = _commons.BUBBLE;
var newNode = _commons.newNode;
var _defineCustomEventTarget = require("./CustomEventTarget");
var defineCustomEventTarget = require("./CustomEventTarget").defineCustomEventTarget;
var _createEventWrapper$STOP_IMMEDIATE_PROPAGATION_FLAG = require("./EventWrapper");
var _EventWrapper = require("./EventWrapper");
var createEventWrapper = _EventWrapper.createEventWrapper;
var STOP_IMMEDIATE_PROPAGATION_FLAG = _EventWrapper.STOP_IMMEDIATE_PROPAGATION_FLAG;
var HAS_EVENTTARGET_INTERFACE = typeof window !== "undefined" && typeof window.EventTarget !== "undefined";

@@ -36,3 +31,3 @@

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

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

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

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

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

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

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

@@ -103,9 +98,9 @@ },

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

@@ -130,3 +125,3 @@ prev.next = node.next;

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

@@ -137,3 +132,3 @@ return true;

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

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

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

@@ -156,2 +151,3 @@ }

}
});
});
module.exports = exports["default"];
"use strict";
var _defineProperty = function (obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); };
exports.createEventWrapper = createEventWrapper;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createEventWrapper = createEventWrapper;
var symbol = require("./commons").symbol;
var _symbol = require("./commons");
var STOP_IMMEDIATE_PROPAGATION_FLAG = symbol("stop_immediate_propagation_flag");
var STOP_IMMEDIATE_PROPAGATION_FLAG = _symbol.symbol("stop_immediate_propagation_flag");
exports.STOP_IMMEDIATE_PROPAGATION_FLAG = STOP_IMMEDIATE_PROPAGATION_FLAG;
var CANCELED_FLAG = symbol("canceled_flag");
var ORIGINAL_EVENT = symbol("original_event");
var CANCELED_FLAG = _symbol.symbol("canceled_flag");
var ORIGINAL_EVENT = _symbol.symbol("original_event");

@@ -70,21 +68,17 @@ var wrapperPrototypeDefinition = {

return Object.create(Object.create(event, wrapperPrototypeDefinition), (function () {
var _Object$create = {
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 } };
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 });
_defineProperty(_Object$create, STOP_IMMEDIATE_PROPAGATION_FLAG, { value: false, writable: true });
_defineProperty(_Object$create, CANCELED_FLAG, { value: false, writable: true });
_defineProperty(_Object$create, ORIGINAL_EVENT, { value: event });
return _Object$create;
})());
return retv;
}
{
"name": "event-target-shim",
"version": "1.0.2",
"version": "1.0.3",
"description": "A polyfill for W3C EventTarget Constructor.",

@@ -24,9 +24,9 @@ "main": "lib/EventTarget.js",

"devDependencies": {
"babel": "^4.7.16",
"babelify": "^5.0.4",
"browserify": "^9.0.3",
"babel": "^5.0.8",
"babelify": "^6.0.1",
"browserify": "^9.0.7",
"eslint": "^0.18.0",
"espowerify": "^0.10.0",
"karma": "^0.12.31",
"karma-browserify": "^4.1.0",
"karma-browserify": "^4.1.2",
"karma-chrome-launcher": "^0.1.7",

@@ -39,3 +39,3 @@ "karma-firefox-launcher": "^0.1.4",

"mocha": "^2.2.1",
"npm-run-all": "^1.1.1",
"npm-run-all": "^1.1.2",
"power-assert": "^0.10.2",

@@ -42,0 +42,0 @@ "rimraf": "^2.3.2",

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