Changes between Initial Version and Version 1 of Ticket #17869


Ignore:
Timestamp:
Apr 21, 2014, 1:19:08 AM (6 years ago)
Author:
bill
Comment:

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?

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #17869

    • Property Owner set to Eugene Lazutkin
    • Property Component changed from Core to HTML
  • Ticket #17869 – Description

    initial v1  
    22
    33e.g.
    4         function _empty(/*DomNode*/ node){
    5                 '''if(node.canHaveChildren){'''
    6                         try{
    74
    8 The node.canHaveChildren is always null in non-ie browsers. So all the process will path to _destroy
     5function _empty(/*DomNode*/ node){[[BR]]
     6        '''if(node.canHaveChildren){'''[[BR]]
     7                try{[[BR]]
     8
     9
     10The node.canHaveChildren is always null in non-ie browsers. So all the process will path to _destroy:
     11
     12{{{
    913        function _destroy(/*DomNode*/ node, /*DomNode*/ parent){
    1014                // in IE quirks, node.canHaveChildren can be false but firstChild can be non-null (OBJECT/APPLET)
     
    2024                }
    2125        }
     26}}}
    2227
    2328Because of the wrong logic in call stack