Opened 16 years ago

Closed 16 years ago

Last modified 15 years ago

#414 closed defect (fixed)

Konqueror problem in dojo.dom.innerXML

Reported by: [email protected] Owned by: anonymous
Priority: high Milestone:
Component: Core Version: 0.2
Keywords: Cc:
Blocked By: Blocking:


In dojo.dom.innerXML of src/dom.js an XMLSerializer is used to convert the node to string. In Konqueror (3.4.1.) this object indeed exists (so typeof XMLSerializer != "undefined" returns true), but its serializeToString method always returns "undefined".

So, I was thinking that it wouldnt hurt having a generic innerXML method that traverses the nodes and builds the resulting string. Here's how we implemented this in (adapted to dojo):

dojo.dom.innerXML = function(node){
		return node.innerXML;
	}else if(typeof XMLSerializer != "undefined"){
		var ret = (new XMLSerializer()).serializeToString(node);
                if (ret == "undefined")
                    return dojo.dom._innerXMLGeneric(node);
                    return ret;

dojo.dom._innerXMLGeneric = function(node){
	var _result = "";
	if (node == null) { return _result; }
	for (var i = 0; i < node.childNodes.length; i++) {
		var thisNode = node.childNodes[i];
		switch (thisNode.nodeType) {
			case 1: // ELEMENT_NODE
				_result += dojo.dom._getElementAsStringGeneric(thisNode);
			case 3: // TEXT_NODE
			case 2: // ATTRIBUTE_NODE
			case 4: // CDATA_SECTION_NODE
				_result += thisNode.nodeValue;
	return _result;	

dojo.dom._getElementAsStringGeneric = function(thisNode){
	var _result = "";
	if (thisNode == null) { return _result; }
	// start tag
	_result += '<' + thisNode.nodeName;
	// add attributes
	if (thisNode.attributes && thisNode.attributes.length>0) {
		for (var i = 0; i < thisNode.attributes.length; i++) {
			_result += " " + thisNode.attributes[i].name 
				+ "="" + thisNode.attributes[i].value + """;	
	// close start tag
	_result += '>';
	// content of tag
	_result += dojo.dom._innerXMLGeneric(thisNode);
	// end tag
	_result += '</' + thisNode.nodeName + '>';
	return _result;

Change History (9)

comment:1 Changed 16 years ago by anonymous

Milestone: 0.2.2release

comment:2 Changed 16 years ago by bill

Milestone: 0.2.2release0.3release

Confusingly, Milestone refers to when we will fix the bug. Since 0.2.2 is already released, I'm setting the milestone to 0.3.

Before we put that code into dojo I think we need the CLA, although if it is part of tacos, I'm not sure how the licensing stuff works there.

comment:3 Changed 16 years ago by [email protected]

There won't be any licensing issues from tacos. We've been a little remiss in adding headers correctly everywhere, but the overall license is apache 2.0. I have a CLA on file if it will help. If there's something else tacos needs to do to be more license friendly let me know and I'll do it.

comment:4 Changed 16 years ago by Tom Trenka

Should we hold off on this until we've finished trying to refactor/reduce bloat? Having a manual node builder isn't a bad idea but if it's just there to support Konq (which I don't think Dojo is fully supporting IIRC), I'd be in favor of not adding it to dojo.dom...

comment:5 Changed 16 years ago by anonymous

Milestone: 0.3release0.5

comment:6 Changed 16 years ago by mumme

Pasting the kde bug ticket for this:

Hopefully the attached patch will get into kde 3.5.4, that would be the best option I think.

/ Fredrik

comment:7 Changed 16 years ago by [email protected]

Hope they apply that patch! You can more or less close this then, unless you're actually interested in a manual node builder for 0.5 (though i don't see a reason for it now ) ...

comment:8 Changed 16 years ago by mumme

Milestone: 0.50.4
Resolution: fixed
Status: newclosed

The KDE folks merged in my patch for this today, so kde3.5.4 will serialize nodes as well as documents.

Closing this bug today

/ Fredrik

comment:9 Changed 15 years ago by (none)

Milestone: 0.4

Milestone 0.4 deleted

Note: See TracTickets for help on using tickets.