Changeset 29507 in legacy


Ignore:
Timestamp:
Aug 20, 2012 3:50:12 AM (5 years ago)
Author:
bill
Message:

For dojo core and dijit, use require(dojo/domReady!?, cb) rather than ready(cb) so that dojo code can run against other dojo loaders.

Exceptions:

  • robot.initRobot() related code that checks when page inside of iframe has finished initializing
  • dijit-legacy-requires back-compat code for synchronous mode, which load modules that weren't explicitly required (ex: how dijit/_WidgetBase loads dojo/_base/manager)
  • dojo/parser's parseOnLoad: true support
  • dojo-config-require sync mode operation

This change depends on dojo/domReady! executing it's callbacks in the order they were registered. To ensure that client-defined callback code executes after the callbacks inside of dojo/dijit, client code should either continue using dojo/ready, or use a nested require(dojo/domReady!?, ...) inside of the original require that loads the modules:

require([...], function(...){
         require(["dojo/domReady!"], ...)
}

Further, when the client code needs to run the parser and then run another block of code, it should be done like:

require([..., "dojo/parser"], function(..., parser){
     parser.parse().then(...);
}

Viewport.js needed a setTimeout() to workaround bug #15866. It should probably be removed when that bug is fixed.

Refs #15616, #15866 !strict. Changes on trunk/.

Files:
10 edited

Legend:

Unmodified
Added
Removed
  • dijit/trunk/Viewport.js

    r29049 r29507  
    11define([
     2        "require",
    23        "dojo/Evented",
    34        "dojo/on",
    4         "dojo/ready",
    55        "dojo/sniff",
    66        "dojo/_base/window", // global
    77        "dojo/window" // getBox()
    8 ], function(Evented, on, ready, has, win, winUtils){
     8], function(require, Evented, on, has, win, winUtils){
    99
    1010        // module:
     
    2626        var Viewport = new Evented();
    2727
    28         ready(200, function(){
    29                 var oldBox = winUtils.getBox();
    30                 Viewport._rlh = on(win.global, "resize", function(){
    31                         var newBox = winUtils.getBox();
    32                         if(oldBox.h == newBox.h && oldBox.w == newBox.w){ return; }
    33                         oldBox = newBox;
    34                         Viewport.emit("resize");
    35                 });
     28        require(["dojo/domReady!"], function(){
     29                setTimeout(function(){          // work around #15866
     30                        var oldBox = winUtils.getBox();
     31                        Viewport._rlh = on(win.global, "resize", function(){
     32                                var newBox = winUtils.getBox();
     33                                if(oldBox.h == newBox.h && oldBox.w == newBox.w){ return; }
     34                                oldBox = newBox;
     35                                Viewport.emit("resize");
     36                        });
    3637
    37                 // Also catch zoom changes on IE8, since they don't naturally generate resize events
    38                 if(has("ie") == 8){
    39                         var deviceXDPI = screen.deviceXDPI;
    40                         setInterval(function(){
    41                                 if(screen.deviceXDPI != deviceXDPI){
    42                                         deviceXDPI = screen.deviceXDPI;
    43                                         Viewport.emit("resize");
    44                                 }
    45                         }, 500);
    46                 }
     38                        // Also catch zoom changes on IE8, since they don't naturally generate resize events
     39                        if(has("ie") == 8){
     40                                var deviceXDPI = screen.deviceXDPI;
     41                                setInterval(function(){
     42                                        if(screen.deviceXDPI != deviceXDPI){
     43                                                deviceXDPI = screen.deviceXDPI;
     44                                                Viewport.emit("resize");
     45                                        }
     46                                }, 500);
     47                        }
     48                }, 500);
    4749        });
    4850
  • dijit/trunk/_CssStateMixin.js

    r29476 r29507  
    11define([
     2        "require",
    23        "dojo/_base/array", // array.forEach array.map
    34        "dojo/_base/declare",   // declare
     
    78        "dojo/_base/lang", // lang.hitch
    89        "dojo/on",
    9         "dojo/ready",
    1010        "dojo/_base/window", // win.body
    1111        "./registry"
    12 ], function(array, declare, dom, domClass, has, lang, on, ready, win, registry){
     12], function(require, array, declare, dom, domClass, has, lang, on, win, registry){
    1313
    1414// module:
     
    260260});
    261261
    262 ready(function(){
     262require(["dojo/domReady!"], 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

    r29372 r29507  
    11define([
     2        "require",
    23        "dojo/_base/array", // array.forEach array.indexOf array.some
    34        "dojo/_base/config", // config
     
    1617        "dojo/on", // on()
    1718        "dojo/query", // query
    18         "dojo/ready", // ready
    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(array, config, declare, Deferred, dom, domAttr, domClass, domConstruct, domGeometry, domStyle,
    32         event, kernel, keys, lang, on, query, ready, has, topic, unload, _Url, win,
     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,
    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                                 ready(lang.hitch(this, "defer", "focus", this.updateInterval));
     857                                require(["dojo/domReady!"], lang.hitch(this, "defer", "focus", this.updateInterval));
    858858                        }
    859859                        // Save off the initial content now
  • dijit/trunk/focus.js

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

    r28952 r29507  
    1 define(["dojo/dom-class", "dojo/hccss", "dojo/ready", "dojo/_base/window"], function(domClass, has, ready, win){
     1define(["require", "dojo/dom-class", "dojo/hccss", "dojo/_base/window"], function(require, domClass, has, win){
    22
    33        // module:
     
    1212        =====*/
    1313
    14         // Priority is 90 to run ahead of parser priority of 100.   For 2.0, remove the ready() call and instead
    15         // change this module to depend on dojo/domReady!
    16         ready(90, function(){
     14        require(["dojo/domReady!"], function(){
    1715                if(has("highcontrast")){
    1816                        domClass.add(win.body(), "dijit_a11y");
  • dojo/trunk/behavior.js

    r29371 r29507  
    1 define(["./_base/kernel", "./_base/lang", "./_base/array", "./_base/connect", "./query", "./ready"],
    2 function(dojo, lang, darray, connect, query, ready){
     1define(["require", "./_base/kernel", "./_base/lang", "./_base/array", "./_base/connect", "./query"],
     2function(require, dojo, lang, darray, connect, query){
    33
    44// module:
     
    244244dojo.behavior = new Behavior();
    245245
    246 ready(dojo.behavior, "apply"); // FIXME: should this use a priority? before/after parser priority?
     246require(["./domReady!"], function(){ dojo.behavior.apply(); });
    247247
    248248return dojo.behavior;
  • dojo/trunk/hash.js

    r29114 r29507  
    1 define(["./_base/kernel", "require", "./_base/config", "./_base/connect", "./_base/lang", "./ready", "./sniff"],
    2         function(dojo, require, config, connect, lang, ready, has){
     1define(["./_base/kernel", "require", "./_base/config", "./_base/connect", "./_base/lang", "./sniff"],
     2        function(dojo, require, config, connect, lang, has){
    33
    44        // module:
     
    237237                setTimeout(lang.hitch(this,this.pollLocation), _pollFrequency);
    238238        }
    239         ready(function(){
     239
     240        require(["./domReady!"], function(){
    240241                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
    241242                        _connect = connect.connect(dojo.global,"onhashchange",_dispatchEvent);
  • dojo/trunk/hccss.js

    r28952 r29507  
    11define([
    2         "require",                      // require.toUrl
     2        "require",                      // require, require.toUrl
    33        "./_base/config", // config.blankGif
    44        "./dom-class", // domClass.add
     
    66        "./dom-style", // domStyle.getComputedStyle
    77        "./has",
    8         "./ready", // ready
    98        "./_base/window" // win.body
    10 ], function(require, config, domClass, domConstruct, domStyle, has, ready, win){
     9], function(require, config, domClass, domConstruct, domStyle, has, win){
    1110
    1211        // module:
     
    4039        });
    4140
    42         // Priority is 90 to run ahead of parser priority of 100.   For 2.0, remove the ready() call and instead
    43         // change this module to depend on dojo/domReady!
    44         ready(90, function(){
     41        require(["./domReady!"], function(){
    4542                if(has("highcontrast")){
    4643                        domClass.add(win.body(), "dj_a11y");
  • dojo/trunk/touch.js

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

    r29111 r29507  
    1 define(["./dom-geometry", "./_base/lang", "./ready", "./sniff", "./_base/window"],
    2         function(geometry, lang, ready, has, baseWindow){
     1define(["require", "./dom-geometry", "./_base/lang", "./sniff", "./_base/window"],
     2        function(require, geometry, lang, has, baseWindow){
    33
    44        // module:
     
    6666        // We can't run the code below until the <body> tag has loaded (so we can check for dir=rtl).
    6767        // priority is 90 to run ahead of parser priority of 100
    68         ready(90, function(){
     68        require(["./domReady!"], function(){
    6969                if(!geometry.isBodyLtr()){
    7070                        var rtlClassStr = "dj_rtl dijitRtl " + classStr.replace(/ /g, "-rtl ");
Note: See TracChangeset for help on using the changeset viewer.