Work around race condition in WCF.js loading
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 25 May 2015 00:56:12 +0000 (02:56 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 25 May 2015 00:56:12 +0000 (02:56 +0200)
wcfsetup/install/files/js/WCF.js
wcfsetup/install/files/js/WoltLab/WCF/Bootstrap.js

index 9df9906becf4b28a0383261fafcfc3e839d7608f..9eb35d71b2f8fc0bc952f818dc8613482b168e18 100755 (executable)
@@ -186,7 +186,8 @@ window.shuffle = function(array) {
 /**
  * Initialize WCF namespace
  */
-window.WCF = {};
+// non strict equals by intent
+if (window.WCF == null) window.WCF = { };
 
 /**
  * Extends jQuery with additional methods.
@@ -3239,25 +3240,28 @@ WCF.Dictionary = Class.extend({
        }
 });
 
-/**
- * @deprecated Use WoltLab/WCF/Language
- */
-WCF.Language = {
-       add: function(key, value) {
-               require(['WoltLab/WCF/Language'], function(Language) {
-                       Language.add(key, value);
-               });
-       },
-       addObject: function(object) {
-               require(['WoltLab/WCF/Language'], function(Language) {
-                       Language.addObject(object);
-               });
-       },
-       get: function(key, parameters) {
-               // This cannot be sanely provided as a compatibility wrapper.
-               throw new Error('Call to deprecated WCF.Language.get("' + key + '")');
-       }
-};
+// non strict equals by intent
+if (window.WCF.Language == null) {
+       /**
+        * @deprecated Use WoltLab/WCF/Language
+        */
+       WCF.Language = {
+               add: function(key, value) {
+                       require(['WoltLab/WCF/Language'], function(Language) {
+                               Language.add(key, value);
+                       });
+               },
+               addObject: function(object) {
+                       require(['WoltLab/WCF/Language'], function(Language) {
+                               Language.addObject(object);
+                       });
+               },
+               get: function(key, parameters) {
+                       // This cannot be sanely provided as a compatibility wrapper.
+                       throw new Error('Call to deprecated WCF.Language.get("' + key + '")');
+               }
+       };
+}
 
 /**
  * Handles multiple language input fields.
index 16384365548f09961df942cc1591904d098f4df1..659313b7a87967c99fb76d52465b4862b38a10b6 100644 (file)
@@ -25,6 +25,9 @@ define(
        // perfectScrollbar does not need to be bound anywhere, it just has to be loaded for WCF.js
        window.Favico = favico;
        window.enquire = enquire;
+       // non strict equals by intent
+       if (window.WCF == null) window.WCF = { };
+       if (window.WCF.Language == null) window.WCF.Language = { };
        window.WCF.Language.get = Language.get;
        window.WCF.Language.add = Language.add;
        window.WCF.Language.addObject = Language.addObject;