[fusion-commits] r3042 - sandbox/cms_refactor/lib

svn_fusion at osgeo.org svn_fusion at osgeo.org
Thu Aug 2 04:36:37 PDT 2018


Author: jng
Date: 2018-08-02 04:36:37 -0700 (Thu, 02 Aug 2018)
New Revision: 3042

Modified:
   sandbox/cms_refactor/lib/fusion.js
Log:
Chrome is saying that using document.write to append script tags is unsafe. So in dev/debug mode where the core scripts have to be loaded first, we'll do it how we do it for individual widget scripts in non-production builds: Create the actual script DOM elements and append them to the head.

An important thing we need to do here unlike regular script tag appending is that these have to be loaded in sequence so (async = false).

Modified: sandbox/cms_refactor/lib/fusion.js
===================================================================
--- sandbox/cms_refactor/lib/fusion.js	2018-07-30 16:49:54 UTC (rev 3041)
+++ sandbox/cms_refactor/lib/fusion.js	2018-08-02 11:36:37 UTC (rev 3042)
@@ -1621,13 +1621,18 @@
             coreScripts.push('lib/OpenLayers/Lang/'+locale+'.js');
             coreScripts.push('text/'+locale+'.json');
         }
-        
-        var allScriptTags = new Array(coreScripts.length);
+
         for (var i = 0; i < coreScripts.length; i++) {
-            allScriptTags[i] = "<script src='" + host + coreScripts[i] +
-                                   "'></script>"; 
+            var script = document.createElement('script');
+            script.defer = false;
+            //Must load sequentially here as downstream scripts in this list rely on the previous scripts being
+            //loaded first
+            script.async = false;
+            script.type = "text/javascript";
+            script.id = coreScripts[i];
+            script.src = host + coreScripts[i];
+            document.getElementsByTagName('head')[0].appendChild(script);
         }
-        document.write(allScriptTags.join(""));
     }
     
     /*********************************************************************************/



More information about the fusion-commits mailing list