Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 3394a67

Browse files
committed
feat: async tag
1 parent 693d184 commit 3394a67

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/main.browser.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
2-
import {AppModule} from './app/app.module';
1+
import './polyfills.browser';
2+
3+
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
4+
import { AppModule } from './app/app.module';
35

46
export const platformRef = platformBrowserDynamic();
57

@@ -9,9 +11,12 @@ export function main() {
911
}
1012

1113
// support async tag or hmr
12-
if (document.readyState === 'complete') {
13-
main()
14-
} else {
15-
document.addEventListener('DOMContentLoaded', () => main());
14+
switch (document.readyState) {
15+
case 'interactive':
16+
case 'complete':
17+
main();
18+
break;
19+
case 'loading':
20+
default:
21+
document.addEventListener('DOMContentLoaded', () => main());
1622
}
17-

0 commit comments

Comments
 (0)