Author: [email protected]
Date: Fri Jun  5 11:25:46 2009
New Revision: 5517

Modified:
    trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html
    trunk/dev/core/src/com/google/gwt/core/linker/IFrameTemplate.js

Log:
Fix for hosted mode with XHR-based iframe selection script.
Includes fix for issue 3717.
Review: http://gwt-code-reviews.appspot.com/33840


Modified: trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html
==============================================================================
--- trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html   
(original)
+++ trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html  Fri  
Jun  5 11:25:46 2009
@@ -4,11 +4,21 @@
  var $doc = $wnd.document;
  var $moduleName, $moduleBase
  ,$stats = $wnd.__gwtStatsEvent ? function(a) {return  
$wnd.__gwtStatsEvent(a);} : null;
+
+// The module to be loaded can be specified either through the url query
+// parameter (as done by the legacy HostedModeTemplate.js), or by  
specifying
+// window.name (as done by IFrameTemplate.js). When the former approach
+// is removed, we can drop the window.location.search part of this logic.
+var moduleFuncName = window.location.search.substring(1);
+if (!moduleFuncName || !$wnd[moduleFuncName]) {
+       moduleFuncName = window.name;
+}
+
+var moduleFunc = $wnd[moduleFuncName];
+var moduleName = moduleFunc ? moduleFunc.moduleName : "unknown";
+
  // Lightweight metrics
  if ($stats) {
-  var moduleFuncName = location.search.substr(1);
-  var moduleFunc = $wnd[moduleFuncName];
-  var moduleName = moduleFunc ? moduleFunc.moduleName : "unknown";
     
$stats({moduleName:moduleName,subSystem:'startup',evtGroup:'moduleStartup',millis:(new
  
Date()).getTime(),type:'moduleEvalStart'});
  }

@@ -241,13 +251,5 @@
    }
  }

-// The module to be loaded can be specified either through the url query
-// parameter (as done by the legacy HostedModeTemplate.js), or by  
specifying
-// window.__gwt_module (as done by IFrameTemplate.js). When the former  
approach
-// is removed, we can drop the 'query' part of this logic.
-query = window.location.search.substring(1);
-if (query && $wnd[query]) setTimeout($wnd[query].onScriptLoad, 1);
-
-var module  = window.__gwt_module;
-if (module && $wnd[module]) setTimeout($wnd[module].onScriptLoad, 1);
+setTimeout($wnd[moduleFuncName].onScriptLoad, 1);
  --></script></body></html>

Modified: trunk/dev/core/src/com/google/gwt/core/linker/IFrameTemplate.js
==============================================================================
--- trunk/dev/core/src/com/google/gwt/core/linker/IFrameTemplate.js      
(original)
+++ trunk/dev/core/src/com/google/gwt/core/linker/IFrameTemplate.js     Fri  
Jun  5 11:25:46 2009
@@ -309,6 +309,9 @@
        type: 'moduleRequested'
      });

+    // to avoid http://support.microsoft.com/kb/927917 only mutate closed  
containers - therefore we create a closed container which can be mutated  
within xhr.onreadystatechange
+    document.write("<div id='__MODULE_NAME__.container'  
style='position:absolute; width:0; height:0; border:none'></div>");
+
      // Fetch the contents via XHR.
      var xhr = newXhr();
      xhr.open('GET', base + initialHtml);
@@ -322,14 +325,14 @@
          scriptFrame.id = '__MODULE_NAME__';
          scriptFrame.style.cssText = 'position:absolute; width:0; height:0;  
border:none';
          scriptFrame.tabIndex = -1;
-        document.body.appendChild(scriptFrame);
+         
document.getElementById("__MODULE_NAME__.container").appendChild(scriptFrame);

-        // Expose the module function via an expando on the iframe's  
window.
+        // Expose the module function via the iframe's window.name property
          // (this is needed for the compiled script to call back into
          //  onScriptLoad()).
          var win = scriptFrame.contentWindow;
          if (isHostedMode()) {
-          win.__gwt_module = '__MODULE_FUNC__';
+          win.name = '__MODULE_FUNC__';
          }

          // Inject the fetched script into the script frame.

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

Reply via email to