Polyfill globalThis in latest build (#9352)

This commit is contained in:
Bram Kragten 2021-06-03 22:50:33 +02:00 committed by GitHub
parent 8836ba6ceb
commit 5418474f64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 3 deletions

View File

@ -48,6 +48,9 @@
window.providersPromise = fetch("/auth/providers", {
credentials: "same-origin",
});
if (!window.globalThis) {
window.globalThis = window;
}
</script>
<script>

View File

@ -71,6 +71,9 @@
import("<%= latestAppJS %>");
window.customPanelJS = "<%= latestCustomPanelJS %>";
window.latestJS = true;
if (!window.globalThis) {
window.globalThis = window;
}
</script>
<script>
{% for extra_module in extra_modules -%}

View File

@ -80,6 +80,9 @@
window.stepsPromise = fetch("/api/onboarding", {
credentials: "same-origin",
});
if (!window.globalThis) {
window.globalThis = window;
}
</script>
<script>

View File

@ -1,10 +1,10 @@
// For localize
import "@formatjs/intl-getcanonicallocales/polyfill";
import "lit/polyfill-support";
import "core-js";
import "regenerator-runtime/runtime";
import "lit/polyfill-support";
import "@formatjs/intl-getcanonicallocales/polyfill";
// To use comlink under ES5
import "proxy-polyfill";
import "regenerator-runtime/runtime";
import "unfetch/polyfill";
// Source: https://github.com/jserz/js_piece/blob/master/DOM/ParentNode/append()/append().md
@ -32,3 +32,16 @@ import "unfetch/polyfill";
});
});
})([Element.prototype, Document.prototype, DocumentFragment.prototype]);
// Source: https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNames
if (Element.prototype.getAttributeNames === undefined) {
Element.prototype.getAttributeNames = function () {
const attributes = this.attributes;
const length = attributes.length;
const result = new Array(length);
for (let i = 0; i < length; i++) {
result[i] = attributes[i].name;
}
return result;
};
}