Skip to content

Commit

Permalink
fix: icon no longer flickers on IE (#722)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladitasev committed Aug 9, 2019
1 parent 52517c4 commit 964af67
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/main/src/Icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import { getRTL } from "@ui5/webcomponents-base/dist/config/RTL.js";
import { getIconData } from "@ui5/webcomponents-base/dist/SVGIconRegistry.js";
import createStyleInHead from "@ui5/webcomponents-base/dist/util/createStyleInHead.js";
import { fetchResourceBundle, getResourceBundle } from "@ui5/webcomponents-base/dist/ResourceBundle.js";
import IconTemplate from "./generated/templates/IconTemplate.lit.js";

Expand Down Expand Up @@ -111,11 +112,22 @@ class Icon extends UI5Element {
}

static async define(...params) {
this.createGlobalStyle();
await fetchResourceBundle("@ui5/webcomponents");

super.define(...params);
}

static createGlobalStyle() {
if (!window.ShadyDOM) {
return;
}
const styleElement = document.head.querySelector(`style[data-ui5-icon-global]`);
if (!styleElement) {
createStyleInHead(`ui5-icon:not([data-ui5-defined]) { display: none !important; }`, { "data-ui5-icon-global": "" });
}
}

_normalizeIconURI(iconURI) {
return this._hasIconPrefix(iconURI) ? iconURI : `sap-icon://${iconURI}`;
}
Expand Down Expand Up @@ -148,6 +160,13 @@ class Icon extends UI5Element {
get dir() {
return getRTL() ? "rtl" : "ltr";
}

onEnterDOM() {
if (!window.ShadyDOM) {
return;
}
this.setAttribute("data-ui5-defined", "");
}
}

Icon.define();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<body>

<ui5-button>ivan</ui5-button>
<ui5-icon src="sap-icon://add"></ui5-icon>

</body>
</html>

0 comments on commit 964af67

Please sign in to comment.