Opened 7 years ago

Last modified 7 years ago

#17869 closed defect

function empty() in dom-construct.js doens't work reasonable in non-IE browser — at Initial Version

Reported by: RickyShi Owned by:
Priority: undecided Milestone: 1.10
Component: HTML Version: 1.9.3
Keywords: Cc:
Blocked By: Blocking:


I saw something updated in Fixes #16975. Remove leak when calling empty() on SVG elements.


function _empty(/*DomNode?*/ node){



The node.canHaveChildren is always null in non-ie browsers. So all the process will path to _destroy

function _destroy(/*DomNode?*/ node, /*DomNode?*/ parent){

in IE quirks, node.canHaveChildren can be false but firstChild can be non-null (OBJECT/APPLET) if(node.firstChild){


} if(parent){

removeNode(false) doesn't leak in IE 6+, but removeChild() and removeNode(true) are known to leak under IE 8- while 9+ is TBD. In IE quirks mode, PARAM nodes as children of OBJECT/APPLET nodes have a removeNode method that does nothing and the parent node has canHaveChildren=false even though removeChild correctly removes the PARAM children. In IE, SVG/strict nodes don't have a removeNode method nor a canHaveChildren boolean. has("ie") && parent.canHaveChildren && "removeNode" in node ? node.removeNode(false) : parent.removeChild(node);



Because of the wrong logic in call stack the removeChild(node) will be always invoked no matter the browser is IE or Firefox. That's the reason why dojo.empty still works.

But in some cases it will take issue.

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.

On my opinion, the empty should just clean the dom tree, should not to clean the linked widget's properties. I think it should be rollback.


Change History (0)

Note: See TracTickets for help on using tickets.