File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change 1
- for ( const template of document . getElementsByTagName ( 'template' ) ) {
2
- fetch ( template . getAttribute ( 'src' ) )
3
- . then ( file => file . text ( ) )
4
- . then ( content => {
5
- const html = document . createElement ( 'html' )
6
- html . innerHTML = content
7
- document . head . innerHTML += html . getElementsByTagName ( 'head' ) [ 0 ] . innerHTML
8
- template . insertAdjacentHTML ( 'afterend' , html . getElementsByTagName ( 'body' ) [ 0 ] . innerHTML )
9
- template . remove ( ) ;
10
- } ) ;
1
+ const templates = [ ]
2
+
3
+ for ( const template of document . getElementsByTagName ( 'include' ) ) {
4
+ templates . push ( template )
5
+ await fetch ( template . getAttribute ( 'src' ) )
6
+ . then ( file => file . text ( ) )
7
+ . then ( content => {
8
+ const html = document . createElement ( 'html' )
9
+ html . innerHTML = content
10
+ document . head . innerHTML += html . getElementsByTagName ( 'head' ) [ 0 ] . innerHTML
11
+ template . insertAdjacentHTML ( 'afterend' , html . getElementsByTagName ( 'body' ) [ 0 ] . innerHTML )
12
+ } ) ;
11
13
}
14
+
15
+ templates . forEach ( template => template . remove ( ) )
You can’t perform that action at this time.
0 commit comments