context: dojo.widget.createWidget = function(name, props, refNode, position){	var isNode = false;	var isNameStr = (typeof name == "string");	if(isNameStr){		var pos = name.indexOf(":");		var ns = (pos > -1) ? name.substring(0,pos) : "dojo";		if(pos > -1){ name = name.substring(pos+1); }		var lowerCaseName = name.toLowerCase();		var namespacedName = ns + ":" + lowerCaseName;		isNode = (dojo.byId(name) && (!dojo.widget.tags[namespacedName])); 	}	if((arguments.length == 1) && ((isNode)||(!isNameStr))){		// we got a DOM node 		var xp = new dojo.xml.Parse(); 		// FIXME: we should try to find the parent! 		var tn = (isNode) ? dojo.byId(name) : name; 		return dojo.widget.getParser().createComponents(xp.parseElement(tn, null, true))[0]; 	}		function fromScript(placeKeeperNode, name, props, ns){		props[namespacedName] = { 			dojotype: [{value: lowerCaseName}],			nodeRef: placeKeeperNode,			fastMixIn: true		};		props.ns = ns;		return dojo.widget.getParser().createComponentFromScript(placeKeeperNode, name, props, ns);	}	props = props||{};	var notRef = false;	var tn = null;	var h = dojo.render.html.capable;	if(h){		tn = document.createElement("span");	}	if(!refNode){		notRef = true;		refNode = tn;		if(h){			dojo.body().appendChild(refNode);		}	}else if(position){		dojo.dom.insertAtPosition(tn, refNode, position);	}else{ // otherwise don't replace, but build in-place		tn = refNode;	}	var widgetArray = fromScript(tn, name.toLowerCase(), props, ns);	if(	(!widgetArray)||(!widgetArray[0])||		(typeof widgetArray[0].widgetType == "undefined") ){		throw new Error("createWidget: Creation of \"" + name + "\" widget failed.");	}	try{		if(notRef){			if(widgetArray[0].domNode.parentNode){				widgetArray[0].domNode.parentNode.removeChild(widgetArray[0].domNode);			}		}	}catch(e){		/* squelch for Safari */		dojo.debug(e);	}	return widgetArray[0]; // just return the widget}
meta: 4707	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/4707/50c3492c4c3c825dbd3401e134a19ed46799c456/Parse.js/clean/www/resources/dojo-ajax/src/widget/Parse.js