Shim enquire and Favico to work around race condition
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 25 May 2015 00:45:43 +0000 (02:45 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 25 May 2015 00:45:43 +0000 (02:45 +0200)
If enquire and Favico are loaded before define.amd is nulled: Fine
If they are loaded after define.amd was nulled: They're shimmed and
everything is fine as well.

com.woltlab.wcf/templates/headIncludeJavaScript.tpl
wcfsetup/install/files/js/require.config.js

index 11c907d63e6534485ea22ecb9fd10393e239d2ba..dfa75709f49a3005bdfe084737d749e04d6c1193 100644 (file)
@@ -24,17 +24,6 @@ requirejs.config({
 </script>
 
 <script data-relocate="true">
-       {if ENABLE_DEBUG_MODE}
-               {* force synchronous requests to prevent jQuery and other files being loaded to early *}
-               var __require_createNode = require.createNode;
-               require.createNode = function() {
-                       var node = __require_createNode.apply(require, arguments);
-                       node.removeAttribute('async');
-                       
-                       return node;
-               };
-       {/if}
-       
        require(['Language', 'WoltLab/WCF/BootstrapFrontend'], function(Language, BootstrapFrontend) {
                Language.addObject({
                        '__days': [ '{lang}wcf.date.day.sunday{/lang}', '{lang}wcf.date.day.monday{/lang}', '{lang}wcf.date.day.tuesday{/lang}', '{lang}wcf.date.day.wednesday{/lang}', '{lang}wcf.date.day.thursday{/lang}', '{lang}wcf.date.day.friday{/lang}', '{lang}wcf.date.day.saturday{/lang}' ],
@@ -140,12 +129,10 @@ requirejs.config({
 {/if}
 {if JQUERY_SOURCE != 'local'}
 <script data-relocate="true">
-       //<![CDATA[
        if (!window.jQuery) {
                document.write('<script src="{@$__wcf->getPath()}js/3rdParty/jquery.min.js?v={@LAST_UPDATE_TIME}"><\/script>');
                document.write('<script src="{@$__wcf->getPath()}js/3rdParty/jquery-ui.min.js?v={@LAST_UPDATE_TIME}" data-requiremodule="jquery-ui" data-requirecontext="_"><\/script>');
        }
-       //]]>
 </script>
 {/if}
 
@@ -155,9 +142,6 @@ requirejs.config({
 <script data-relocate="true" src="{@$__wcf->getPath()}js/3rdParty/jquery-ui.timepicker{if !ENABLE_DEBUG_MODE}.min{/if}.js?v={@LAST_UPDATE_TIME}"></script>
 <script data-relocate="true" src="{@$__wcf->getPath()}js/WCF.Assets.js?v={@LAST_UPDATE_TIME}"></script>
 <script data-relocate="true" src="{@$__wcf->getPath()}js/WCF.js?v={@LAST_UPDATE_TIME}"></script>
-<script data-relocate="true">
-       require.createNode = __require_createNode;
-</script>
 {else}
 <script data-relocate="true" src="{@$__wcf->getPath()}js/WCF.Combined.min.js?v={@LAST_UPDATE_TIME}"></script>
 {/if}
index bfc9aeb85f32bb3bd0e94960db732b17b1e1fe56..c1a868f0aea08f56911c0695d6cbb3fa3a0bba9c 100644 (file)
@@ -4,6 +4,11 @@ requirejs.config({
                favico: '3rdParty/favico',
                'perfect-scrollbar': '3rdParty/perfect-scrollbar'
        },
+       shim: {
+               enquire: { exports: 'enquire' },
+               favico: { exports: 'Favico' },
+               'perfect-scrollbar': { exports: 'PerfectScrollbar' }
+       },
        map: {
                '*': {
                        'Ajax': 'WoltLab/WCF/Ajax',