Skip to content

Commit 4128216

Browse files
authored
feat(framework): Limited support for campact size on IE (#2230)
1 parent 67c4d69 commit 4128216

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

packages/base/src/UI5Element.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const GLOBAL_DIR_CSS_VAR = "--_ui5_dir";
4545
class UI5Element extends HTMLElement {
4646
constructor() {
4747
super();
48+
this._propertyChangeListeners = new Set();
4849
this._initializeState();
4950
this._upgradeAllProperties();
5051
this._initializeContainers();
@@ -59,7 +60,6 @@ class UI5Element extends HTMLElement {
5960
this._domRefReadyPromise._deferredResolve = deferredResolve;
6061

6162
this._monitoredChildProps = new Map();
62-
this._propertyChangeListeners = new Set();
6363
this._shouldInvalidateParent = false;
6464
}
6565

packages/base/src/theming/CSSVarsPonyfill.js

+24
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const runPonyfill = () => {
77

88
window.CSSVarsPonyfill.cssVars({
99
rootElement: document.head,
10+
variables: isCompact() ? getCompactModeVars() : {},
1011
silent: true,
1112
});
1213
};
@@ -17,6 +18,29 @@ const schedulePonyfill = () => {
1718
}
1819
};
1920

21+
const isCompact = () => {
22+
const b = document.body;
23+
return b.hasAttribute("data-ui5-compact-size") || b.classList.contains("ui5-content-density-compact") || b.classList.contains("sapUiSizeCompact");
24+
};
25+
26+
const getCompactModeVars = () => {
27+
const compactVars = {};
28+
[...document.querySelectorAll(`[data-ui5-theme-properties]`)].forEach(el => {
29+
const cssContent = el.textContent.replace("\n", "");
30+
let match;
31+
const regExp = new RegExp("data-ui5-compact-size[^{]*{(.*?)}", "g");
32+
while ((match = regExp.exec(cssContent)) !== null) { // eslint-disable-line
33+
const compactCSS = match[1];
34+
compactCSS.split(";").forEach(declaration => {
35+
const pair = declaration.split(":");
36+
compactVars[pair[0].trim()] = pair[1].trim();
37+
});
38+
}
39+
});
40+
41+
return compactVars;
42+
};
43+
2044
export {
2145
ponyfillNeeded,
2246
runPonyfill,

0 commit comments

Comments
 (0)