diff options
| author | Nicolas Lempereur <nle@odoo.com> | 2019-11-07 10:23:57 +0000 |
|---|---|---|
| committer | Nicolas Lempereur <nle@odoo.com> | 2019-11-12 17:13:56 +0000 |
| commit | 062735847c6ea145804207952acb3a8e2ebe7259 (patch) | |
| tree | e100dbad1021402e4a21c1c989706c02b1201e52 /addons/web/static/lib | |
| parent | a1839fb305b872632791be11bc481d591b58c395 (diff) | |
[FIX] web: guardedCatch on IE Edge async return
In IE Edge async and await are supported, but guardedCatch is added to
polyfilled MyPromise object and async methods return original Promise so
depending of chain guardedCatch can cause en error or not.
It seems that historically, the MyPromise patching has also had issue in
firefox with it sometimes working or not.
In this changeset we completely remove it (which will have the drawback
of more error shown in console in firefox).
opw-1964486
opw-2116839
closes #39953
closes odoo/odoo#40154
X-original-commit: 5ca38da66de00ca6efef307bcb39fc5037903221
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Diffstat (limited to 'addons/web/static/lib')
| -rw-r--r-- | addons/web/static/lib/unhandled-rejection-polyfill/LICENSE | 21 | ||||
| -rw-r--r-- | addons/web/static/lib/unhandled-rejection-polyfill/unhandled-rejection-polyfill.js | 75 |
2 files changed, 0 insertions, 96 deletions
diff --git a/addons/web/static/lib/unhandled-rejection-polyfill/LICENSE b/addons/web/static/lib/unhandled-rejection-polyfill/LICENSE deleted file mode 100644 index 36fa4306167..00000000000 --- a/addons/web/static/lib/unhandled-rejection-polyfill/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2017 ustccjw - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/addons/web/static/lib/unhandled-rejection-polyfill/unhandled-rejection-polyfill.js b/addons/web/static/lib/unhandled-rejection-polyfill/unhandled-rejection-polyfill.js deleted file mode 100644 index 9422078ac37..00000000000 --- a/addons/web/static/lib/unhandled-rejection-polyfill/unhandled-rejection-polyfill.js +++ /dev/null @@ -1,75 +0,0 @@ -// based on https://github.com/ustccjw/unhandled-rejection-polyfill -(function () { -"use strict"; - -var self = window; -var OriginalPromise = self.Promise; - -function dispatchUnhandledRejectionEvent(promise, reason) { - var event = document.createEvent('Event'); - Object.defineProperties(event, { - promise: { - value: promise, - writable: false, - }, - reason: { - value: reason, - writable: false, - }, - }); - event.initEvent('unhandledrejection', false, true); - window.dispatchEvent(event); -} - -function MyPromise(resolver) { - if (!(this instanceof MyPromise)) { - throw new TypeError('Cannot call a class as a function'); - } - var promise = new OriginalPromise(function (resolve, reject) { - var customReject = function (reason) { - // macro-task (setTimeout) will execute after micro-task (promise) - setTimeout(function () { - if (promise.handled !== true) { - dispatchUnhandledRejectionEvent(promise, reason); - } - }, 0); - return reject(reason); - }; - try { - return resolver(resolve, customReject); - } catch (err) { - return customReject(err); - } - }); - promise.__proto__ = MyPromise.prototype; - return promise; -} - -MyPromise.__proto__ = OriginalPromise; -MyPromise.prototype.__proto__ = OriginalPromise.prototype; - - -MyPromise.prototype.then = function (resolve, reject) { - var self = this; - return OriginalPromise.prototype.then.call(this, resolve, reject && (function (reason) { - self.handled = true; - return reject(reason); - })); -}; - -MyPromise.prototype.catch = function (reject) { - var self = this; - return OriginalPromise.prototype.catch.call(this, reject && (function (reason) { - self.handled = true; - return reject(reason); - })); -}; - -MyPromise.polyfill = function () { - if (typeof PromiseRejectionEvent === 'undefined') { - window.Promise = MyPromise; - } -}; -MyPromise.polyfill(); - -})(); |
