|
122 | 122 | (set! (.-isProvided_ js/goog) (fn [name] false))
|
123 | 123 | (set! (.-writeScriptTag__ js/goog)
|
124 | 124 | (fn [src opt_sourceText]
|
| 125 | + ;; the page is already loaded, we can no longer leverage document.write |
| 126 | + ;; instead construct script tag elements and append them to the body |
| 127 | + ;; of the page, to avoid parallel script loading enforce sequential |
| 128 | + ;; load with a simple load queue |
125 | 129 | (let [loaded (atom false)
|
126 | 130 | onload (fn []
|
127 | 131 | (when (and load-queue (false? @loaded))
|
|
130 | 134 | (set! load-queue nil)
|
131 | 135 | (.apply js/goog.writeScriptTag__ nil (.shift load-queue)))))]
|
132 | 136 | (.appendChild js/document.body
|
133 |
| - (as-> (.createElement js/document "script") script |
134 |
| - (doto script |
135 |
| - (aset "type" "text/javascript") |
136 |
| - (aset "onload" onload) |
137 |
| - (aset "onreadystatechange" onload)) |
138 |
| - (if (nil? opt_sourceText) |
139 |
| - (doto script (aset "src" src)) |
140 |
| - (doto script (gdom/setTextContext opt_sourceText)))))))) |
| 137 | + (as-> (.createElement js/document "script") script |
| 138 | + (doto script |
| 139 | + (aset "type" "text/javascript") |
| 140 | + (aset "onload" onload) |
| 141 | + (aset "onreadystatechange" onload)) ;; IE |
| 142 | + (if (nil? opt_sourceText) |
| 143 | + (doto script (aset "src" src)) |
| 144 | + (doto script (gdom/setTextContext opt_sourceText)))))))) |
| 145 | + ;; queue or load |
141 | 146 | (set! (.-writeScriptTag_ js/goog)
|
142 | 147 | (fn [src opt_sourceText]
|
143 | 148 | (if load-queue
|
144 | 149 | (.push load-queue #js [src opt_sourceText])
|
145 | 150 | (do
|
146 | 151 | (set! load-queue #js [])
|
147 | 152 | (js/goog.writeScriptTag__ src opt_sourceText)))))
|
| 153 | + ;; we must reuse Closure library dev time dependency management, under namespace |
| 154 | + ;; reload scenarios we simply delete entries from the correct private locations |
148 | 155 | (set! (.-require js/goog)
|
149 | 156 | (fn [src reload]
|
150 | 157 | (when (= reload "reload-all")
|
|
0 commit comments