]> git.proxmox.com Git - mirror_novnc.git/blobdiff - vendor/browser-es-module-loader/src/browser-es-module-loader.js
Better currentScript fallback
[mirror_novnc.git] / vendor / browser-es-module-loader / src / browser-es-module-loader.js
index 4925702b5b194e6bb2064ddc780df19879ca22a3..5eff16765740c6c2c709a94a909d20410c1e9f22 100644 (file)
@@ -140,9 +140,16 @@ var WorkerPool = function (script, size) {
   var current = document.currentScript;
   // IE doesn't support currentScript
   if (!current) {
-    // We should be the last loaded script
+    // Find an entry with out basename
     var scripts = document.getElementsByTagName('script');
-    current = scripts[scripts.length - 1];
+    for (var i = 0; i < scripts.length; i++) {
+      if (scripts[i].src.indexOf("browser-es-module-loader.js") !== -1) {
+        current = scripts[i];
+        break;
+      }
+    }
+    if (!current)
+      throw Error("Could not find own <script> element");
   }
   script = current.src.substr(0, current.src.lastIndexOf("/")) + "/" + script;
   this._workers = new Array(size);