mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 16:26:43 +00:00
Inject ElementInternals polyfill where needed (#20818)
This commit is contained in:
parent
7d2cee650d
commit
e0062cf190
@ -2,6 +2,18 @@ import defineProvider from "@babel/helper-define-polyfill-provider";
|
|||||||
|
|
||||||
// List of polyfill keys with supported browser targets for the functionality
|
// List of polyfill keys with supported browser targets for the functionality
|
||||||
const PolyfillSupport = {
|
const PolyfillSupport = {
|
||||||
|
// Note states and shadowRoot properties should be supported.
|
||||||
|
"element-internals": {
|
||||||
|
android: 90,
|
||||||
|
chrome: 90,
|
||||||
|
edge: 90,
|
||||||
|
firefox: 126,
|
||||||
|
ios: 17.4,
|
||||||
|
opera: 76,
|
||||||
|
opera_mobile: 64,
|
||||||
|
safari: 17.4,
|
||||||
|
samsung: 15.0,
|
||||||
|
},
|
||||||
fetch: {
|
fetch: {
|
||||||
android: 42,
|
android: 42,
|
||||||
chrome: 42,
|
chrome: 42,
|
||||||
@ -33,7 +45,12 @@ const polyfillMap = {
|
|||||||
Proxy: { key: "proxy", module: "proxy-polyfill" },
|
Proxy: { key: "proxy", module: "proxy-polyfill" },
|
||||||
fetch: { key: "fetch", module: "unfetch/polyfill" },
|
fetch: { key: "fetch", module: "unfetch/polyfill" },
|
||||||
},
|
},
|
||||||
instance: {},
|
instance: {
|
||||||
|
attachInternals: {
|
||||||
|
key: "element-internals",
|
||||||
|
module: "element-internals-polyfill",
|
||||||
|
},
|
||||||
|
},
|
||||||
static: {},
|
static: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -49,7 +66,9 @@ export default defineProvider(
|
|||||||
if (polyfill && shouldInjectPolyfill(polyfill.desc.key)) {
|
if (polyfill && shouldInjectPolyfill(polyfill.desc.key)) {
|
||||||
debug(polyfill.desc.key);
|
debug(polyfill.desc.key);
|
||||||
utils.injectGlobalImport(polyfill.desc.module);
|
utils.injectGlobalImport(polyfill.desc.module);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,12 @@ module.exports.babelOptions = ({ latestBuild, isProdBuild, isTestBuild }) => ({
|
|||||||
{ method: "usage-global" },
|
{ method: "usage-global" },
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
exclude: /\/node_modules\/(?:unfetch|proxy-polyfill)\//,
|
exclude: [
|
||||||
|
"@webcomponents/scoped-custom-element-registry",
|
||||||
|
"element-internals-polyfill",
|
||||||
|
"proxy-polyfill",
|
||||||
|
"unfetch",
|
||||||
|
].map((p) => new RegExp(`/node_modules/${p}/`)),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Use unambiguous for dependencies so that require() is correctly injected into CommonJS files
|
// Use unambiguous for dependencies so that require() is correctly injected into CommonJS files
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import "element-internals-polyfill";
|
|
||||||
import { MdAssistChip } from "@material/web/chips/assist-chip";
|
import { MdAssistChip } from "@material/web/chips/assist-chip";
|
||||||
import { css, html } from "lit";
|
import { css, html } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import "element-internals-polyfill";
|
|
||||||
import { MdChipSet } from "@material/web/chips/chip-set";
|
import { MdChipSet } from "@material/web/chips/chip-set";
|
||||||
import { customElement } from "lit/decorators";
|
import { customElement } from "lit/decorators";
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import "element-internals-polyfill";
|
|
||||||
import { MdFilterChip } from "@material/web/chips/filter-chip";
|
import { MdFilterChip } from "@material/web/chips/filter-chip";
|
||||||
import { css, html } from "lit";
|
import { css, html } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import "element-internals-polyfill";
|
|
||||||
import { MdInputChip } from "@material/web/chips/input-chip";
|
import { MdInputChip } from "@material/web/chips/input-chip";
|
||||||
import { css } from "lit";
|
import { css } from "lit";
|
||||||
import { customElement } from "lit/decorators";
|
import { customElement } from "lit/decorators";
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import "element-internals-polyfill";
|
|
||||||
import { MdCircularProgress } from "@material/web/progress/circular-progress";
|
import { MdCircularProgress } from "@material/web/progress/circular-progress";
|
||||||
import { PropertyValues, css } from "lit";
|
import { PropertyValues, css } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { customElement } from "lit/decorators";
|
|
||||||
import "element-internals-polyfill";
|
|
||||||
import { MdListItem } from "@material/web/list/list-item";
|
import { MdListItem } from "@material/web/list/list-item";
|
||||||
import { css } from "lit";
|
import { css } from "lit";
|
||||||
|
import { customElement } from "lit/decorators";
|
||||||
|
|
||||||
@customElement("ha-list-item-new")
|
@customElement("ha-list-item-new")
|
||||||
export class HaListItemNew extends MdListItem {
|
export class HaListItemNew extends MdListItem {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { customElement } from "lit/decorators";
|
|
||||||
import "element-internals-polyfill";
|
|
||||||
import { MdList } from "@material/web/list/list";
|
import { MdList } from "@material/web/list/list";
|
||||||
import { css } from "lit";
|
import { css } from "lit";
|
||||||
|
import { customElement } from "lit/decorators";
|
||||||
|
|
||||||
@customElement("ha-list-new")
|
@customElement("ha-list-new")
|
||||||
export class HaListNew extends MdList {
|
export class HaListNew extends MdList {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { MdMenuItem } from "@material/web/menu/menu-item";
|
import { MdMenuItem } from "@material/web/menu/menu-item";
|
||||||
import "element-internals-polyfill";
|
|
||||||
import { css } from "lit";
|
import { css } from "lit";
|
||||||
import { customElement } from "lit/decorators";
|
import { customElement } from "lit/decorators";
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { customElement } from "lit/decorators";
|
|
||||||
import "element-internals-polyfill";
|
|
||||||
import { css } from "lit";
|
|
||||||
import { MdMenu } from "@material/web/menu/menu";
|
import { MdMenu } from "@material/web/menu/menu";
|
||||||
|
import { css } from "lit";
|
||||||
|
import { customElement } from "lit/decorators";
|
||||||
|
|
||||||
@customElement("ha-menu")
|
@customElement("ha-menu")
|
||||||
export class HaMenu extends MdMenu {
|
export class HaMenu extends MdMenu {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
|
import { MdOutlinedButton } from "@material/web/button/outlined-button";
|
||||||
import { css } from "lit";
|
import { css } from "lit";
|
||||||
import { customElement } from "lit/decorators";
|
import { customElement } from "lit/decorators";
|
||||||
import "element-internals-polyfill";
|
|
||||||
import { MdOutlinedButton } from "@material/web/button/outlined-button";
|
|
||||||
|
|
||||||
@customElement("ha-outlined-button")
|
@customElement("ha-outlined-button")
|
||||||
export class HaOutlinedButton extends MdOutlinedButton {
|
export class HaOutlinedButton extends MdOutlinedButton {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { MdOutlinedField } from "@material/web/field/outlined-field";
|
import { MdOutlinedField } from "@material/web/field/outlined-field";
|
||||||
import "element-internals-polyfill";
|
|
||||||
import { css } from "lit";
|
import { css } from "lit";
|
||||||
import { customElement } from "lit/decorators";
|
import { customElement } from "lit/decorators";
|
||||||
import { literal } from "lit/static-html";
|
import { literal } from "lit/static-html";
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
|
import { MdOutlinedIconButton } from "@material/web/iconbutton/outlined-icon-button";
|
||||||
import { css } from "lit";
|
import { css } from "lit";
|
||||||
import { customElement } from "lit/decorators";
|
import { customElement } from "lit/decorators";
|
||||||
import "element-internals-polyfill";
|
|
||||||
import { MdOutlinedIconButton } from "@material/web/iconbutton/outlined-icon-button";
|
|
||||||
|
|
||||||
@customElement("ha-outlined-icon-button")
|
@customElement("ha-outlined-icon-button")
|
||||||
export class HaOutlinedIconButton extends MdOutlinedIconButton {
|
export class HaOutlinedIconButton extends MdOutlinedIconButton {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { MdOutlinedTextField } from "@material/web/textfield/outlined-text-field";
|
import { MdOutlinedTextField } from "@material/web/textfield/outlined-text-field";
|
||||||
import "element-internals-polyfill";
|
|
||||||
import { css } from "lit";
|
import { css } from "lit";
|
||||||
import { customElement } from "lit/decorators";
|
import { customElement } from "lit/decorators";
|
||||||
import { literal } from "lit/static-html";
|
import { literal } from "lit/static-html";
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { AttachableController } from "@material/web/internal/controller/attachable-controller";
|
import { AttachableController } from "@material/web/internal/controller/attachable-controller";
|
||||||
import { MdRipple } from "@material/web/ripple/ripple";
|
import { MdRipple } from "@material/web/ripple/ripple";
|
||||||
import "element-internals-polyfill";
|
|
||||||
import { css } from "lit";
|
import { css } from "lit";
|
||||||
import { customElement } from "lit/decorators";
|
import { customElement } from "lit/decorators";
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { customElement } from "lit/decorators";
|
|
||||||
import "element-internals-polyfill";
|
|
||||||
import { MdSlider } from "@material/web/slider/slider";
|
import { MdSlider } from "@material/web/slider/slider";
|
||||||
import { css } from "lit";
|
import { css } from "lit";
|
||||||
|
import { customElement } from "lit/decorators";
|
||||||
import { mainWindow } from "../common/dom/get_main_window";
|
import { mainWindow } from "../common/dom/get_main_window";
|
||||||
|
|
||||||
@customElement("ha-slider")
|
@customElement("ha-slider")
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { customElement } from "lit/decorators";
|
|
||||||
import "element-internals-polyfill";
|
|
||||||
import { css } from "lit";
|
|
||||||
import { MdSubMenu } from "@material/web/menu/sub-menu";
|
import { MdSubMenu } from "@material/web/menu/sub-menu";
|
||||||
|
import { css } from "lit";
|
||||||
|
import { customElement } from "lit/decorators";
|
||||||
|
|
||||||
@customElement("ha-sub-menu")
|
@customElement("ha-sub-menu")
|
||||||
export class HaSubMenu extends MdSubMenu {
|
export class HaSubMenu extends MdSubMenu {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user