Gazebo_simulation-Frontend/node_modules/.cache/babel-loader/e9b6be8d90ace42ab7b99809fc97a6e6.json
2020-12-22 09:59:14 -05:00

1 line
2.0 KiB
JSON

{"ast":null,"code":"'use strict';\n/* Simplified implementation of DOM2 EventTarget.\n * http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventTarget\n */\n\nfunction EventTarget() {\n this._listeners = {};\n}\n\nEventTarget.prototype.addEventListener = function (eventType, listener) {\n if (!(eventType in this._listeners)) {\n this._listeners[eventType] = [];\n }\n\n var arr = this._listeners[eventType]; // #4\n\n if (arr.indexOf(listener) === -1) {\n // Make a copy so as not to interfere with a current dispatchEvent.\n arr = arr.concat([listener]);\n }\n\n this._listeners[eventType] = arr;\n};\n\nEventTarget.prototype.removeEventListener = function (eventType, listener) {\n var arr = this._listeners[eventType];\n\n if (!arr) {\n return;\n }\n\n var idx = arr.indexOf(listener);\n\n if (idx !== -1) {\n if (arr.length > 1) {\n // Make a copy so as not to interfere with a current dispatchEvent.\n this._listeners[eventType] = arr.slice(0, idx).concat(arr.slice(idx + 1));\n } else {\n delete this._listeners[eventType];\n }\n\n return;\n }\n};\n\nEventTarget.prototype.dispatchEvent = function () {\n var event = arguments[0];\n var t = event.type; // equivalent of Array.prototype.slice.call(arguments, 0);\n\n var args = arguments.length === 1 ? [event] : Array.apply(null, arguments); // TODO: This doesn't match the real behavior; per spec, onfoo get\n // their place in line from the /first/ time they're set from\n // non-null. Although WebKit bumps it to the end every time it's\n // set.\n\n if (this['on' + t]) {\n this['on' + t].apply(this, args);\n }\n\n if (t in this._listeners) {\n // Grab a reference to the listeners list. removeEventListener may alter the list.\n var listeners = this._listeners[t];\n\n for (var i = 0; i < listeners.length; i++) {\n listeners[i].apply(this, args);\n }\n }\n};\n\nmodule.exports = EventTarget;","map":null,"metadata":{},"sourceType":"script"}