File tree Expand file tree Collapse file tree 2 files changed +31
-16
lines changed
packages/base/src/sap/ui/webcomponents/base Expand file tree Collapse file tree 2 files changed +31
-16
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import whenDOMReady from "./util/whenDOMReady";
22import EventEnrichment from "./events/EventEnrichment" ;
33import { insertIconFontFace } from "./IconFonts" ;
44import DOMEventHandler from "./DOMEventHandler" ;
5+ import whenPolyfillLoaded from "./compatibility/whenPolyfillLoaded" ;
56
67EventEnrichment . run ( ) ;
78
@@ -14,22 +15,12 @@ const Bootstrap = {
1415 return bootPromise ;
1516 }
1617
17- bootPromise = new Promise ( resolve => {
18- whenDOMReady ( ) . then ( ( ) => {
19- insertIconFontFace ( ) ;
20- DOMEventHandler . start ( ) ;
21-
22- if ( window . WebComponents && window . WebComponents . waitFor ) {
23- // the polyfill loader is present
24- window . WebComponents . waitFor ( ( ) => {
25- // the polyfills are loaded, safe to execute code depending on their APIs
26- resolve ( ) ;
27- } ) ;
28- } else {
29- // polyfill loader missing, modern browsers only
30- resolve ( ) ;
31- }
32- } ) ;
18+ bootPromise = new Promise ( async resolve => {
19+ await whenDOMReady ( ) ;
20+ insertIconFontFace ( ) ;
21+ DOMEventHandler . start ( ) ;
22+ await whenPolyfillLoaded ( ) ;
23+ resolve ( ) ;
3324 } ) ;
3425
3526 return bootPromise ;
Original file line number Diff line number Diff line change 1+ let polyfillLoadedPromise ;
2+
3+ const whenPolyfillLoaded = ( ) => {
4+ if ( polyfillLoadedPromise ) {
5+ return polyfillLoadedPromise ;
6+ }
7+
8+ polyfillLoadedPromise = new Promise ( resolve => {
9+ if ( window . WebComponents && window . WebComponents . waitFor ) {
10+ // the polyfill loader is present
11+ window . WebComponents . waitFor ( ( ) => {
12+ // the polyfills are loaded, safe to execute code depending on their APIs
13+ resolve ( ) ;
14+ } ) ;
15+ } else {
16+ // polyfill loader missing, modern browsers only
17+ resolve ( ) ;
18+ }
19+ } ) ;
20+
21+ return polyfillLoadedPromise ;
22+ } ;
23+
24+ export default whenPolyfillLoaded ;
You can’t perform that action at this time.
0 commit comments