The node.canHaveChildren is always null in non-ie browsers.
I agree that's a weird check, perhaps it should say this instead?
if("innerHTML" in node)
Actually the if()
condition is unnecessary -- we can always run the code in the try/catch -- but it prevents spurious throws that are annoying when using the debugger.
If I have a node with some child dijit widget, in elder versions, it do innerHtml = "", when I run empty on this node, the widget.domNode will still kept as a detached dom node. While in 1.9.3, if we use removeChild here, the domNode in all child widget will be cleaned.
I guess so... actually the fallback for()
loop seems strange, I see it has a comment that:
// destroy is better than removeChild so TABLE subelements are removed in proper order
...but I don't get it. Seems like removeChild() is fine. So probably this makes sense:
function _empty(/*DomNode*/ node){
if("innerHTML" in node){
try{
// fast path
node.innerHTML = "";
return;
}catch(e){
// innerHTML is readOnly (e.g. TABLE (sub)elements in quirks mode)
// Fall through (saves bytes)
}
}
// SVG/strict elements don't support innerHTML
for(var c; c = node.lastChild;){ // intentional assignment
node.removeChild(c);
}
}
Comments?