mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 02:36:37 +00:00
Move globalThis polyfill to compatibility, add more compatibility (#16386)
This commit is contained in:
parent
060f6ce3d8
commit
8695bbc490
@ -84,9 +84,6 @@
|
|||||||
<%= renderTemplate("../../../src/html/_js_base.html.template") %>
|
<%= renderTemplate("../../../src/html/_js_base.html.template") %>
|
||||||
<%= renderTemplate("../../../src/html/_preload_roboto.html.template") %>
|
<%= renderTemplate("../../../src/html/_preload_roboto.html.template") %>
|
||||||
<script>
|
<script>
|
||||||
if (!window.globalThis) {
|
|
||||||
window.globalThis = window;
|
|
||||||
}
|
|
||||||
// Safari 12 and below does not have a compliant ES2015 implementation of template literals, so we ship ES5
|
// Safari 12 and below does not have a compliant ES2015 implementation of template literals, so we ship ES5
|
||||||
if (!isS11_12) {
|
if (!isS11_12) {
|
||||||
<% for (const entry of latestEntryJS) { %>
|
<% for (const entry of latestEntryJS) { %>
|
||||||
|
@ -88,8 +88,8 @@ export class HaIcon extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!MDI_PREFIXES.includes(iconPrefix)) {
|
if (!MDI_PREFIXES.includes(iconPrefix)) {
|
||||||
if (iconPrefix in customIcons) {
|
const customIcon = customIcons[iconPrefix];
|
||||||
const customIcon = customIcons[iconPrefix];
|
if (customIcon) {
|
||||||
if (customIcon && typeof customIcon.getIcon === "function") {
|
if (customIcon && typeof customIcon.getIcon === "function") {
|
||||||
this._setCustomPath(customIcon.getIcon(iconName), requestedIcon);
|
this._setCustomPath(customIcon.getIcon(iconName), requestedIcon);
|
||||||
}
|
}
|
||||||
|
@ -36,5 +36,4 @@ export const customIcons = new Proxy(customIconsWindow.customIcons!, {
|
|||||||
getIcon: customIconsets[prop],
|
getIcon: customIconsets[prop],
|
||||||
}
|
}
|
||||||
: undefined),
|
: undefined),
|
||||||
has: (obj, prop: string) => prop in obj || prop in customIconsets,
|
|
||||||
});
|
});
|
||||||
|
@ -94,7 +94,7 @@ const connProm = async (auth) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (__DEV__) {
|
if (__DEV__ && "performance" in window) {
|
||||||
// Remove adoptedStyleSheets so style inspector works on shadow DOM.
|
// Remove adoptedStyleSheets so style inspector works on shadow DOM.
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
delete Document.prototype.adoptedStyleSheets;
|
delete Document.prototype.adoptedStyleSheets;
|
||||||
|
@ -41,9 +41,6 @@
|
|||||||
<%= renderTemplate("_js_base.html.template") %>
|
<%= renderTemplate("_js_base.html.template") %>
|
||||||
<%= renderTemplate("_preload_roboto.html.template") %>
|
<%= renderTemplate("_preload_roboto.html.template") %>
|
||||||
<script crossorigin="use-credentials">
|
<script crossorigin="use-credentials">
|
||||||
if (!window.globalThis) {
|
|
||||||
window.globalThis = window;
|
|
||||||
}
|
|
||||||
// Safari 12 and below does not have a compliant ES2015 implementation of template literals, so we ship ES5
|
// Safari 12 and below does not have a compliant ES2015 implementation of template literals, so we ship ES5
|
||||||
if (!isS11_12) {
|
if (!isS11_12) {
|
||||||
<% for (const entry of latestEntryJS) { %>
|
<% for (const entry of latestEntryJS) { %>
|
||||||
|
@ -84,9 +84,6 @@
|
|||||||
<%= renderTemplate("_js_base.html.template") %>
|
<%= renderTemplate("_js_base.html.template") %>
|
||||||
<%= renderTemplate("_preload_roboto.html.template") %>
|
<%= renderTemplate("_preload_roboto.html.template") %>
|
||||||
<script <% if (!useWDS) { %>crossorigin="use-credentials"<% } %>>
|
<script <% if (!useWDS) { %>crossorigin="use-credentials"<% } %>>
|
||||||
if (!window.globalThis) {
|
|
||||||
window.globalThis = window;
|
|
||||||
}
|
|
||||||
// Safari 12 and below does not have a compliant ES2015 implementation of template literals, so we ship ES5
|
// Safari 12 and below does not have a compliant ES2015 implementation of template literals, so we ship ES5
|
||||||
if (!isS11_12) {
|
if (!isS11_12) {
|
||||||
<% for (const entry of latestEntryJS) { %>
|
<% for (const entry of latestEntryJS) { %>
|
||||||
|
@ -71,9 +71,6 @@
|
|||||||
<%= renderTemplate("_js_base.html.template") %>
|
<%= renderTemplate("_js_base.html.template") %>
|
||||||
<%= renderTemplate("_preload_roboto.html.template") %>
|
<%= renderTemplate("_preload_roboto.html.template") %>
|
||||||
<script crossorigin="use-credentials">
|
<script crossorigin="use-credentials">
|
||||||
if (!window.globalThis) {
|
|
||||||
window.globalThis = window;
|
|
||||||
}
|
|
||||||
// Safari 12 and below does not have a compliant ES2015 implementation of template literals, so we ship ES5
|
// Safari 12 and below does not have a compliant ES2015 implementation of template literals, so we ship ES5
|
||||||
if (!isS11_12) {
|
if (!isS11_12) {
|
||||||
<% for (const entry of latestEntryJS) { %>
|
<% for (const entry of latestEntryJS) { %>
|
||||||
|
@ -66,3 +66,27 @@ if (Element.prototype.getAttributeNames === undefined) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Source: https://gist.github.com/rebelchris/365f26f95d7e9f432f64f21886d9b9ef
|
||||||
|
if (!Element.prototype.toggleAttribute) {
|
||||||
|
Element.prototype.toggleAttribute = function (name, force) {
|
||||||
|
if (force !== undefined) {
|
||||||
|
force = !!force;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.hasAttribute(name)) {
|
||||||
|
if (force) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.removeAttribute(name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (force === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setAttribute(name, "");
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user