@@ -2,6 +2,7 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
2
2
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js" ;
3
3
import { getRTL } from "@ui5/webcomponents-base/dist/config/RTL.js" ;
4
4
import { getIconData } from "@ui5/webcomponents-base/dist/SVGIconRegistry.js" ;
5
+ import createStyleInHead from "@ui5/webcomponents-base/dist/util/createStyleInHead.js" ;
5
6
import { fetchResourceBundle , getResourceBundle } from "@ui5/webcomponents-base/dist/ResourceBundle.js" ;
6
7
import IconTemplate from "./generated/templates/IconTemplate.lit.js" ;
7
8
@@ -111,11 +112,22 @@ class Icon extends UI5Element {
111
112
}
112
113
113
114
static async define ( ...params ) {
115
+ this . createGlobalStyle ( ) ;
114
116
await fetchResourceBundle ( "@ui5/webcomponents" ) ;
115
117
116
118
super . define ( ...params ) ;
117
119
}
118
120
121
+ static createGlobalStyle ( ) {
122
+ if ( ! window . ShadyDOM ) {
123
+ return ;
124
+ }
125
+ const styleElement = document . head . querySelector ( `style[data-ui5-icon-global]` ) ;
126
+ if ( ! styleElement ) {
127
+ createStyleInHead ( `ui5-icon:not([data-ui5-defined]) { display: none !important; }` , { "data-ui5-icon-global" : "" } ) ;
128
+ }
129
+ }
130
+
119
131
_normalizeIconURI ( iconURI ) {
120
132
return this . _hasIconPrefix ( iconURI ) ? iconURI : `sap-icon://${ iconURI } ` ;
121
133
}
@@ -148,6 +160,13 @@ class Icon extends UI5Element {
148
160
get dir ( ) {
149
161
return getRTL ( ) ? "rtl" : "ltr" ;
150
162
}
163
+
164
+ onEnterDOM ( ) {
165
+ if ( ! window . ShadyDOM ) {
166
+ return ;
167
+ }
168
+ this . setAttribute ( "data-ui5-defined" , "" ) ;
169
+ }
151
170
}
152
171
153
172
Icon . define ( ) ;
0 commit comments