After the change below, dojo.byId() no longer works when passed a
null/undefined argument, which breaks dijit since _Widget.js does:

this.srcNodeRef = dojo.byId(srcNodeRef);

Should we be supporting a null argument to dojo.byId()? The API doc
doesn't say it's supported but maybe people are depending on it? (If we
don't want to support it I can just update dijit to do a null check.)
On 4/12/09 3:09 PM, dojo-checkins-admin at dojotoolkit.org wrote:
Author: alex
Date: Sat Apr 11 23:09:14 2009
New Revision: 17266

Modified:
dojo/trunk/_base/html.js
Log:
create (and use) a local reference to dojo.byId() in order to boost addclass-odd test #'s on IE6. Very strange, but the performance difference is nearly order-of-magnitude (80ms vs> 800ms).

Refs #9114

!strict


Modified: dojo/trunk/_base/html.js
==============================================================================
--- dojo/trunk/_base/html.js (original)
+++ dojo/trunk/_base/html.js Sat Apr 11 23:09:14 2009
@@ -49,29 +49,28 @@
//>>excludeStart("webkitMobile", kwArgs.webkitMobile);
if(dojo.isIE || dojo.isOpera){
dojo.byId = function(id, doc){
- if(dojo.isString(id)){
- var _d = doc || dojo.doc;
- var te = _d.getElementById(id);
- // attributes.id.value is better than just id in case the
- // user has a name=id inside a form
- if(te&& (te.attributes.id.value == id || te.id == id)){
- return te;
- }else{
- var eles = _d.all[id];
- if(!eles || eles.nodeName){
- eles = [eles];
- }
- // if more than 1, choose first with the correct id
- var i=0;
- while((te=eles[i++])){
- if((te.attributes&& te.attributes.id&& te.attributes.id.value == id)
- || te.id == id){
- return te;
- }
+ if(id.nodeType){
+ return id;
+ }
+ var _d = doc || dojo.doc;
+ var te = _d.getElementById(id);
+ // attributes.id.value is better than just id in case the
+ // user has a name=id inside a form
+ if(te&& (te.attributes.id.value == id || te.id == id)){
+ return te;
+ }else{
+ var eles = _d.all[id];
+ if(!eles || eles.nodeName){
+ eles = [eles];
+ }
+ // if more than 1, choose first with the correct id
+ var i=0;
+ while((te=eles[i++])){
+ if((te.attributes&& te.attributes.id&& te.attributes.id.value == id)
+ || te.id == id){
+ return te;
}
}
- }else{
- return id; // DomNode
}
};
}else{
@@ -90,6 +89,8 @@
(function(){
var d = dojo;
//>>excludeEnd("webkitMobile");
+ var byId = d.byId;
+ var isString = d.isString;

var _destroyContainer = null;
//>>excludeStart("webkitMobile", kwArgs.webkitMobile);
@@ -125,7 +126,7 @@
// Destroy all nodes in a list by reference:
// | dojo.query(".someNode").forEach(dojo.destroy);

- node = d.byId(node);
+ node = byId(node);
try{
if(!_destroyContainer || _destroyContainer.ownerDocument != node.ownerDocument){
_destroyContainer = node.ownerDocument.createElement("div");
@@ -144,8 +145,8 @@
// node: string id or node reference to test
// ancestor: string id or node reference of potential parent to test against
try{
- node = d.byId(node);
- ancestor = d.byId(ancestor);
+ node = byId(node);
+ ancestor = byId(ancestor);
while(node){
if(node === ancestor){
return true; // Boolean
@@ -163,7 +164,7 @@
// selectable:
// state to put the node in. false indicates unselectable, true
// allows selection.
- node = d.byId(node);
+ node = byId(node);
//>>excludeStart("webkitMobile", kwArgs.webkitMobile);
if(d.isMozilla){
node.style.MozUserSelect = selectable ? "" : "none";
@@ -244,9 +245,9 @@
// Put a new LI as the first child of a list by id:
// | dojo.place(dojo.create('li'), "someUl", "first");

- refNode = d.byId(refNode);
- if(d.isString(node)){
- node = node.charAt(0) == "<" ? d._toDom(node, refNode.ownerDocument) : d.byId(node);
+ refNode = byId(refNode);
+ if(isString(node)){
+ node = node.charAt(0) == "<" ? d._toDom(node, refNode.ownerDocument) : byId(node);
}
if(typeof position == "number"){
var cn = refNode.childNodes;
@@ -614,7 +615,7 @@
// | fontSize:"13pt"
// | });

- var n = d.byId(node), args = arguments.length, op = (style == "opacity");
+ var n = byId(node), args = arguments.length, op = (style == "opacity");
style = _floatAliases[style] || style;
if(args == 3){
return op ? d._setOpacity(n, value) : n.style[style] = value; /*Number*/
@@ -623,7 +624,7 @@
return d._getOpacity(n);
}
var s = gcs(n);
- if(args == 2&& !d.isString(style)){
+ if(args == 2&& !isString(style)){
for(var x in style){
d.style(node, x, style[x]);
}
@@ -976,7 +977,7 @@
// If passed, denotes that dojo.marginBox() should
// update/set the margin box for node. Box is an object in the
// above format. All properties are optional if passed.
- var n = d.byId(node), s = gcs(n), b = box;
+ var n = byId(node), s = gcs(n), b = box;
return !b ? d._getMarginBox(n, s) : d._setMarginBox(n, b.l, b.t, b.w, b.h, s); // Object
}

@@ -998,7 +999,7 @@
// If passed, denotes that dojo.contentBox() should
// update/set the content box for node. Box is an object in the
// above format. All properties are optional if passed.
- var n = d.byId(node), s = gcs(n), b = box;
+ var n = byId(node), s = gcs(n), b = box;
return !b ? d._getContentBox(n, s) : d._setContentSize(n, b.w, b.h, s); // Object
}

@@ -1214,7 +1215,7 @@
//| { l: 50, t: 200, w: 300: h: 150, x: 100, y: 300 }
// Does not act as a setter. If includeScroll is passed, the x and
// y params are affected as one would expect in dojo._abs().
- var n = d.byId(node), s = gcs(n), mb = d._getMarginBox(n, s);
+ var n = byId(node), s = gcs(n), mb = d._getMarginBox(n, s);
var abs = d._abs(n, includeScroll);
mb.x = abs.x;
mb.y = abs.y;
@@ -1284,7 +1285,7 @@
// returns:
// true if the requested attribute is specified on the
// given element, and false otherwise
- node = d.byId(node);
+ node = byId(node);
var fixName = _fixAttrName(name);
fixName = fixName == "htmlFor" ? "for" : fixName; //IE<8 uses htmlFor except in this case
var attr = node.getAttributeNode&& node.getAttributeNode(fixName);
@@ -1379,11 +1380,13 @@
// | // though shorter to use `dojo.style` in this case:
// | dojo.style("someNode", obj);

- node = d.byId(node);
+ node = byId(node);
var args = arguments.length;
- if(args == 2&& !d.isString(name)){
+ if(args == 2&& !isString(name)){
// the object form of setter: the 2nd argument is a dictionary
- for(var x in name){ d.attr(node, x, name[x]); }
+ for(var x in name){
+ d.attr(node, x, name[x]);
+ }
// FIXME: return the node in this case? could be useful.
return;
}
@@ -1413,7 +1416,7 @@

}else if(typeof value == "boolean"){ // e.g. onsubmit, disabled
node[name] = value;
- }else if(name === "style"&& !d.isString(value)){
+ }else if(name === "style"&& !isString(value)){
// when the name is "style" and value is an object, pass along
d.style(node, value);
}else if(name == "className"){
@@ -1453,7 +1456,7 @@
// id or reference to the element to remove the attribute from
// name:
// the name of the attribute to remove
- d.byId(node).removeAttribute(_fixAttrName(name));
+ byId(node).removeAttribute(_fixAttrName(name));
}

dojo.create = function(tag, attrs, refNode, pos){
@@ -1528,10 +1531,10 @@

var doc = d.doc;
if(refNode){
- refNode = d.byId(refNode);
+ refNode = byId(refNode);
doc = refNode.ownerDocument;
}
- if(d.isString(tag)){
+ if(isString(tag)){
tag = doc.createElement(tag);
}
if(attrs){ d.attr(tag, attrs); }
@@ -1558,14 +1561,14 @@
d.empty =
//>>excludeStart("webkitMobile", kwArgs.webkitMobile);
d.isIE ? function(node){
- node = d.byId(node);
+ node = byId(node);
for(var c; c = node.lastChild;){ // intentional assignment
d.destroy(c);
}
} :
//>>excludeEnd("webkitMobile");
function(node){
- d.byId(node).innerHTML = "";
+ byId(node).innerHTML = "";
};

/*=====
@@ -1675,7 +1678,7 @@
// example:
// | if(dojo.hasClass("someNode","aSillyClassName")){ ... }

- return ((" "+ d.byId(node)[_className] +" ").indexOf(" "+ classStr +" ")>= 0); // Boolean
+ return ((" "+ byId(node)[_className] +" ").indexOf(" "+ classStr +" ")>= 0); // Boolean
};

dojo.addClass = function(/*DomNode|String*/node, /*String*/classStr){
@@ -1702,7 +1705,7 @@
// Available in `dojo.NodeList` for multiple additions
// | dojo.query("ul> li").addClass("firstLevel");

- node = d.byId(node);
+ node = byId(node);
var cls = node[_className];
if((" "+ cls +" ").indexOf(" " + classStr + " ")< 0){
node[_className] = cls + (cls ? ' ' : '') + classStr;
@@ -1727,7 +1730,7 @@
// Available in `dojo.NodeList` for multiple removal
// | dojo.query(".foo").removeClass("foo");

- node = d.byId(node);
+ node = byId(node);
var t = d.trim((" " + node[_className] + " ").replace(" " + classStr + " ", " "));
if(node[_className] != t){ node[_className] = t; }
};
_______________________________________________
Dojo-checkins mailing list
Dojo-checkins at mail.dojotoolkit.org
http://mail.dojotoolkit.org/mailman/listinfo/dojo-checkins

Search Discussions

  • Peter E Higgins at Apr 13, 2009 at 9:54 am
    I like that we can pass anything (null included) and get back a truthy
    value. I expect that if dijit was relying on the behavior, others are
    as well.

    Bill Keese wrote:
    After the change below, dojo.byId() no longer works when passed a
    null/undefined argument, which breaks dijit since _Widget.js does:

    this.srcNodeRef = dojo.byId(srcNodeRef);

    Should we be supporting a null argument to dojo.byId()? The API doc
    doesn't say it's supported but maybe people are depending on it? (If we
    don't want to support it I can just update dijit to do a null check.)
    On 4/12/09 3:09 PM, dojo-checkins-admin at dojotoolkit.org wrote:

    Author: alex
    Date: Sat Apr 11 23:09:14 2009
    New Revision: 17266

    Modified:
    dojo/trunk/_base/html.js
    Log:
    create (and use) a local reference to dojo.byId() in order to boost addclass-odd test #'s on IE6. Very strange, but the performance difference is nearly order-of-magnitude (80ms vs> 800ms).

    Refs #9114

    !strict


    Modified: dojo/trunk/_base/html.js
    ==============================================================================
    --- dojo/trunk/_base/html.js (original)
    +++ dojo/trunk/_base/html.js Sat Apr 11 23:09:14 2009
    @@ -49,29 +49,28 @@
    //>>excludeStart("webkitMobile", kwArgs.webkitMobile);
    if(dojo.isIE || dojo.isOpera){
    dojo.byId = function(id, doc){
    - if(dojo.isString(id)){
    - var _d = doc || dojo.doc;
    - var te = _d.getElementById(id);
    - // attributes.id.value is better than just id in case the
    - // user has a name=id inside a form
    - if(te&& (te.attributes.id.value == id || te.id == id)){
    - return te;
    - }else{
    - var eles = _d.all[id];
    - if(!eles || eles.nodeName){
    - eles = [eles];
    - }
    - // if more than 1, choose first with the correct id
    - var i=0;
    - while((te=eles[i++])){
    - if((te.attributes&& te.attributes.id&& te.attributes.id.value == id)
    - || te.id == id){
    - return te;
    - }
    + if(id.nodeType){
    + return id;
    + }
    + var _d = doc || dojo.doc;
    + var te = _d.getElementById(id);
    + // attributes.id.value is better than just id in case the
    + // user has a name=id inside a form
    + if(te&& (te.attributes.id.value == id || te.id == id)){
    + return te;
    + }else{
    + var eles = _d.all[id];
    + if(!eles || eles.nodeName){
    + eles = [eles];
    + }
    + // if more than 1, choose first with the correct id
    + var i=0;
    + while((te=eles[i++])){
    + if((te.attributes&& te.attributes.id&& te.attributes.id.value == id)
    + || te.id == id){
    + return te;
    }
    }
    - }else{
    - return id; // DomNode
    }
    };
    }else{
    @@ -90,6 +89,8 @@
    (function(){
    var d = dojo;
    //>>excludeEnd("webkitMobile");
    + var byId = d.byId;
    + var isString = d.isString;

    var _destroyContainer = null;
    //>>excludeStart("webkitMobile", kwArgs.webkitMobile);
    @@ -125,7 +126,7 @@
    // Destroy all nodes in a list by reference:
    // | dojo.query(".someNode").forEach(dojo.destroy);

    - node = d.byId(node);
    + node = byId(node);
    try{
    if(!_destroyContainer || _destroyContainer.ownerDocument != node.ownerDocument){
    _destroyContainer = node.ownerDocument.createElement("div");
    @@ -144,8 +145,8 @@
    // node: string id or node reference to test
    // ancestor: string id or node reference of potential parent to test against
    try{
    - node = d.byId(node);
    - ancestor = d.byId(ancestor);
    + node = byId(node);
    + ancestor = byId(ancestor);
    while(node){
    if(node === ancestor){
    return true; // Boolean
    @@ -163,7 +164,7 @@
    // selectable:
    // state to put the node in. false indicates unselectable, true
    // allows selection.
    - node = d.byId(node);
    + node = byId(node);
    //>>excludeStart("webkitMobile", kwArgs.webkitMobile);
    if(d.isMozilla){
    node.style.MozUserSelect = selectable ? "" : "none";
    @@ -244,9 +245,9 @@
    // Put a new LI as the first child of a list by id:
    // | dojo.place(dojo.create('li'), "someUl", "first");

    - refNode = d.byId(refNode);
    - if(d.isString(node)){
    - node = node.charAt(0) == "<" ? d._toDom(node, refNode.ownerDocument) : d.byId(node);
    + refNode = byId(refNode);
    + if(isString(node)){
    + node = node.charAt(0) == "<" ? d._toDom(node, refNode.ownerDocument) : byId(node);
    }
    if(typeof position == "number"){
    var cn = refNode.childNodes;
    @@ -614,7 +615,7 @@
    // | fontSize:"13pt"
    // | });

    - var n = d.byId(node), args = arguments.length, op = (style == "opacity");
    + var n = byId(node), args = arguments.length, op = (style == "opacity");
    style = _floatAliases[style] || style;
    if(args == 3){
    return op ? d._setOpacity(n, value) : n.style[style] = value; /*Number*/
    @@ -623,7 +624,7 @@
    return d._getOpacity(n);
    }
    var s = gcs(n);
    - if(args == 2&& !d.isString(style)){
    + if(args == 2&& !isString(style)){
    for(var x in style){
    d.style(node, x, style[x]);
    }
    @@ -976,7 +977,7 @@
    // If passed, denotes that dojo.marginBox() should
    // update/set the margin box for node. Box is an object in the
    // above format. All properties are optional if passed.
    - var n = d.byId(node), s = gcs(n), b = box;
    + var n = byId(node), s = gcs(n), b = box;
    return !b ? d._getMarginBox(n, s) : d._setMarginBox(n, b.l, b.t, b.w, b.h, s); // Object
    }

    @@ -998,7 +999,7 @@
    // If passed, denotes that dojo.contentBox() should
    // update/set the content box for node. Box is an object in the
    // above format. All properties are optional if passed.
    - var n = d.byId(node), s = gcs(n), b = box;
    + var n = byId(node), s = gcs(n), b = box;
    return !b ? d._getContentBox(n, s) : d._setContentSize(n, b.w, b.h, s); // Object
    }

    @@ -1214,7 +1215,7 @@
    //| { l: 50, t: 200, w: 300: h: 150, x: 100, y: 300 }
    // Does not act as a setter. If includeScroll is passed, the x and
    // y params are affected as one would expect in dojo._abs().
    - var n = d.byId(node), s = gcs(n), mb = d._getMarginBox(n, s);
    + var n = byId(node), s = gcs(n), mb = d._getMarginBox(n, s);
    var abs = d._abs(n, includeScroll);
    mb.x = abs.x;
    mb.y = abs.y;
    @@ -1284,7 +1285,7 @@
    // returns:
    // true if the requested attribute is specified on the
    // given element, and false otherwise
    - node = d.byId(node);
    + node = byId(node);
    var fixName = _fixAttrName(name);
    fixName = fixName == "htmlFor" ? "for" : fixName; //IE<8 uses htmlFor except in this case
    var attr = node.getAttributeNode&& node.getAttributeNode(fixName);
    @@ -1379,11 +1380,13 @@
    // | // though shorter to use `dojo.style` in this case:
    // | dojo.style("someNode", obj);

    - node = d.byId(node);
    + node = byId(node);
    var args = arguments.length;
    - if(args == 2&& !d.isString(name)){
    + if(args == 2&& !isString(name)){
    // the object form of setter: the 2nd argument is a dictionary
    - for(var x in name){ d.attr(node, x, name[x]); }
    + for(var x in name){
    + d.attr(node, x, name[x]);
    + }
    // FIXME: return the node in this case? could be useful.
    return;
    }
    @@ -1413,7 +1416,7 @@

    }else if(typeof value == "boolean"){ // e.g. onsubmit, disabled
    node[name] = value;
    - }else if(name === "style"&& !d.isString(value)){
    + }else if(name === "style"&& !isString(value)){
    // when the name is "style" and value is an object, pass along
    d.style(node, value);
    }else if(name == "className"){
    @@ -1453,7 +1456,7 @@
    // id or reference to the element to remove the attribute from
    // name:
    // the name of the attribute to remove
    - d.byId(node).removeAttribute(_fixAttrName(name));
    + byId(node).removeAttribute(_fixAttrName(name));
    }

    dojo.create = function(tag, attrs, refNode, pos){
    @@ -1528,10 +1531,10 @@

    var doc = d.doc;
    if(refNode){
    - refNode = d.byId(refNode);
    + refNode = byId(refNode);
    doc = refNode.ownerDocument;
    }
    - if(d.isString(tag)){
    + if(isString(tag)){
    tag = doc.createElement(tag);
    }
    if(attrs){ d.attr(tag, attrs); }
    @@ -1558,14 +1561,14 @@
    d.empty =
    //>>excludeStart("webkitMobile", kwArgs.webkitMobile);
    d.isIE ? function(node){
    - node = d.byId(node);
    + node = byId(node);
    for(var c; c = node.lastChild;){ // intentional assignment
    d.destroy(c);
    }
    } :
    //>>excludeEnd("webkitMobile");
    function(node){
    - d.byId(node).innerHTML = "";
    + byId(node).innerHTML = "";
    };

    /*=====
    @@ -1675,7 +1678,7 @@
    // example:
    // | if(dojo.hasClass("someNode","aSillyClassName")){ ... }

    - return ((" "+ d.byId(node)[_className] +" ").indexOf(" "+ classStr +" ")>= 0); // Boolean
    + return ((" "+ byId(node)[_className] +" ").indexOf(" "+ classStr +" ")>= 0); // Boolean
    };

    dojo.addClass = function(/*DomNode|String*/node, /*String*/classStr){
    @@ -1702,7 +1705,7 @@
    // Available in `dojo.NodeList` for multiple additions
    // | dojo.query("ul> li").addClass("firstLevel");

    - node = d.byId(node);
    + node = byId(node);
    var cls = node[_className];
    if((" "+ cls +" ").indexOf(" " + classStr + " ")< 0){
    node[_className] = cls + (cls ? ' ' : '') + classStr;
    @@ -1727,7 +1730,7 @@
    // Available in `dojo.NodeList` for multiple removal
    // | dojo.query(".foo").removeClass("foo");

    - node = d.byId(node);
    + node = byId(node);
    var t = d.trim((" " + node[_className] + " ").replace(" " + classStr + " ", " "));
    if(node[_className] != t){ node[_className] = t; }
    };
    _______________________________________________
    Dojo-checkins mailing list
    Dojo-checkins at mail.dojotoolkit.org
    http://mail.dojotoolkit.org/mailman/listinfo/dojo-checkins
    _______________________________________________
    dojo-contributors mailing list
    dojo-contributors at mail.dojotoolkit.org
    http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors

    --
    Peter E Higgins
    Dojo Project Lead : http://dojotoolkit.org
  • Nathan Toone at Apr 13, 2009 at 11:17 am
    I also agree - passing null is a fairly common occurance - especially
    if you aren't quite sure if it exists. It seems to me that it's
    better to put the null check in one place (dojo.byId) rather than
    every place that you may be using it.

    Personally, I'd also like to see the ability to pass null to
    dojo.addClass/removeClass, and some of the other html functions as
    well - it just makes it a bit more bullet-proof.

    -Nathan
    On Apr 13, 2009, at 7:54 AM, Peter E Higgins wrote:

    I like that we can pass anything (null included) and get back a truthy
    value. I expect that if dijit was relying on the behavior, others are
    as well.

    Bill Keese wrote:
    After the change below, dojo.byId() no longer works when passed a
    null/undefined argument, which breaks dijit since _Widget.js does:

    this.srcNodeRef = dojo.byId(srcNodeRef);

    Should we be supporting a null argument to dojo.byId()? The API doc
    doesn't say it's supported but maybe people are depending on it?
    (If we
    don't want to support it I can just update dijit to do a null check.)
    On 4/12/09 3:09 PM, dojo-checkins-admin at dojotoolkit.org wrote:

    Author: alex
    Date: Sat Apr 11 23:09:14 2009
    New Revision: 17266

    Modified:
    dojo/trunk/_base/html.js
    Log:
    create (and use) a local reference to dojo.byId() in order to
    boost addclass-odd test #'s on IE6. Very strange, but the
    performance difference is nearly order-of-magnitude (80ms vs>
    800ms).

    Refs #9114

    !strict


    Modified: dojo/trunk/_base/html.js
    =
    =
    =
    =
    =
    =
    =
    =
    =
    =
    ====================================================================
    --- dojo/trunk/_base/html.js (original)
    +++ dojo/trunk/_base/html.js Sat Apr 11 23:09:14 2009
    @@ -49,29 +49,28 @@
    //>>excludeStart("webkitMobile", kwArgs.webkitMobile);
    if(dojo.isIE || dojo.isOpera){
    dojo.byId = function(id, doc){
    - if(dojo.isString(id)){
    - var _d = doc || dojo.doc;
    - var te = _d.getElementById(id);
    - // attributes.id.value is better than just id in case the
    - // user has a name=id inside a form
    - if(te&& (te.attributes.id.value == id || te.id == id)){
    - return te;
    - }else{
    - var eles = _d.all[id];
    - if(!eles || eles.nodeName){
    - eles = [eles];
    - }
    - // if more than 1, choose first with the correct id
    - var i=0;
    - while((te=eles[i++])){
    - if((te.attributes&& te.attributes.id&&
    te.attributes.id.value == id)
    - || te.id == id){
    - return te;
    - }
    + if(id.nodeType){
    + return id;
    + }
    + var _d = doc || dojo.doc;
    + var te = _d.getElementById(id);
    + // attributes.id.value is better than just id in case the
    + // user has a name=id inside a form
    + if(te&& (te.attributes.id.value == id || te.id == id)){
    + return te;
    + }else{
    + var eles = _d.all[id];
    + if(!eles || eles.nodeName){
    + eles = [eles];
    + }
    + // if more than 1, choose first with the correct id
    + var i=0;
    + while((te=eles[i++])){
    + if((te.attributes&& te.attributes.id&&
    te.attributes.id.value == id)
    + || te.id == id){
    + return te;
    }
    }
    - }else{
    - return id; // DomNode
    }
    };
    }else{
    @@ -90,6 +89,8 @@
    (function(){
    var d = dojo;
    //>>excludeEnd("webkitMobile");
    + var byId = d.byId;
    + var isString = d.isString;

    var _destroyContainer = null;
    //>>excludeStart("webkitMobile", kwArgs.webkitMobile);
    @@ -125,7 +126,7 @@
    // Destroy all nodes in a list by reference:
    // | dojo.query(".someNode").forEach(dojo.destroy);

    - node = d.byId(node);
    + node = byId(node);
    try{
    if(!_destroyContainer || _destroyContainer.ownerDocument !=
    node.ownerDocument){
    _destroyContainer = node.ownerDocument.createElement("div");
    @@ -144,8 +145,8 @@
    // node: string id or node reference to test
    // ancestor: string id or node reference of potential parent to
    test against
    try{
    - node = d.byId(node);
    - ancestor = d.byId(ancestor);
    + node = byId(node);
    + ancestor = byId(ancestor);
    while(node){
    if(node === ancestor){
    return true; // Boolean
    @@ -163,7 +164,7 @@
    // selectable:
    // state to put the node in. false indicates unselectable, true
    // allows selection.
    - node = d.byId(node);
    + node = byId(node);
    //>>excludeStart("webkitMobile", kwArgs.webkitMobile);
    if(d.isMozilla){
    node.style.MozUserSelect = selectable ? "" : "none";
    @@ -244,9 +245,9 @@
    // Put a new LI as the first child of a list by id:
    // | dojo.place(dojo.create('li'), "someUl", "first");

    - refNode = d.byId(refNode);
    - if(d.isString(node)){
    - node = node.charAt(0) == "<" ? d._toDom(node,
    refNode.ownerDocument) : d.byId(node);
    + refNode = byId(refNode);
    + if(isString(node)){
    + node = node.charAt(0) == "<" ? d._toDom(node,
    refNode.ownerDocument) : byId(node);
    }
    if(typeof position == "number"){
    var cn = refNode.childNodes;
    @@ -614,7 +615,7 @@
    // | fontSize:"13pt"
    // | });

    - var n = d.byId(node), args = arguments.length, op = (style ==
    "opacity");
    + var n = byId(node), args = arguments.length, op = (style ==
    "opacity");
    style = _floatAliases[style] || style;
    if(args == 3){
    return op ? d._setOpacity(n, value) : n.style[style] = value; /
    *Number*/
    @@ -623,7 +624,7 @@
    return d._getOpacity(n);
    }
    var s = gcs(n);
    - if(args == 2&& !d.isString(style)){
    + if(args == 2&& !isString(style)){
    for(var x in style){
    d.style(node, x, style[x]);
    }
    @@ -976,7 +977,7 @@
    // If passed, denotes that dojo.marginBox() should
    // update/set the margin box for node. Box is an object in the
    // above format. All properties are optional if passed.
    - var n = d.byId(node), s = gcs(n), b = box;
    + var n = byId(node), s = gcs(n), b = box;
    return !b ? d._getMarginBox(n, s) : d._setMarginBox(n, b.l,
    b.t, b.w, b.h, s); // Object
    }

    @@ -998,7 +999,7 @@
    // If passed, denotes that dojo.contentBox() should
    // update/set the content box for node. Box is an object in the
    // above format. All properties are optional if passed.
    - var n = d.byId(node), s = gcs(n), b = box;
    + var n = byId(node), s = gcs(n), b = box;
    return !b ? d._getContentBox(n, s) : d._setContentSize(n, b.w,
    b.h, s); // Object
    }

    @@ -1214,7 +1215,7 @@
    //| { l: 50, t: 200, w: 300: h: 150, x: 100, y: 300 }
    // Does not act as a setter. If includeScroll is passed, the x
    and
    // y params are affected as one would expect in dojo._abs().
    - var n = d.byId(node), s = gcs(n), mb = d._getMarginBox(n, s);
    + var n = byId(node), s = gcs(n), mb = d._getMarginBox(n, s);
    var abs = d._abs(n, includeScroll);
    mb.x = abs.x;
    mb.y = abs.y;
    @@ -1284,7 +1285,7 @@
    // returns:
    // true if the requested attribute is specified on the
    // given element, and false otherwise
    - node = d.byId(node);
    + node = byId(node);
    var fixName = _fixAttrName(name);
    fixName = fixName == "htmlFor" ? "for" : fixName; //IE<8 uses
    htmlFor except in this case
    var attr = node.getAttributeNode&&
    node.getAttributeNode(fixName);
    @@ -1379,11 +1380,13 @@
    // | // though shorter to use `dojo.style` in this case:
    // | dojo.style("someNode", obj);

    - node = d.byId(node);
    + node = byId(node);
    var args = arguments.length;
    - if(args == 2&& !d.isString(name)){
    + if(args == 2&& !isString(name)){
    // the object form of setter: the 2nd argument is a dictionary
    - for(var x in name){ d.attr(node, x, name[x]); }
    + for(var x in name){
    + d.attr(node, x, name[x]);
    + }
    // FIXME: return the node in this case? could be useful.
    return;
    }
    @@ -1413,7 +1416,7 @@

    }else if(typeof value == "boolean"){ // e.g. onsubmit, disabled
    node[name] = value;
    - }else if(name === "style"&& !d.isString(value)){
    + }else if(name === "style"&& !isString(value)){
    // when the name is "style" and value is an object, pass along
    d.style(node, value);
    }else if(name == "className"){
    @@ -1453,7 +1456,7 @@
    // id or reference to the element to remove the attribute from
    // name:
    // the name of the attribute to remove
    - d.byId(node).removeAttribute(_fixAttrName(name));
    + byId(node).removeAttribute(_fixAttrName(name));
    }

    dojo.create = function(tag, attrs, refNode, pos){
    @@ -1528,10 +1531,10 @@

    var doc = d.doc;
    if(refNode){
    - refNode = d.byId(refNode);
    + refNode = byId(refNode);
    doc = refNode.ownerDocument;
    }
    - if(d.isString(tag)){
    + if(isString(tag)){
    tag = doc.createElement(tag);
    }
    if(attrs){ d.attr(tag, attrs); }
    @@ -1558,14 +1561,14 @@
    d.empty =
    //>>excludeStart("webkitMobile", kwArgs.webkitMobile);
    d.isIE ? function(node){
    - node = d.byId(node);
    + node = byId(node);
    for(var c; c = node.lastChild;){ // intentional assignment
    d.destroy(c);
    }
    } :
    //>>excludeEnd("webkitMobile");
    function(node){
    - d.byId(node).innerHTML = "";
    + byId(node).innerHTML = "";
    };

    /*=====
    @@ -1675,7 +1678,7 @@
    // example:
    // | if(dojo.hasClass("someNode","aSillyClassName")){ ... }

    - return ((" "+ d.byId(node)[_className] +" ").indexOf(" "+
    classStr +" ")>= 0); // Boolean
    + return ((" "+ byId(node)[_className] +" ").indexOf(" "+
    classStr +" ")>= 0); // Boolean
    };

    dojo.addClass = function(/*DomNode|String*/node, /*String*/
    classStr){
    @@ -1702,7 +1705,7 @@
    // Available in `dojo.NodeList` for multiple additions
    // | dojo.query("ul> li").addClass("firstLevel");

    - node = d.byId(node);
    + node = byId(node);
    var cls = node[_className];
    if((" "+ cls +" ").indexOf(" " + classStr + " ")< 0){
    node[_className] = cls + (cls ? ' ' : '') + classStr;
    @@ -1727,7 +1730,7 @@
    // Available in `dojo.NodeList` for multiple removal
    // | dojo.query(".foo").removeClass("foo");

    - node = d.byId(node);
    + node = byId(node);
    var t = d.trim((" " + node[_className] + " ").replace(" " +
    classStr + " ", " "));
    if(node[_className] != t){ node[_className] = t; }
    };
    _______________________________________________
    Dojo-checkins mailing list
    Dojo-checkins at mail.dojotoolkit.org
    http://mail.dojotoolkit.org/mailman/listinfo/dojo-checkins
    _______________________________________________
    dojo-contributors mailing list
    dojo-contributors at mail.dojotoolkit.org
    http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors

    --
    Peter E Higgins
    Dojo Project Lead : http://dojotoolkit.org

    _______________________________________________
    dojo-contributors mailing list
    dojo-contributors at mail.dojotoolkit.org
    http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors
  • Sam foster at Apr 13, 2009 at 12:02 pm
    In the flip side, being permissive propagates an error, making it
    harder to track down. I'm on the fence here - there's cases where you
    want to call dojo.byId and not have to check the result each time, and
    there's cases where you want it to fail, so you dont accidently pass a
    null into dojo.style or whatever.

    dojo._getText has an optional 2nd param:

    fail_ok:
    Default false. If fail_ok and loading fails, return null
    instead of throwing.

    I wonder if that might be useful here . We'd default to true as that's
    the historical behavior, and it would have to be the 3rd param, as the
    2nd is already used to provide a document to match the id in.

    Ok, I know this is ugly, but I do think both expectations are valid.
    Another way of looking at it is, if dojo.byId is truly cheap now,
    maybe its better to recommend users do: if( dojo.byId( foo ) &&
    dojo.byId( foo ).whatever ) - i.e. call it twice - the first time as a
    null/truthiness check, and the second time to "deference" the id to a
    node.

    /Sam
    On Mon, Apr 13, 2009 at 4:17 PM, Nathan Toone wrote:
    I also agree - passing null is a fairly common occurance - especially
    if you aren't quite sure if it exists. ?It seems to me that it's
    better to put the null check in one place (dojo.byId) rather than
    every place that you may be using it.

    Personally, I'd also like to see the ability to pass null to
    dojo.addClass/removeClass, and some of the other html functions as
    well - it just makes it a bit more bullet-proof.

    -Nathan
  • Mike Wilcox at Apr 13, 2009 at 12:30 pm
    I'd like to point out that I prefer dojo never fails (where possible)
    - I would rather my code fails. Errors like "n is null" or "args is
    undefined" can be extremely difficult to track down, especially for
    dojo devs of moderate or less experience, and even harder when you
    jump into the middle of a large app that throws errors.

    It looks like this can only work for when something is returned. So
    using dojo.style(node, style, value) probably needs to fail in dojo,
    whereas dojo.style(node, style) could return null or false.

    So my vote is for byId allowing null.

    Mike Wilcox
    mwilcox at sitepen.com
    http://www.sitepen.com
    work: 650.968.8787 x218
    cell: 214.697.4872
    On Apr 13, 2009, at 11:02 AM, sam foster wrote:

    In the flip side, being permissive propagates an error, making it
    harder to track down. I'm on the fence here - there's cases where you
    want to call dojo.byId and not have to check the result each time, and
    there's cases where you want it to fail, so you dont accidently pass a
    null into dojo.style or whatever.

    dojo._getText has an optional 2nd param:

    fail_ok:
    Default false. If fail_ok and loading fails, return null
    instead of throwing.

    I wonder if that might be useful here . We'd default to true as that's
    the historical behavior, and it would have to be the 3rd param, as the
    2nd is already used to provide a document to match the id in.

    Ok, I know this is ugly, but I do think both expectations are valid.
    Another way of looking at it is, if dojo.byId is truly cheap now,
    maybe its better to recommend users do: if( dojo.byId( foo ) &&
    dojo.byId( foo ).whatever ) - i.e. call it twice - the first time as a
    null/truthiness check, and the second time to "deference" the id to a
    node.

    /Sam

    On Mon, Apr 13, 2009 at 4:17 PM, Nathan Toone <toonetown at dojotoolkit.org
    wrote:
    I also agree - passing null is a fairly common occurance - especially
    if you aren't quite sure if it exists. It seems to me that it's
    better to put the null check in one place (dojo.byId) rather than
    every place that you may be using it.

    Personally, I'd also like to see the ability to pass null to
    dojo.addClass/removeClass, and some of the other html functions as
    well - it just makes it a bit more bullet-proof.

    -Nathan
    _______________________________________________
    dojo-contributors mailing list
    dojo-contributors at mail.dojotoolkit.org
    http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors
  • Alex Russell at Apr 13, 2009 at 12:36 pm
    Will fix if you add a unit test. The intent wasn't to change behavior
    but were motivated by a striking performance differential on IE for
    the before and after behaviors. I think there's a way to accommodate
    the old null behavior and keep the speed. FWIW, there will be more
    changes like this coming in the next week or two, so if everyone could
    keep a watchful eye for these kinds of regressions, it would be most
    helpful. I'll keep running the core unit tests as I optimize, so help
    in making sure they test all the cases we're actually using is most
    appreciated.

    Thanks again for spotting this and apologies for the inconvenience.

    Regards
    On Mon, Apr 13, 2009 at 12:24 AM, Bill Keese wrote:
    After the change below, dojo.byId() no longer works when passed a
    null/undefined argument, which breaks dijit since _Widget.js does:

    ? ? ? ?this.srcNodeRef = dojo.byId(srcNodeRef);

    Should we be supporting a null argument to dojo.byId()? ?The API doc
    doesn't say it's supported but maybe people are depending on it? ?(If we
    don't want to support it I can just update dijit to do a null check.)
    On 4/12/09 3:09 PM, dojo-checkins-admin at dojotoolkit.org wrote:
    Author: alex
    Date: Sat Apr 11 23:09:14 2009
    New Revision: 17266

    Modified:
    ? ? dojo/trunk/_base/html.js
    Log:
    create (and use) a local reference to dojo.byId() in order to boost addclass-odd test #'s on IE6. Very strange, but the performance difference is nearly order-of-magnitude (80ms vs> ?800ms).

    Refs #9114

    !strict


    Modified: dojo/trunk/_base/html.js
    ==============================================================================
    --- dojo/trunk/_base/html.js ?(original)
    +++ dojo/trunk/_base/html.js ?Sat Apr 11 23:09:14 2009
    @@ -49,29 +49,28 @@
    ? //>>excludeStart("webkitMobile", kwArgs.webkitMobile);
    ? if(dojo.isIE || dojo.isOpera){
    ? ? ? dojo.byId = function(id, doc){
    - ? ? ? ? ? ? if(dojo.isString(id)){
    - ? ? ? ? ? ? ? ? ? ? var _d = doc || dojo.doc;
    - ? ? ? ? ? ? ? ? ? ? var te = _d.getElementById(id);
    - ? ? ? ? ? ? ? ? ? ? // attributes.id.value is better than just id in case the
    - ? ? ? ? ? ? ? ? ? ? // user has a name=id inside a form
    - ? ? ? ? ? ? ? ? ? ? if(te&& ?(te.attributes.id.value == id || te.id == id)){
    - ? ? ? ? ? ? ? ? ? ? ? ? ? ? return te;
    - ? ? ? ? ? ? ? ? ? ? }else{
    - ? ? ? ? ? ? ? ? ? ? ? ? ? ? var eles = _d.all[id];
    - ? ? ? ? ? ? ? ? ? ? ? ? ? ? if(!eles || eles.nodeName){
    - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? eles = [eles];
    - ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
    - ? ? ? ? ? ? ? ? ? ? ? ? ? ? // if more than 1, choose first with the correct id
    - ? ? ? ? ? ? ? ? ? ? ? ? ? ? var i=0;
    - ? ? ? ? ? ? ? ? ? ? ? ? ? ? while((te=eles[i++])){
    - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if((te.attributes&& ?te.attributes.id&& ?te.attributes.id.value == id)
    - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? || te.id == id){
    - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return te;
    - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
    + ? ? ? ? ? ? if(id.nodeType){
    + ? ? ? ? ? ? ? ? ? ? return id;
    + ? ? ? ? ? ? }
    + ? ? ? ? ? ? var _d = doc || dojo.doc;
    + ? ? ? ? ? ? var te = _d.getElementById(id);
    + ? ? ? ? ? ? // attributes.id.value is better than just id in case the
    + ? ? ? ? ? ? // user has a name=id inside a form
    + ? ? ? ? ? ? if(te&& ?(te.attributes.id.value == id || te.id == id)){
    + ? ? ? ? ? ? ? ? ? ? return te;
    + ? ? ? ? ? ? }else{
    + ? ? ? ? ? ? ? ? ? ? var eles = _d.all[id];
    + ? ? ? ? ? ? ? ? ? ? if(!eles || eles.nodeName){
    + ? ? ? ? ? ? ? ? ? ? ? ? ? ? eles = [eles];
    + ? ? ? ? ? ? ? ? ? ? }
    + ? ? ? ? ? ? ? ? ? ? // if more than 1, choose first with the correct id
    + ? ? ? ? ? ? ? ? ? ? var i=0;
    + ? ? ? ? ? ? ? ? ? ? while((te=eles[i++])){
    + ? ? ? ? ? ? ? ? ? ? ? ? ? ? if((te.attributes&& ?te.attributes.id&& ?te.attributes.id.value == id)
    + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? || te.id == id){
    + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return te;
    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
    ? ? ? ? ? ? ? ? ? ? ? }
    - ? ? ? ? ? ? }else{
    - ? ? ? ? ? ? ? ? ? ? return id; // DomNode
    ? ? ? ? ? ? ? }
    ? ? ? };
    ? }else{
    @@ -90,6 +89,8 @@
    ? (function(){
    ? ? ? var d = dojo;
    ? //>>excludeEnd("webkitMobile");
    + ? ? var byId = d.byId;
    + ? ? var isString = d.isString;

    ? ? ? var _destroyContainer = null;
    ? ? ? //>>excludeStart("webkitMobile", kwArgs.webkitMobile);
    @@ -125,7 +126,7 @@
    ? ? ? ? ? ? ? // ? ? ?Destroy all nodes in a list by reference:
    ? ? ? ? ? ? ? // ? ? ?| dojo.query(".someNode").forEach(dojo.destroy);

    - ? ? ? ? ? ? node = d.byId(node);
    + ? ? ? ? ? ? node = byId(node);
    ? ? ? ? ? ? ? try{
    ? ? ? ? ? ? ? ? ? ? ? if(!_destroyContainer || _destroyContainer.ownerDocument != node.ownerDocument){
    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? _destroyContainer = node.ownerDocument.createElement("div");
    @@ -144,8 +145,8 @@
    ? ? ? ? ? ? ? // ? ? ?node: string id or node reference to test
    ? ? ? ? ? ? ? // ? ? ?ancestor: string id or node reference of potential parent to test against
    ? ? ? ? ? ? ? try{
    - ? ? ? ? ? ? ? ? ? ? node = d.byId(node);
    - ? ? ? ? ? ? ? ? ? ? ancestor = d.byId(ancestor);
    + ? ? ? ? ? ? ? ? ? ? node = byId(node);
    + ? ? ? ? ? ? ? ? ? ? ancestor = byId(ancestor);
    ? ? ? ? ? ? ? ? ? ? ? while(node){
    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if(node === ancestor){
    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return true; // Boolean
    @@ -163,7 +164,7 @@
    ? ? ? ? ? ? ? // ? ? ?selectable:
    ? ? ? ? ? ? ? // ? ? ? ? ? ? ?state to put the node in. false indicates unselectable, true
    ? ? ? ? ? ? ? // ? ? ? ? ? ? ?allows selection.
    - ? ? ? ? ? ? node = d.byId(node);
    + ? ? ? ? ? ? node = byId(node);
    ? ? ? ? ? ? ? //>>excludeStart("webkitMobile", kwArgs.webkitMobile);
    ? ? ? ? ? ? ? if(d.isMozilla){
    ? ? ? ? ? ? ? ? ? ? ? node.style.MozUserSelect = selectable ? "" : "none";
    @@ -244,9 +245,9 @@
    ? ? ? ? ? ? ? // ? ? ? ? ? ? ?Put a new LI as the first child of a list by id:
    ? ? ? ? ? ? ? // | ? ?dojo.place(dojo.create('li'), "someUl", "first");

    - ? ? ? ? ? ? refNode = d.byId(refNode);
    - ? ? ? ? ? ? if(d.isString(node)){
    - ? ? ? ? ? ? ? ? ? ? node = node.charAt(0) == "<" ? d._toDom(node, refNode.ownerDocument) : d.byId(node);
    + ? ? ? ? ? ? refNode = byId(refNode);
    + ? ? ? ? ? ? if(isString(node)){
    + ? ? ? ? ? ? ? ? ? ? node = node.charAt(0) == "<" ? d._toDom(node, refNode.ownerDocument) : byId(node);
    ? ? ? ? ? ? ? }
    ? ? ? ? ? ? ? if(typeof position == "number"){
    ? ? ? ? ? ? ? ? ? ? ? var cn = refNode.childNodes;
    @@ -614,7 +615,7 @@
    ? ? ? ? ? ? ? // ? ? ?| ? ? ? ? ? ? ? fontSize:"13pt"
    ? ? ? ? ? ? ? // ? ? ?| ? ? ? });

    - ? ? ? ? ? ? var n = d.byId(node), args = arguments.length, op = (style == "opacity");
    + ? ? ? ? ? ? var n = byId(node), args = arguments.length, op = (style == "opacity");
    ? ? ? ? ? ? ? style = _floatAliases[style] || style;
    ? ? ? ? ? ? ? if(args == 3){
    ? ? ? ? ? ? ? ? ? ? ? return op ? d._setOpacity(n, value) : n.style[style] = value; /*Number*/
    @@ -623,7 +624,7 @@
    ? ? ? ? ? ? ? ? ? ? ? return d._getOpacity(n);
    ? ? ? ? ? ? ? }
    ? ? ? ? ? ? ? var s = gcs(n);
    - ? ? ? ? ? ? if(args == 2&& ?!d.isString(style)){
    + ? ? ? ? ? ? if(args == 2&& ?!isString(style)){
    ? ? ? ? ? ? ? ? ? ? ? for(var x in style){
    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? d.style(node, x, style[x]);
    ? ? ? ? ? ? ? ? ? ? ? }
    @@ -976,7 +977,7 @@
    ? ? ? ? ? ? ? // ? ? ? ? ? ? ?If passed, denotes that dojo.marginBox() should
    ? ? ? ? ? ? ? // ? ? ? ? ? ? ?update/set the margin box for node. Box is an object in the
    ? ? ? ? ? ? ? // ? ? ? ? ? ? ?above format. All properties are optional if passed.
    - ? ? ? ? ? ? var n = d.byId(node), s = gcs(n), b = box;
    + ? ? ? ? ? ? var n = byId(node), s = gcs(n), b = box;
    ? ? ? ? ? ? ? return !b ? d._getMarginBox(n, s) : d._setMarginBox(n, b.l, b.t, b.w, b.h, s); // Object
    ? ? ? }

    @@ -998,7 +999,7 @@
    ? ? ? ? ? ? ? // ? ? ? ? ? ? ?If passed, denotes that dojo.contentBox() should
    ? ? ? ? ? ? ? // ? ? ? ? ? ? ?update/set the content box for node. Box is an object in the
    ? ? ? ? ? ? ? // ? ? ? ? ? ? ?above format. All properties are optional if passed.
    - ? ? ? ? ? ? var n = d.byId(node), s = gcs(n), b = box;
    + ? ? ? ? ? ? var n = byId(node), s = gcs(n), b = box;
    ? ? ? ? ? ? ? return !b ? d._getContentBox(n, s) : d._setContentSize(n, b.w, b.h, s); // Object
    ? ? ? }

    @@ -1214,7 +1215,7 @@
    ? ? ? ? ? ? ? //| ? ? ? ? ? ? ? ? ? ? { l: 50, t: 200, w: 300: h: 150, x: 100, y: 300 }
    ? ? ? ? ? ? ? // ? ? ? ? ? ? ?Does not act as a setter. If includeScroll is passed, the x and
    ? ? ? ? ? ? ? // ? ? ? ? ? ? ?y params are affected as one would expect in dojo._abs().
    - ? ? ? ? ? ? var n = d.byId(node), s = gcs(n), mb = d._getMarginBox(n, s);
    + ? ? ? ? ? ? var n = byId(node), s = gcs(n), mb = d._getMarginBox(n, s);
    ? ? ? ? ? ? ? var abs = d._abs(n, includeScroll);
    ? ? ? ? ? ? ? mb.x = abs.x;
    ? ? ? ? ? ? ? mb.y = abs.y;
    @@ -1284,7 +1285,7 @@
    ? ? ? ? ? ? ? // ? ? ?returns:
    ? ? ? ? ? ? ? // ? ? ? ? ? ? ?true if the requested attribute is specified on the
    ? ? ? ? ? ? ? // ? ? ? ? ? ? ?given element, and false otherwise
    - ? ? ? ? ? ? node = d.byId(node);
    + ? ? ? ? ? ? node = byId(node);
    ? ? ? ? ? ? ? var fixName = _fixAttrName(name);
    ? ? ? ? ? ? ? fixName = fixName == "htmlFor" ? "for" : fixName; //IE<8 uses htmlFor except in this case
    ? ? ? ? ? ? ? var attr = node.getAttributeNode&& ?node.getAttributeNode(fixName);
    @@ -1379,11 +1380,13 @@
    ? ? ? ? ? ? ? // ? ? ?| ? ? ? // though shorter to use `dojo.style` in this case:
    ? ? ? ? ? ? ? // ? ? ?| ? ? ? dojo.style("someNode", obj);

    - ? ? ? ? ? ? node = d.byId(node);
    + ? ? ? ? ? ? node = byId(node);
    ? ? ? ? ? ? ? var args = arguments.length;
    - ? ? ? ? ? ? if(args == 2&& ?!d.isString(name)){
    + ? ? ? ? ? ? if(args == 2&& ?!isString(name)){
    ? ? ? ? ? ? ? ? ? ? ? // the object form of setter: the 2nd argument is a dictionary
    - ? ? ? ? ? ? ? ? ? ? for(var x in name){ d.attr(node, x, name[x]); }
    + ? ? ? ? ? ? ? ? ? ? for(var x in name){
    + ? ? ? ? ? ? ? ? ? ? ? ? ? ? d.attr(node, x, name[x]);
    + ? ? ? ? ? ? ? ? ? ? }
    ? ? ? ? ? ? ? ? ? ? ? // FIXME: return the node in this case? could be useful.
    ? ? ? ? ? ? ? ? ? ? ? return;
    ? ? ? ? ? ? ? }
    @@ -1413,7 +1416,7 @@

    ? ? ? ? ? ? ? ? ? ? ? }else if(typeof value == "boolean"){ // e.g. onsubmit, disabled
    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? node[name] = value;
    - ? ? ? ? ? ? ? ? ? ? }else if(name === "style"&& ?!d.isString(value)){
    + ? ? ? ? ? ? ? ? ? ? }else if(name === "style"&& ?!isString(value)){
    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // when the name is "style" and value is an object, pass along
    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? d.style(node, value);
    ? ? ? ? ? ? ? ? ? ? ? }else if(name == "className"){
    @@ -1453,7 +1456,7 @@
    ? ? ? ? ? ? ? // ? ? ? ? ? ? ?id or reference to the element to remove the attribute from
    ? ? ? ? ? ? ? // ? ? ?name:
    ? ? ? ? ? ? ? // ? ? ? ? ? ? ?the name of the attribute to remove
    - ? ? ? ? ? ? d.byId(node).removeAttribute(_fixAttrName(name));
    + ? ? ? ? ? ? byId(node).removeAttribute(_fixAttrName(name));
    ? ? ? }

    ? ? ? dojo.create = function(tag, attrs, refNode, pos){
    @@ -1528,10 +1531,10 @@

    ? ? ? ? ? ? ? var doc = d.doc;
    ? ? ? ? ? ? ? if(refNode){
    - ? ? ? ? ? ? ? ? ? ? refNode = d.byId(refNode);
    + ? ? ? ? ? ? ? ? ? ? refNode = byId(refNode);
    ? ? ? ? ? ? ? ? ? ? ? doc = refNode.ownerDocument;
    ? ? ? ? ? ? ? }
    - ? ? ? ? ? ? if(d.isString(tag)){
    + ? ? ? ? ? ? if(isString(tag)){
    ? ? ? ? ? ? ? ? ? ? ? tag = doc.createElement(tag);
    ? ? ? ? ? ? ? }
    ? ? ? ? ? ? ? if(attrs){ d.attr(tag, attrs); }
    @@ -1558,14 +1561,14 @@
    ? ? ? d.empty =
    ? ? ? ? ? ? ? //>>excludeStart("webkitMobile", kwArgs.webkitMobile);
    ? ? ? ? ? ? ? d.isIE ? ?function(node){
    - ? ? ? ? ? ? ? ? ? ? node = d.byId(node);
    + ? ? ? ? ? ? ? ? ? ? node = byId(node);
    ? ? ? ? ? ? ? ? ? ? ? for(var c; c = node.lastChild;){ // intentional assignment
    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? d.destroy(c);
    ? ? ? ? ? ? ? ? ? ? ? }
    ? ? ? ? ? ? ? } :
    ? ? ? ? ? ? ? //>>excludeEnd("webkitMobile");
    ? ? ? ? ? ? ? function(node){
    - ? ? ? ? ? ? ? ? ? ? d.byId(node).innerHTML = "";
    + ? ? ? ? ? ? ? ? ? ? byId(node).innerHTML = "";
    ? ? ? ? ? ? ? };

    ? ? ? /*=====
    @@ -1675,7 +1678,7 @@
    ? ? ? ? ? ? ? // ? ? ?example:
    ? ? ? ? ? ? ? // ? ? ?| if(dojo.hasClass("someNode","aSillyClassName")){ ... }

    - ? ? ? ? ? ? return ((" "+ d.byId(node)[_className] +" ").indexOf(" "+ classStr +" ")>= 0); ?// Boolean
    + ? ? ? ? ? ? return ((" "+ byId(node)[_className] +" ").indexOf(" "+ classStr +" ")>= 0); ?// Boolean
    ? ? ? };

    ? ? ? dojo.addClass = function(/*DomNode|String*/node, /*String*/classStr){
    @@ -1702,7 +1705,7 @@
    ? ? ? ? ? ? ? // ? ? ?Available in `dojo.NodeList` for multiple additions
    ? ? ? ? ? ? ? // ? ? ?| dojo.query("ul> ?li").addClass("firstLevel");

    - ? ? ? ? ? ? node = d.byId(node);
    + ? ? ? ? ? ? node = byId(node);
    ? ? ? ? ? ? ? var cls = node[_className];
    ? ? ? ? ? ? ? if((" "+ cls +" ").indexOf(" " + classStr + " ")< ?0){
    ? ? ? ? ? ? ? ? ? ? ? node[_className] = cls + (cls ? ' ' : '') + classStr;
    @@ -1727,7 +1730,7 @@
    ? ? ? ? ? ? ? // ? ? ?Available in `dojo.NodeList` for multiple removal
    ? ? ? ? ? ? ? // ? ? ?| dojo.query(".foo").removeClass("foo");

    - ? ? ? ? ? ? node = d.byId(node);
    + ? ? ? ? ? ? node = byId(node);
    ? ? ? ? ? ? ? var t = d.trim((" " + node[_className] + " ").replace(" " + classStr + " ", " "));
    ? ? ? ? ? ? ? if(node[_className] != t){ node[_className] = t; }
    ? ? ? };
    _______________________________________________
    Dojo-checkins mailing list
    Dojo-checkins at mail.dojotoolkit.org
    http://mail.dojotoolkit.org/mailman/listinfo/dojo-checkins
    _______________________________________________
    dojo-contributors mailing list
    dojo-contributors at mail.dojotoolkit.org
    http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors
  • Bill Keese at Apr 14, 2009 at 12:52 am

    On 4/14/09 1:36 AM, Alex Russell wrote:
    Will fix if you add a unit test.
    OK thanks, I checked one in in [17277].

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdojo-contributors @
categoriesdojo
postedApr 13, '09 at 3:24a
activeApr 14, '09 at 12:52a
posts7
users6
websitedojotoolkit.org

People

Translate

site design / logo © 2022 Grokbase