Revision: 9696
Author: [email protected]
Date: Tue Feb  8 09:31:49 2011
Log: Get rid of document.write option since it can break in some edge cases and isn't actually necessary. I believe that I originally thought it was needed because I was appending to the body rather than the head and therefore seeing some cases where this broke. However, I believe that this is safe because the nocache.js
will be requested from either:

A - the document body - In this case, the head tag should be completely loaded B - the document head - In this case, the script tag should always be a direct descendant of the head tag, and it should be allowed to modify it's immediate
parent, even if the parent is not full loaded

http://code.google.com/p/google-web-toolkit/source/detail?r=9696

Modified:
/trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/installScriptEarlyDownload.js /trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/loadExternalStylesheets.js

=======================================
--- /trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/installScriptEarlyDownload.js Tue Nov 16 10:12:20 2010 +++ /trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/installScriptEarlyDownload.js Tue Feb 8 09:31:49 2011
@@ -29,17 +29,7 @@
     });
   };
   sendStats('moduleStartup', 'moduleRequested');
-  if (isBodyLoaded()) {
- // if the body is loaded, then the tag to download the script can be added
-    // in a non-destructive manner
-    var script = $doc.createElement('script');
-    script.src = filename;
-    $doc.getElementsByTagName('head')[0].appendChild(script);
-  } else {
-    // if the doc has not yet loaded, go ahead and do a destructive
-    // document.write since we want to immediately start the download.
- // Note that we cannot append an element to the doc if it is still loading
-    // since this would cause problems in IE.
-    $doc.write("<script src='" + filename + "'></scr" + "ipt>");
-  }
-}
+  var script = $doc.createElement('script');
+  script.src = filename;
+  $doc.getElementsByTagName('head')[0].appendChild(script);
+}
=======================================
--- /trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/loadExternalStylesheets.js Wed Oct 27 13:37:45 2010 +++ /trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/loadExternalStylesheets.js Tue Feb 8 09:31:49 2011
@@ -6,14 +6,10 @@

   function installOneStylesheet(stylesheetUrl, hrefExpr) {
     if (!__gwt_stylesLoaded[stylesheetUrl]) {
-      if (isBodyLoaded()) {
-        var l = $doc.createElement('link');
-        l.setAttribute('rel', 'stylesheet');
-        l.setAttribute('href', hrefExpr);
-        $doc.getElementsByTagName('head')[0].appendChild(l);
-      } else {
- $doc.write("<link id='' rel='stylesheet' href='" + hrefExpr + "'></li" + "nk>");
-      }
+      var l = $doc.createElement('link');
+      l.setAttribute('rel', 'stylesheet');
+      l.setAttribute('href', hrefExpr);
+      $doc.getElementsByTagName('head')[0].appendChild(l);
       __gwt_stylesLoaded[stylesheetUrl] = true;
     }
   }

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to