Revision: 6025
Author: [email protected]
Date: Thu Aug 27 20:54:30 2009
Log: Fix a problem on Safari/Chrome where docuemntElement.getFirstChild is  
not
necessarily the head element.

Patch by: dwolf
Review by: jat

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

Modified:
  /trunk/user/src/com/google/gwt/jsonp/client/JsonpRequest.java

=======================================
--- /trunk/user/src/com/google/gwt/jsonp/client/JsonpRequest.java       Tue Jun 
 
23 09:12:15 2009
+++ /trunk/user/src/com/google/gwt/jsonp/client/JsonpRequest.java       Thu Aug 
 
27 20:54:30 2009
@@ -52,9 +52,9 @@
      return $wnd[name] = new Object();
    }-*/;

-  private static native Node getDocumentElement() /*-{
-    return $doc.documentElement;
-  }-*/;
+  private static Node getHeadElement() {
+    return Document.get().getElementsByTagName("head").getItem(0);
+  }

    private static String nextCallbackId() {
      return "I" + (callbackCounter++);
@@ -142,7 +142,7 @@
      script.setType("text/javascript");
      script.setId(callbackId);
      script.setSrc(uri.toString());
-    getDocumentElement().getFirstChild().appendChild(script);
+    getHeadElement().appendChild(script);
      timer = new Timer() {
        @Override
        public void run() {
@@ -225,7 +225,7 @@
        public void execute() {
          unregisterCallbacks(CALLBACKS);
          Node script = Document.get().getElementById(callbackId);
-        getDocumentElement().getFirstChild().removeChild(script);
+        getHeadElement().removeChild(script);
        }
      });
    }

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

Reply via email to