@cloudcare/browser-core 3.2.40 → 3.2.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -38,19 +38,59 @@ function addEventListeners(eventTarget, eventNames, listener, options) {
|
|
|
38
38
|
passive: options.passive
|
|
39
39
|
} : options && options.capture;
|
|
40
40
|
// Use the window.EventTarget.prototype when possible to avoid wrong overrides (e.g: https://github.com/salesforce/lwc/issues/1824)
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
// const istarget = Object.prototype.toString.call(window)
|
|
42
|
+
// const listenerTarget =
|
|
43
|
+
// window.EventTarget && eventTarget instanceof EventTarget
|
|
44
|
+
// ? window.EventTarget.prototype
|
|
45
|
+
// : eventTarget
|
|
46
|
+
// var add = getZoneJsOriginalValue(listenerTarget, 'addEventListener')
|
|
47
|
+
|
|
48
|
+
// eventNames.forEach((eventName) => {
|
|
49
|
+
// add.call(eventTarget, eventName, wrappedListener, options)
|
|
50
|
+
// })
|
|
43
51
|
(0, _tools.each)(eventNames, function (eventName) {
|
|
44
|
-
|
|
52
|
+
withOriginalOrZoneJsPatchedMethod(eventTarget, 'addEventListener', function (method) {
|
|
53
|
+
return method.call(eventTarget, eventName, wrappedListener, options);
|
|
54
|
+
});
|
|
55
|
+
// add.call(eventTarget, eventName, wrappedListener, options)
|
|
45
56
|
});
|
|
46
57
|
var stop = function stop() {
|
|
47
|
-
var remove =
|
|
58
|
+
// var remove = getZoneJsOriginalValue(listenerTarget, 'removeEventListener')
|
|
48
59
|
(0, _tools.each)(eventNames, function (eventName) {
|
|
49
|
-
|
|
60
|
+
withOriginalOrZoneJsPatchedMethod(eventTarget, 'removeEventListener', function (method) {
|
|
61
|
+
return method.call(eventTarget, eventName, wrappedListener, options);
|
|
62
|
+
});
|
|
63
|
+
// remove.call(eventTarget, eventName, wrappedListener, options)
|
|
50
64
|
});
|
|
51
65
|
};
|
|
52
66
|
return {
|
|
53
67
|
stop: stop
|
|
54
68
|
};
|
|
55
69
|
}
|
|
70
|
+
function isIllegalInvocationError(error, methodName) {
|
|
71
|
+
if (!(error instanceof Error)) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
return error.message.includes('Illegal invocation') ||
|
|
75
|
+
// chrome
|
|
76
|
+
error.message.includes("'".concat(methodName, "' called on an object that does not implement interface EventTarget.")) ||
|
|
77
|
+
// firefox
|
|
78
|
+
error.message.includes("Can only call EventTarget.".concat(methodName, " on instances of EventTarget")) // safari
|
|
79
|
+
;
|
|
80
|
+
}
|
|
81
|
+
function withOriginalOrZoneJsPatchedMethod(eventTarget, methodName, cb) {
|
|
82
|
+
// Use the window.EventTarget.prototype when possible to avoid wrong overrides (e.g: https://github.com/salesforce/lwc/issues/1824)
|
|
83
|
+
var listenerTarget = window.EventTarget && eventTarget instanceof EventTarget ? window.EventTarget.prototype : eventTarget;
|
|
84
|
+
var originalMethod = (0, _getZoneJsOriginalValue.getZoneJsOriginalValue)(listenerTarget, methodName);
|
|
85
|
+
try {
|
|
86
|
+
// In some cases this call fails with an Illegal invocation error, we then catch the error and use the zone.js
|
|
87
|
+
// patched method
|
|
88
|
+
cb(originalMethod);
|
|
89
|
+
} catch (error) {
|
|
90
|
+
if (isIllegalInvocationError(error, methodName)) {
|
|
91
|
+
return cb(eventTarget[methodName]);
|
|
92
|
+
}
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
56
96
|
//# sourceMappingURL=addEventListener.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addEventListener.js","names":["_tools","require","_getZoneJsOriginalValue","_monitor","addEventListener","eventTarget","event","listener","options","addEventListeners","eventNames","wrappedListener","monitor","once","stop","passive","capture","
|
|
1
|
+
{"version":3,"file":"addEventListener.js","names":["_tools","require","_getZoneJsOriginalValue","_monitor","addEventListener","eventTarget","event","listener","options","addEventListeners","eventNames","wrappedListener","monitor","once","stop","passive","capture","each","eventName","withOriginalOrZoneJsPatchedMethod","method","call","isIllegalInvocationError","error","methodName","Error","message","includes","concat","cb","listenerTarget","window","EventTarget","prototype","originalMethod","getZoneJsOriginalValue"],"sources":["../../src/browser/addEventListener.js"],"sourcesContent":["import { each } from '../helper/tools'\nimport { getZoneJsOriginalValue } from '../helper/getZoneJsOriginalValue'\nimport { monitor } from '../helper/monitor'\nexport function addEventListener(eventTarget, event, listener, options) {\n return addEventListeners(eventTarget, [event], listener, options)\n}\n\n/**\n * Add event listeners to an event emitter object (Window, Element, mock object...). This provides\n * a few conveniences compared to using `element.addEventListener` directly:\n *\n * * supports IE11 by:\n * * using an option object only if needed\n * * emulating the `once` option\n *\n * * wraps the listener with a `monitor` function\n *\n * * returns a `stop` function to remove the listener\n *\n * * with `once: true`, the listener will be called at most once, even if different events are\n * listened\n */\n\nexport function addEventListeners(eventTarget, eventNames, listener, options) {\n var wrappedListener = monitor(\n options && options.once\n ? function (event) {\n stop()\n listener(event)\n }\n : listener\n )\n options =\n options && options.passive\n ? { capture: options.capture, passive: options.passive }\n : options && options.capture\n // Use the window.EventTarget.prototype when possible to avoid wrong overrides (e.g: https://github.com/salesforce/lwc/issues/1824)\n // const istarget = Object.prototype.toString.call(window)\n // const listenerTarget =\n // window.EventTarget && eventTarget instanceof EventTarget\n // ? window.EventTarget.prototype\n // : eventTarget\n // var add = getZoneJsOriginalValue(listenerTarget, 'addEventListener')\n\n // eventNames.forEach((eventName) => {\n // add.call(eventTarget, eventName, wrappedListener, options)\n // })\n each(eventNames, function (eventName) {\n withOriginalOrZoneJsPatchedMethod(\n eventTarget,\n 'addEventListener',\n (method) => method.call(eventTarget, eventName, wrappedListener, options)\n )\n // add.call(eventTarget, eventName, wrappedListener, options)\n })\n var stop = function () {\n // var remove = getZoneJsOriginalValue(listenerTarget, 'removeEventListener')\n each(eventNames, function (eventName) {\n withOriginalOrZoneJsPatchedMethod(\n eventTarget,\n 'removeEventListener',\n (method) =>\n method.call(eventTarget, eventName, wrappedListener, options)\n )\n // remove.call(eventTarget, eventName, wrappedListener, options)\n })\n }\n return {\n stop: stop\n }\n}\nfunction isIllegalInvocationError(error, methodName) {\n if (!(error instanceof Error)) {\n return false\n }\n\n return (\n error.message.includes('Illegal invocation') || // chrome\n error.message.includes(\n `'${methodName}' called on an object that does not implement interface EventTarget.`\n ) || // firefox\n error.message.includes(\n `Can only call EventTarget.${methodName} on instances of EventTarget`\n ) // safari\n )\n}\n\nfunction withOriginalOrZoneJsPatchedMethod(eventTarget, methodName, cb) {\n // Use the window.EventTarget.prototype when possible to avoid wrong overrides (e.g: https://github.com/salesforce/lwc/issues/1824)\n const listenerTarget =\n window.EventTarget && eventTarget instanceof EventTarget\n ? window.EventTarget.prototype\n : eventTarget\n\n const originalMethod = getZoneJsOriginalValue(listenerTarget, methodName)\n\n try {\n // In some cases this call fails with an Illegal invocation error, we then catch the error and use the zone.js\n // patched method\n cb(originalMethod)\n } catch (error) {\n if (isIllegalInvocationError(error, methodName)) {\n return cb(eventTarget[methodName])\n }\n\n throw error\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACO,SAASG,gBAAgBA,CAACC,WAAW,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,OAAO,EAAE;EACtE,OAAOC,iBAAiB,CAACJ,WAAW,EAAE,CAACC,KAAK,CAAC,EAAEC,QAAQ,EAAEC,OAAO,CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,SAASC,iBAAiBA,CAACJ,WAAW,EAAEK,UAAU,EAAEH,QAAQ,EAAEC,OAAO,EAAE;EAC5E,IAAIG,eAAe,GAAG,IAAAC,gBAAO,EAC3BJ,OAAO,IAAIA,OAAO,CAACK,IAAI,GACnB,UAAUP,KAAK,EAAE;IACfQ,IAAI,CAAC,CAAC;IACNP,QAAQ,CAACD,KAAK,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CAAC,CAAC;EAAA;AAEN;AAEA,SAASL,iCAAiCA,CAACd,WAAW,EAAEmB,UAAU,EAAEK,EAAE,EAAE;EACtE;EACA,IAAMC,cAAc,GAClBC,MAAM,CAACC,WAAW,IAAI3B,WAAW,YAAY2B,WAAW,GACpDD,MAAM,CAACC,WAAW,CAACC,SAAS,GAC5B5B,WAAW;EAEjB,IAAM6B,cAAc,GAAG,IAAAC,8CAAsB,EAACL,cAAc,EAAEN,UAAU,CAAC;EAEzE,IAAI;IACF;IACA;IACAK,EAAE,CAACK,cAAc,CAAC;EACpB,CAAC,CAAC,OAAOX,KAAK,EAAE;IACd,IAAID,wBAAwB,CAACC,KAAK,EAAEC,UAAU,CAAC,EAAE;MAC/C,OAAOK,EAAE,CAACxB,WAAW,CAACmB,UAAU,CAAC,CAAC;IACpC;IAEA,MAAMD,KAAK;EACb;AACF","ignoreList":[]}
|
|
@@ -31,19 +31,59 @@ export function addEventListeners(eventTarget, eventNames, listener, options) {
|
|
|
31
31
|
passive: options.passive
|
|
32
32
|
} : options && options.capture;
|
|
33
33
|
// Use the window.EventTarget.prototype when possible to avoid wrong overrides (e.g: https://github.com/salesforce/lwc/issues/1824)
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
// const istarget = Object.prototype.toString.call(window)
|
|
35
|
+
// const listenerTarget =
|
|
36
|
+
// window.EventTarget && eventTarget instanceof EventTarget
|
|
37
|
+
// ? window.EventTarget.prototype
|
|
38
|
+
// : eventTarget
|
|
39
|
+
// var add = getZoneJsOriginalValue(listenerTarget, 'addEventListener')
|
|
40
|
+
|
|
41
|
+
// eventNames.forEach((eventName) => {
|
|
42
|
+
// add.call(eventTarget, eventName, wrappedListener, options)
|
|
43
|
+
// })
|
|
36
44
|
each(eventNames, function (eventName) {
|
|
37
|
-
|
|
45
|
+
withOriginalOrZoneJsPatchedMethod(eventTarget, 'addEventListener', function (method) {
|
|
46
|
+
return method.call(eventTarget, eventName, wrappedListener, options);
|
|
47
|
+
});
|
|
48
|
+
// add.call(eventTarget, eventName, wrappedListener, options)
|
|
38
49
|
});
|
|
39
50
|
var stop = function stop() {
|
|
40
|
-
var remove = getZoneJsOriginalValue(listenerTarget, 'removeEventListener')
|
|
51
|
+
// var remove = getZoneJsOriginalValue(listenerTarget, 'removeEventListener')
|
|
41
52
|
each(eventNames, function (eventName) {
|
|
42
|
-
|
|
53
|
+
withOriginalOrZoneJsPatchedMethod(eventTarget, 'removeEventListener', function (method) {
|
|
54
|
+
return method.call(eventTarget, eventName, wrappedListener, options);
|
|
55
|
+
});
|
|
56
|
+
// remove.call(eventTarget, eventName, wrappedListener, options)
|
|
43
57
|
});
|
|
44
58
|
};
|
|
45
59
|
return {
|
|
46
60
|
stop: stop
|
|
47
61
|
};
|
|
48
62
|
}
|
|
63
|
+
function isIllegalInvocationError(error, methodName) {
|
|
64
|
+
if (!(error instanceof Error)) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return error.message.includes('Illegal invocation') ||
|
|
68
|
+
// chrome
|
|
69
|
+
error.message.includes("'".concat(methodName, "' called on an object that does not implement interface EventTarget.")) ||
|
|
70
|
+
// firefox
|
|
71
|
+
error.message.includes("Can only call EventTarget.".concat(methodName, " on instances of EventTarget")) // safari
|
|
72
|
+
;
|
|
73
|
+
}
|
|
74
|
+
function withOriginalOrZoneJsPatchedMethod(eventTarget, methodName, cb) {
|
|
75
|
+
// Use the window.EventTarget.prototype when possible to avoid wrong overrides (e.g: https://github.com/salesforce/lwc/issues/1824)
|
|
76
|
+
var listenerTarget = window.EventTarget && eventTarget instanceof EventTarget ? window.EventTarget.prototype : eventTarget;
|
|
77
|
+
var originalMethod = getZoneJsOriginalValue(listenerTarget, methodName);
|
|
78
|
+
try {
|
|
79
|
+
// In some cases this call fails with an Illegal invocation error, we then catch the error and use the zone.js
|
|
80
|
+
// patched method
|
|
81
|
+
cb(originalMethod);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
if (isIllegalInvocationError(error, methodName)) {
|
|
84
|
+
return cb(eventTarget[methodName]);
|
|
85
|
+
}
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
49
89
|
//# sourceMappingURL=addEventListener.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addEventListener.js","names":["each","getZoneJsOriginalValue","monitor","addEventListener","eventTarget","event","listener","options","addEventListeners","eventNames","wrappedListener","once","stop","passive","capture","
|
|
1
|
+
{"version":3,"file":"addEventListener.js","names":["each","getZoneJsOriginalValue","monitor","addEventListener","eventTarget","event","listener","options","addEventListeners","eventNames","wrappedListener","once","stop","passive","capture","eventName","withOriginalOrZoneJsPatchedMethod","method","call","isIllegalInvocationError","error","methodName","Error","message","includes","concat","cb","listenerTarget","window","EventTarget","prototype","originalMethod"],"sources":["../../src/browser/addEventListener.js"],"sourcesContent":["import { each } from '../helper/tools'\nimport { getZoneJsOriginalValue } from '../helper/getZoneJsOriginalValue'\nimport { monitor } from '../helper/monitor'\nexport function addEventListener(eventTarget, event, listener, options) {\n return addEventListeners(eventTarget, [event], listener, options)\n}\n\n/**\n * Add event listeners to an event emitter object (Window, Element, mock object...). This provides\n * a few conveniences compared to using `element.addEventListener` directly:\n *\n * * supports IE11 by:\n * * using an option object only if needed\n * * emulating the `once` option\n *\n * * wraps the listener with a `monitor` function\n *\n * * returns a `stop` function to remove the listener\n *\n * * with `once: true`, the listener will be called at most once, even if different events are\n * listened\n */\n\nexport function addEventListeners(eventTarget, eventNames, listener, options) {\n var wrappedListener = monitor(\n options && options.once\n ? function (event) {\n stop()\n listener(event)\n }\n : listener\n )\n options =\n options && options.passive\n ? { capture: options.capture, passive: options.passive }\n : options && options.capture\n // Use the window.EventTarget.prototype when possible to avoid wrong overrides (e.g: https://github.com/salesforce/lwc/issues/1824)\n // const istarget = Object.prototype.toString.call(window)\n // const listenerTarget =\n // window.EventTarget && eventTarget instanceof EventTarget\n // ? window.EventTarget.prototype\n // : eventTarget\n // var add = getZoneJsOriginalValue(listenerTarget, 'addEventListener')\n\n // eventNames.forEach((eventName) => {\n // add.call(eventTarget, eventName, wrappedListener, options)\n // })\n each(eventNames, function (eventName) {\n withOriginalOrZoneJsPatchedMethod(\n eventTarget,\n 'addEventListener',\n (method) => method.call(eventTarget, eventName, wrappedListener, options)\n )\n // add.call(eventTarget, eventName, wrappedListener, options)\n })\n var stop = function () {\n // var remove = getZoneJsOriginalValue(listenerTarget, 'removeEventListener')\n each(eventNames, function (eventName) {\n withOriginalOrZoneJsPatchedMethod(\n eventTarget,\n 'removeEventListener',\n (method) =>\n method.call(eventTarget, eventName, wrappedListener, options)\n )\n // remove.call(eventTarget, eventName, wrappedListener, options)\n })\n }\n return {\n stop: stop\n }\n}\nfunction isIllegalInvocationError(error, methodName) {\n if (!(error instanceof Error)) {\n return false\n }\n\n return (\n error.message.includes('Illegal invocation') || // chrome\n error.message.includes(\n `'${methodName}' called on an object that does not implement interface EventTarget.`\n ) || // firefox\n error.message.includes(\n `Can only call EventTarget.${methodName} on instances of EventTarget`\n ) // safari\n )\n}\n\nfunction withOriginalOrZoneJsPatchedMethod(eventTarget, methodName, cb) {\n // Use the window.EventTarget.prototype when possible to avoid wrong overrides (e.g: https://github.com/salesforce/lwc/issues/1824)\n const listenerTarget =\n window.EventTarget && eventTarget instanceof EventTarget\n ? window.EventTarget.prototype\n : eventTarget\n\n const originalMethod = getZoneJsOriginalValue(listenerTarget, methodName)\n\n try {\n // In some cases this call fails with an Illegal invocation error, we then catch the error and use the zone.js\n // patched method\n cb(originalMethod)\n } catch (error) {\n if (isIllegalInvocationError(error, methodName)) {\n return cb(eventTarget[methodName])\n }\n\n throw error\n }\n}\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,iBAAiB;AACtC,SAASC,sBAAsB,QAAQ,kCAAkC;AACzE,SAASC,OAAO,QAAQ,mBAAmB;AAC3C,OAAO,SAASC,gBAAgBA,CAACC,WAAW,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,OAAO,EAAE;EACtE,OAAOC,i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,EAAEA;EACR,CAAC;AACH;AACA,SAASO,wBAAwBA,CAACC,KAAK,EAAEC,UAAU,EAAE;EACnD,IAAI,EAAED,KAAK,YAAYE,KAAK,CAAC,EAAE;IAC7B,OAAO,KAAK;EACd;EAEA,OACEF,KAAK,CAACG,OAAO,CAACC,QAAQ,CAAC,oBAAoB,CAAC;EAAI;EAChDJ,KAAK,CAACG,OAAO,CAACC,QAAQ,KAAAC,MAAA,CAChBJ,UAAU,yEAChB,CAAC;EAAI;EACLD,KAAK,CAACG,OAAO,CAACC,QAAQ,8BAAAC,MAAA,CACSJ,UAAU,iCACzC,CAAC,CAAC;EAAA;AAEN;AAEA,SAASL,iCAAiCA,CAACZ,WAAW,EAAEiB,UAAU,EAAEK,EAAE,EAAE;EACtE;EACA,IAAMC,cAAc,GAClBC,MAAM,CAACC,WAAW,IAAIzB,WAAW,YAAYyB,WAAW,GACpDD,MAAM,CAACC,WAAW,CAACC,SAAS,GAC5B1B,WAAW;EAEjB,IAAM2B,cAAc,GAAG9B,sBAAsB,CAAC0B,cAAc,EAAEN,UAAU,CAAC;EAEzE,IAAI;IACF;IACA;IACAK,EAAE,CAACK,cAAc,CAAC;EACpB,CAAC,CAAC,OAAOX,KAAK,EAAE;IACd,IAAID,wBAAwB,CAACC,KAAK,EAAEC,UAAU,CAAC,EAAE;MAC/C,OAAOK,EAAE,CAACtB,WAAW,CAACiB,UAAU,CAAC,CAAC;IACpC;IAEA,MAAMD,KAAK;EACb;AACF","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcare/browser-core",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.41",
|
|
4
4
|
"main": "cjs/index.js",
|
|
5
5
|
"module": "esm/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
},
|
|
22
22
|
"author": "dataflux",
|
|
23
23
|
"license": "MIT",
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "3e05985fe37e62e7a332e1f5c96cd5b12e7e9b81"
|
|
25
25
|
}
|
|
@@ -35,22 +35,74 @@ export function addEventListeners(eventTarget, eventNames, listener, options) {
|
|
|
35
35
|
? { capture: options.capture, passive: options.passive }
|
|
36
36
|
: options && options.capture
|
|
37
37
|
// Use the window.EventTarget.prototype when possible to avoid wrong overrides (e.g: https://github.com/salesforce/lwc/issues/1824)
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
// const istarget = Object.prototype.toString.call(window)
|
|
39
|
+
// const listenerTarget =
|
|
40
|
+
// window.EventTarget && eventTarget instanceof EventTarget
|
|
41
|
+
// ? window.EventTarget.prototype
|
|
42
|
+
// : eventTarget
|
|
43
|
+
// var add = getZoneJsOriginalValue(listenerTarget, 'addEventListener')
|
|
43
44
|
|
|
45
|
+
// eventNames.forEach((eventName) => {
|
|
46
|
+
// add.call(eventTarget, eventName, wrappedListener, options)
|
|
47
|
+
// })
|
|
44
48
|
each(eventNames, function (eventName) {
|
|
45
|
-
|
|
49
|
+
withOriginalOrZoneJsPatchedMethod(
|
|
50
|
+
eventTarget,
|
|
51
|
+
'addEventListener',
|
|
52
|
+
(method) => method.call(eventTarget, eventName, wrappedListener, options)
|
|
53
|
+
)
|
|
54
|
+
// add.call(eventTarget, eventName, wrappedListener, options)
|
|
46
55
|
})
|
|
47
56
|
var stop = function () {
|
|
48
|
-
var remove = getZoneJsOriginalValue(listenerTarget, 'removeEventListener')
|
|
57
|
+
// var remove = getZoneJsOriginalValue(listenerTarget, 'removeEventListener')
|
|
49
58
|
each(eventNames, function (eventName) {
|
|
50
|
-
|
|
59
|
+
withOriginalOrZoneJsPatchedMethod(
|
|
60
|
+
eventTarget,
|
|
61
|
+
'removeEventListener',
|
|
62
|
+
(method) =>
|
|
63
|
+
method.call(eventTarget, eventName, wrappedListener, options)
|
|
64
|
+
)
|
|
65
|
+
// remove.call(eventTarget, eventName, wrappedListener, options)
|
|
51
66
|
})
|
|
52
67
|
}
|
|
53
68
|
return {
|
|
54
69
|
stop: stop
|
|
55
70
|
}
|
|
56
71
|
}
|
|
72
|
+
function isIllegalInvocationError(error, methodName) {
|
|
73
|
+
if (!(error instanceof Error)) {
|
|
74
|
+
return false
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
error.message.includes('Illegal invocation') || // chrome
|
|
79
|
+
error.message.includes(
|
|
80
|
+
`'${methodName}' called on an object that does not implement interface EventTarget.`
|
|
81
|
+
) || // firefox
|
|
82
|
+
error.message.includes(
|
|
83
|
+
`Can only call EventTarget.${methodName} on instances of EventTarget`
|
|
84
|
+
) // safari
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function withOriginalOrZoneJsPatchedMethod(eventTarget, methodName, cb) {
|
|
89
|
+
// Use the window.EventTarget.prototype when possible to avoid wrong overrides (e.g: https://github.com/salesforce/lwc/issues/1824)
|
|
90
|
+
const listenerTarget =
|
|
91
|
+
window.EventTarget && eventTarget instanceof EventTarget
|
|
92
|
+
? window.EventTarget.prototype
|
|
93
|
+
: eventTarget
|
|
94
|
+
|
|
95
|
+
const originalMethod = getZoneJsOriginalValue(listenerTarget, methodName)
|
|
96
|
+
|
|
97
|
+
try {
|
|
98
|
+
// In some cases this call fails with an Illegal invocation error, we then catch the error and use the zone.js
|
|
99
|
+
// patched method
|
|
100
|
+
cb(originalMethod)
|
|
101
|
+
} catch (error) {
|
|
102
|
+
if (isIllegalInvocationError(error, methodName)) {
|
|
103
|
+
return cb(eventTarget[methodName])
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
throw error
|
|
107
|
+
}
|
|
108
|
+
}
|