From 0ce486ce9d04dff6d7275e0acea7a4b6885558ee Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Tue, 9 Mar 2021 12:53:51 +0100 Subject: [PATCH] MOBILE-3720 env: Add missing polyfills --- package-lock.json | 19 ++++++++++++------- package.json | 1 + src/polyfills.ts | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index e125e9746..7e9ee4e69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -139,6 +139,12 @@ "uri-js": "^4.2.2" } }, + "core-js": { + "version": "3.6.4", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.4.tgz", + "integrity": "sha512-4paDGScNgZP2IXXilaffL9X7968RuvwlkK3xWtZRVqgd8SYNiVKRJvkFd1aqqEuPfN7E68ZHEp9hDj6lHj4Hyw==", + "dev": true + }, "open": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/open/-/open-7.0.4.tgz", @@ -5873,9 +5879,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001144", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001144.tgz", - "integrity": "sha512-4GQTEWNMnVZVOFG3BK0xvGeaDAtiPAbG2N8yuMXuXzx/c2Vd4XoMPO8+E918zeXn5IF0FRVtGShBfkfQea2wHQ==", + "version": "1.0.30001197", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001197.tgz", + "integrity": "sha512-8aE+sqBqtXz4G8g35Eg/XEaFr2N7rd/VQ6eABGBmNtcB8cN6qNJhMi6oSFy4UWWZgqgL3filHT8Nha4meu3tsw==", "dev": true }, "canonical-path": { @@ -7890,10 +7896,9 @@ } }, "core-js": { - "version": "3.6.4", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.4.tgz", - "integrity": "sha512-4paDGScNgZP2IXXilaffL9X7968RuvwlkK3xWtZRVqgd8SYNiVKRJvkFd1aqqEuPfN7E68ZHEp9hDj6lHj4Hyw==", - "dev": true + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.9.1.tgz", + "integrity": "sha512-gSjRvzkxQc1zjM/5paAmL4idJBFzuJoo+jDjF1tStYFMV2ERfD02HhahhCGXUyHxQRG4yFKVSdO6g62eoRMcDg==" }, "core-js-compat": { "version": "3.6.5", diff --git a/package.json b/package.json index 74dbc309a..a4b3d2811 100644 --- a/package.json +++ b/package.json @@ -107,6 +107,7 @@ "cordova-sqlite-storage": "^4.0.0", "cordova-support-google-services": "^1.2.1", "cordova.plugins.diagnostic": "^5.0.2", + "core-js": "^3.9.1", "es6-promise-plugin": "^4.2.2", "jszip": "^3.5.0", "moment": "^2.29.0", diff --git a/src/polyfills.ts b/src/polyfills.ts index 584ee02e7..cf90936b0 100644 --- a/src/polyfills.ts +++ b/src/polyfills.ts @@ -17,3 +17,42 @@ window.__Zone_disable_customElements = true; // Zone JS is required by default for Angular itself. import 'zone.js/dist/zone'; + +// Platform polyfills +import 'core-js/es/array/includes'; +import 'core-js/es/promise/finally'; +import 'core-js/es/string/match-all'; +import 'core-js/es/string/trim-right'; + +polyfillEventComposedPath(); + +/** + * Polyfill Event.composedPath() if necessary. + * + * @see https://github.com/ionic-team/stencil/issues/2681 + */ +function polyfillEventComposedPath() { + const event = new Event('') as { path?: NodeList }; + + if (!('path' in event && event.path instanceof NodeList)) { + return; + } + + Event.prototype.composedPath = function () { + if (this._composedPath) { + return this._composedPath; + } + + let node = this.target; + + for (this._composedPath = []; node.parentNode !== null;) { + this._composedPath.push(node); + + node = node.parentNode; + } + + this._composedPath.push(document, window); + + return this._composedPath; + }; +}