File tree 2 files changed +25
-1
lines changed
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ const GLOBAL_DIR_CSS_VAR = "--_ui5_dir";
45
45
class UI5Element extends HTMLElement {
46
46
constructor ( ) {
47
47
super ( ) ;
48
+ this . _propertyChangeListeners = new Set ( ) ;
48
49
this . _initializeState ( ) ;
49
50
this . _upgradeAllProperties ( ) ;
50
51
this . _initializeContainers ( ) ;
@@ -59,7 +60,6 @@ class UI5Element extends HTMLElement {
59
60
this . _domRefReadyPromise . _deferredResolve = deferredResolve ;
60
61
61
62
this . _monitoredChildProps = new Map ( ) ;
62
- this . _propertyChangeListeners = new Set ( ) ;
63
63
this . _shouldInvalidateParent = false ;
64
64
}
65
65
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ const runPonyfill = () => {
7
7
8
8
window . CSSVarsPonyfill . cssVars ( {
9
9
rootElement : document . head ,
10
+ variables : isCompact ( ) ? getCompactModeVars ( ) : { } ,
10
11
silent : true ,
11
12
} ) ;
12
13
} ;
@@ -17,6 +18,29 @@ const schedulePonyfill = () => {
17
18
}
18
19
} ;
19
20
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
+
20
44
export {
21
45
ponyfillNeeded ,
22
46
runPonyfill ,
You can’t perform that action at this time.
0 commit comments