You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by mh...@apache.org on 2011/05/17 02:24:59 UTC

svn commit: r1103960 - /shindig/trunk/features/src/main/javascript/features/container/init.js

Author: mhermanto
Date: Tue May 17 00:24:59 2011
New Revision: 1103960

URL: http://svn.apache.org/viewvc?rev=1103960&view=rev
Log:
Enable proper common container globals initialization when dynamically loading. Thanks to sieverssj@gmail.com.
http://codereview.appspot.com/4439090/

Modified:
    shindig/trunk/features/src/main/javascript/features/container/init.js

Modified: shindig/trunk/features/src/main/javascript/features/container/init.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/container/init.js?rev=1103960&r1=1103959&r2=1103960&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/container/init.js (original)
+++ shindig/trunk/features/src/main/javascript/features/container/init.js Tue May 17 00:24:59 2011
@@ -43,9 +43,18 @@
     window.__CONTAINER_URI = shindig.uri(window.location.href);
 
     window.__API_URI = null;
-    var scriptEls = document.getElementsByTagName('script');
-    if (scriptEls.length > 0) {
-      window.__API_URI = shindig.uri(scriptEls[scriptEls.length - 1].src);
+    var scriptEl = null;
+    if (window.__CONTAINER_SCRIPT_ID) {
+      scriptEl = document.getElementById(window.__CONTAINER_SCRIPT_ID);
+    } else {
+      var scriptEls = document.getElementsByTagName('script');
+      if (scriptEls.length > 0) {
+        scriptEl = scriptEls[scriptEls.length - 1];
+      }
+    }
+
+    if (scriptEl) {
+      window.__API_URI = shindig.uri(scriptEl.src);
       // In case script URI is relative, resolve (make absolute) with container.
       window.__API_URI.resolve(window.__CONTAINER_URI);
     }