Skip to content

Commit b8ae60e

Browse files
authoredApr 7, 2020
fix(framework): CSS Vars in Static Styles work on IE11 (#1440)
The `createComponentStyleTag` method did not take into account Static Area CSS and did not inject it in the head. Instead, this CSS went to the `ui5-static-area-item` like on normal browsers. However, it wasn't processed there so CSS vars were not replaced. The fix: - Do not inject any CSS in `_updateFragment` for IE11 (if `shadyDOM` is `true`). - Inject the static area CSS along with the normal CSS in `createComponentStyleTag` instead, where it will be processed like the regular CSS - Finally, add a static getter for static area CSS in `UI5Element.js` to ensure it's always a string.
1 parent a4f502b commit b8ae60e

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed
 

‎packages/base/src/StaticAreaItem.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class StaticAreaItem {
2222
*/
2323
_updateFragment() {
2424
const renderResult = this.ui5ElementContext.constructor.staticAreaTemplate(this.ui5ElementContext),
25-
stylesToAdd = this.ui5ElementContext.constructor.staticAreaStyles || false;
25+
stylesToAdd = window.ShadyDOM ? false : this.ui5ElementContext.constructor.staticAreaStyles;
2626

2727
if (!this.staticAreaItemDomRef) {
2828
// Initial rendering of fragment

‎packages/base/src/UI5Element.js

+8
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,14 @@ class UI5Element extends HTMLElement {
820820
return "";
821821
}
822822

823+
/**
824+
* Returns the Static Area CSS for this UI5 Web Component Class
825+
* @protected
826+
*/
827+
static get staticAreaStyles() {
828+
return "";
829+
}
830+
823831
/**
824832
* Registers a UI5 Web Component in the browser window object
825833
* @public

‎packages/base/src/theming/createComponentStyleTag.js

+17
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ import { ponyfillNeeded, schedulePonyfill } from "./CSSVarsPonyfill.js";
55

66
const IEStyleSet = new Set();
77

8+
const getStaticStyle = ElementClass => {
9+
let componentStaticStyles = ElementClass.staticAreaStyles;
10+
if (Array.isArray(componentStaticStyles)) {
11+
componentStaticStyles = componentStaticStyles.join(" ");
12+
}
13+
14+
return componentStaticStyles;
15+
};
16+
817
/**
918
* Creates the needed CSS for a web component class in the head tag
1019
* Note: IE11, Edge
@@ -18,6 +27,14 @@ const createComponentStyleTag = ElementClass => {
1827

1928
let cssContent = getEffectiveStyle(ElementClass);
2029
cssContent = adaptCSSForIE(cssContent, tag);
30+
31+
// Append static CSS, if any, for IE
32+
let staticCssContent = getStaticStyle(ElementClass);
33+
if (staticCssContent) {
34+
staticCssContent = adaptCSSForIE(staticCssContent, "ui5-static-area-item");
35+
cssContent = `${cssContent} ${staticCssContent}`;
36+
}
37+
2138
createStyleInHead(cssContent, {
2239
"data-ui5-element-styles": tag,
2340
"disabled": "disabled",

0 commit comments

Comments
 (0)
Please sign in to comment.