Changeset 29511 in legacy


Ignore:
Timestamp:
Aug 21, 2012 7:58:18 AM (5 years ago)
Author:
bill
Message:

Use domReady() as a function rather than as a plugin, so dependencies can be fully resolved on the server.

This required a few changes to dojo/ready and dojo/domReady though:

  • for dojo/domReady, needed to make sure that tasks were executed in the order they were registered, including tasks registered after the DOMContentLoaded event but before the queue of tasks has been completed
  • delay executing dojo/ready callbacks until all tasks registered via domReady() complete, in order to insure that all the dojo initialization code runs before user defined code


Refs #15616 !strict

Files:
12 edited

Legend:

Unmodified
Added
Removed
  • dijit/trunk/Viewport.js

    r29507 r29511  
    11define([
    2         "require",
    32        "dojo/Evented",
    43        "dojo/on",
     4        "dojo/domReady",
    55        "dojo/sniff",
    66        "dojo/_base/window", // global
    77        "dojo/window" // getBox()
    8 ], function(require, Evented, on, has, win, winUtils){
     8], function(Evented, on, domReady, has, win, winUtils){
    99
    1010        // module:
     
    2626        var Viewport = new Evented();
    2727
    28         require(["dojo/domReady!"], function(){
     28        domReady(function(){
    2929                setTimeout(function(){          // work around #15866
    3030                        var oldBox = winUtils.getBox();
  • dijit/trunk/_CssStateMixin.js

    r29507 r29511  
    11define([
    2         "require",
    32        "dojo/_base/array", // array.forEach array.map
    43        "dojo/_base/declare",   // declare
     
    87        "dojo/_base/lang", // lang.hitch
    98        "dojo/on",
     9        "dojo/domReady",
    1010        "dojo/_base/window", // win.body
    1111        "./registry"
    12 ], function(require, array, declare, dom, domClass, has, lang, on, win, registry){
     12], function(array, declare, dom, domClass, has, lang, on, domReady, win, registry){
    1313
    1414// module:
     
    260260});
    261261
    262 require(["dojo/domReady!"], function(){
     262domReady(function(){
    263263        // Document level listener to catch hover etc. events on widget root nodes and subnodes.
    264264        // Note that when the mouse is moved quickly, a single onmouseenter event could signal that multiple widgets
  • dijit/trunk/_editor/RichText.js

    r29507 r29511  
    11define([
    2         "require",
    32        "dojo/_base/array", // array.forEach array.indexOf array.some
    43        "dojo/_base/config", // config
     
    1716        "dojo/on", // on()
    1817        "dojo/query", // query
     18        "dojo/domReady",
    1919        "dojo/sniff", // has("ie") has("mozilla") has("opera") has("safari") has("webkit")
    2020        "dojo/topic",   // topic.publish() (publish)
     
    2929        "../focus",
    3030        "../main"       // dijit._scopeName
    31 ], function(require, array, config, declare, Deferred, dom, domAttr, domClass, domConstruct, domGeometry, domStyle,
    32         event, kernel, keys, lang, on, query, has, topic, unload, _Url, win,
     31], function(array, config, declare, Deferred, dom, domAttr, domClass, domConstruct, domGeometry, domStyle,
     32        event, kernel, keys, lang, on, query, domReady, has, topic, unload, _Url, win,
    3333        _Widget, _CssStateMixin, selectionapi, rangeapi, htmlapi, focus, dijit){
    3434
     
    855855                                // after the document loads, then set focus after updateInterval expires so that
    856856                                // onNormalizedDisplayChanged has run to avoid input caret issues
    857                                 require(["dojo/domReady!"], lang.hitch(this, "defer", "focus", this.updateInterval));
     857                                domReady(lang.hitch(this, "defer", "focus", this.updateInterval));
    858858                        }
    859859                        // Save off the initial content now
  • dijit/trunk/focus.js

    r29507 r29511  
    11define([
    2         "require",
    32        "dojo/aspect",
    43        "dojo/_base/declare", // declare
     
    98        "dojo/_base/lang", // lang.hitch
    109        "dojo/on",
     10        "dojo/domReady",
    1111        "dojo/sniff", // has("ie")
    1212        "dojo/Stateful",
     
    1717        "./registry",   // registry.byId
    1818        "./main"                // to set dijit.focus
    19 ], function(require, aspect, declare, dom, domAttr, domConstruct, Evented, lang, on, has, Stateful, unload, win, winUtils,
     19], function(aspect, declare, dom, domAttr, domConstruct, Evented, lang, on, domReady, has, Stateful, unload, win, winUtils,
    2020                        a11y, registry, dijit){
    2121
     
    335335
    336336        // register top window and all the iframes it contains
    337         require(["dojo/domReady!"], function(){
     337        domReady(function(){
    338338                var handle = singleton.registerWin(winUtils.get(win.doc));
    339339                if(has("ie")){
  • dijit/trunk/hccss.js

    r29507 r29511  
    1 define(["require", "dojo/dom-class", "dojo/hccss", "dojo/_base/window"], function(require, domClass, has, win){
     1define(["dojo/dom-class", "dojo/hccss", "dojo/domReady", "dojo/_base/window"], function(domClass, has, domReady, win){
    22
    33        // module:
     
    1212        =====*/
    1313
    14         require(["dojo/domReady!"], function(){
     14        domReady(function(){
    1515                if(has("highcontrast")){
    1616                        domClass.add(win.body(), "dijit_a11y");
  • dojo/trunk/behavior.js

    r29507 r29511  
    1 define(["require", "./_base/kernel", "./_base/lang", "./_base/array", "./_base/connect", "./query"],
    2 function(require, dojo, lang, darray, connect, query){
     1define(["./_base/kernel", "./_base/lang", "./_base/array", "./_base/connect", "./query", "./domReady"],
     2function(dojo, lang, darray, connect, query, domReady){
    33
    44// module:
     
    244244dojo.behavior = new Behavior();
    245245
    246 require(["./domReady!"], function(){ dojo.behavior.apply(); });
     246domReady( function(){ dojo.behavior.apply(); } );
    247247
    248248return dojo.behavior;
  • dojo/trunk/domReady.js

    r29156 r29511  
    8484                // summary:
    8585                //              Plugin to delay require()/define() callback from firing until the DOM has finished loading.
    86                 if(ready){
     86                if(ready && (!readyQ || !readyQ.length)){
    8787                        callback(doc);
    8888                }else{
  • dojo/trunk/hash.js

    r29507 r29511  
    1 define(["./_base/kernel", "require", "./_base/config", "./_base/connect", "./_base/lang", "./sniff"],
    2         function(dojo, require, config, connect, lang, has){
     1define(["./_base/kernel", "require", "./_base/config", "./_base/connect", "./_base/lang", "./domReady", "./sniff"],
     2        function(dojo, require, config, connect, lang, domReady, has){
    33
    44        // module:
     
    237237                setTimeout(lang.hitch(this,this.pollLocation), _pollFrequency);
    238238        }
    239 
    240         require(["./domReady!"], function(){
     239        domReady(function(){
    241240                if("onhashchange" in dojo.global && (!has("ie") || (has("ie") >= 8 && document.compatMode != "BackCompat"))){   //need this IE browser test because "onhashchange" exists in IE8 in IE7 mode
    242241                        _connect = connect.connect(dojo.global,"onhashchange",_dispatchEvent);
  • dojo/trunk/hccss.js

    r29507 r29511  
    66        "./dom-style", // domStyle.getComputedStyle
    77        "./has",
     8        "./domReady",
    89        "./_base/window" // win.body
    9 ], function(require, config, domClass, domConstruct, domStyle, has, win){
     10], function(require, config, domClass, domConstruct, domStyle, has, domReady, win){
    1011
    1112        // module:
     
    3940        });
    4041
    41         require(["./domReady!"], function(){
     42        domReady(function(){
    4243                if(has("highcontrast")){
    4344                        domClass.add(win.body(), "dj_a11y");
  • dojo/trunk/ready.js

    r29174 r29511  
    3232                                onLoadRecursiveGuard = 1;
    3333                                var f = loadQ.shift();
    34                                         try{
    35                                                 f();
    36                                         }
    37                                                 // FIXME: signal the error via require.on
    38                                         finally{
    39                                                 onLoadRecursiveGuard = 0;
    40                                         }
     34                                try{
     35                                        // Call domReady() again to yield to any tasks registered directly via domReady().
     36                                        // This is necessary so that a user defined dojo.ready() callback is delayed until after the
     37                                        // domReady() calls inside of dojo.   Failure can be seen on dijit/tests/Dialog.html because the
     38                                        // dijit/focus.js domReady() callback doesn't execute until after the test starts running.
     39                                        domReady(f);
     40                                }
     41                                // FIXME: signal the error via require.on
     42                                finally{
     43                                        onLoadRecursiveGuard = 0;
     44                                }
    4145                                onLoadRecursiveGuard = 0;
    4246                                if(loadQ.length){
  • dojo/trunk/touch.js

    r29507 r29511  
    1 define(["require", "./_base/kernel", "./_base/lang", "./aspect", "./dom", "./on", "./has", "./mouse", "./_base/window"],
    2 function(require, dojo, lang, aspect, dom, on, has, mouse, win){
     1define(["./_base/kernel", "./_base/lang", "./aspect", "./dom", "./on", "./has", "./mouse", "./domReady", "./_base/window"],
     2function(dojo, lang, aspect, dom, on, has, mouse, domReady, win){
    33
    44        // module:
     
    1919
    2020        if(hasTouch){
    21                 require(["./domReady!"], function(){
     21                domReady(function(){
    2222                        // Keep track of currently hovered node
    2323                        hoveredNode = win.body();       // currently hovered node
  • dojo/trunk/uacss.js

    r29507 r29511  
    1 define(["require", "./dom-geometry", "./_base/lang", "./sniff", "./_base/window"],
    2         function(require, geometry, lang, has, baseWindow){
     1define(["./dom-geometry", "./_base/lang", "./domReady", "./sniff", "./_base/window"],
     2        function(geometry, lang, domReady, has, baseWindow){
    33
    44        // module:
     
    6565        // If RTL mode, then add dj_rtl flag plus repeat existing classes with -rtl extension.
    6666        // We can't run the code below until the <body> tag has loaded (so we can check for dir=rtl).
    67         // priority is 90 to run ahead of parser priority of 100
    68         require(["./domReady!"], function(){
     67        domReady(function(){
    6968                if(!geometry.isBodyLtr()){
    7069                        var rtlClassStr = "dj_rtl dijitRtl " + classStr.replace(/ /g, "-rtl ");
Note: See TracChangeset for help on using the changeset viewer.