Opened 13 years ago

Closed 12 years ago

#3206 closed task (fixed)

Port dojo.lang.shallowCopy to Dojo 0.9

Reported by: Tom Trenka Owned by: alex
Priority: high Milestone: 1.0
Component: Core Version: 0.9
Keywords: Cc:
Blocked By: Blocking:

Description

The shallowCopy method in dojo.lang (0.4) is used fairly often in some other parts of the code base (particularly dojox.gfx); if this could be ported to Dojo Core, that'd be awesome. There's a comment in it asking "why tf is it called shallowCopy?"; suggestions for a better name would be dojo.clone() or dojo.copy().

Change History (2)

comment:1 Changed 12 years ago by bill

Milestone: 1.0

See lang.js. There's a dojo.clone() function there already except that it's commented out.

// FIXME: this is unreviewed dojo.clone() function, 
// which can clone any objects including HTML nodes

//dojo.clone = function(/*anything*/ o){
//	// summary:
//	//		Clones objects (including DOM nodes) and all children.
//	//		Warning: do not clone cyclic structures.
//	if(!o){ return o; }
//	if(dojo.isArray(o)){
//		var r = [];
//		for(var i = 0; i < o.length; ++i){
//			r.push(dojo.clone(o[i]));
//		}
//		return r;
//	}else if(dojo.isObject(o)){
//		if(o.nodeType && o.cloneNode){ // isNode
//			return o.cloneNode(true);
//		}else{
//			var r = new o.constructor();
//			for(var i in o){
//				if(!(i in r) || r[i] != o[i]){
//					r[i] = dojo.clone(o[i]);
//				}
//			}
//			return r;
//		}
//	}
//	return o;
//}

comment:2 Changed 12 years ago by alex

Resolution: fixed
Status: newclosed

dojo.clone() made it into 0.9

Note: See TracTickets for help on using tickets.