File tree Expand file tree Collapse file tree 1 file changed +23
-16
lines changed
Expand file tree Collapse file tree 1 file changed +23
-16
lines changed Original file line number Diff line number Diff line change @@ -700,7 +700,7 @@ async function fetchLiveViewScripts(frameDocument) {
700700
701701 } else {
702702
703- addScript ( frameDocument , false , script . src , script . type ) ;
703+ await addScript ( frameDocument , false , script . src , script . type ) ;
704704
705705 // delete original
706706 script . remove ( ) ;
@@ -723,23 +723,30 @@ async function fetchLiveViewScripts(frameDocument) {
723723
724724function addScript ( documentNode , code , src , type ) {
725725
726- const script = documentNode . createElement ( 'script' ) ;
727-
728- if ( type && type != '' ) script . type = type ;
729-
730- if ( code ) {
731-
732- script . appendChild ( documentNode . createTextNode ( code ) ) ;
733-
734- } else {
726+ return new Promise ( ( resolve ) => {
735727
736- script . src = src ;
737- script . defer = true ;
738- script . async = false ;
728+ const script = documentNode . createElement ( 'script' ) ;
729+
730+ if ( type && type != '' ) script . type = type ;
731+
732+ if ( code ) {
733+
734+ script . appendChild ( documentNode . createTextNode ( code ) ) ;
735+
736+ } else {
737+
738+ script . src = src ;
739+ script . defer = true ;
740+ script . async = false ;
741+
742+ script . onload = resolve ;
743+ script . onerror = resolve ;
744+
745+ }
746+
747+ documentNode . head . appendChild ( script ) ;
739748
740- }
741-
742- documentNode . head . appendChild ( script ) ;
749+ } ) ;
743750
744751}
745752
You can’t perform that action at this time.
0 commit comments