Version: (using KDE Devel) Installed from: Compiled sources Compiler: g++ 4.02 (Kubuntu breezy) OS: Linux XMLSerializer.serializeToString(node); returns undefined, in moz it does serialize the tree under node. However if we provide the node.ownerDocument it serializes DOMDocument. This is less usefull if we would want to make a cross browser innerXML function in ecmascript I copied webcore's function in xmlserializer.cpp and it seems to work, however you are probably better suited to deside if it could get in kde3.5.3 Im sypplying a testcase for you. Regards Fredrik Johansson
Created attachment 15954 [details] testpage
Created attachment 16573 [details] [Patch], supports serialize a DOMNode as well as DOMDocument Attached a patch that makes this work on a kde3.5.x branch. The ecma/xmlserializer.cpp code is a modified version from webcore. The xml/dom_elementimpl.cpp code is my own. Regards Fredrik Johansson
SVN commit 556110 by ggarand: apply patch from Fredrik Johansson <fredrik@mumme.se> make serializeToString work DOMNodes BUG: 126869 M +4 -5 ecma/xmlserializer.cpp M +3 -0 xml/dom_elementimpl.cpp --- branches/KDE/3.5/kdelibs/khtml/ecma/xmlserializer.cpp #556109:556110 @@ -79,21 +79,20 @@ return Undefined(); } - if (!args[0].toObject(exec).inherits(&DOMDocument::info)) { + if (!args[0].toObject(exec).inherits(&DOMNode::info)) { return Undefined(); } - DOM::Node docNode = static_cast<KJS::DOMDocument *>(args[0].toObject(exec).imp())->toNode(); - DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl *>(docNode.handle()); + DOM::NodeImpl *node = static_cast<DOM::NodeImpl *>(static_cast<KJS::DOMNode *>(args[0].toObject(exec).imp())->toNode().handle()); - if (!doc) { + if (!node) { return Undefined(); } QString body; try { - body = doc->toString().string(); + body = node->toString().string(); } catch(DOM::DOMException& e) { Object err = Error::create(exec, GeneralError, "Exception serializing document"); exec->setException(err); --- branches/KDE/3.5/kdelibs/khtml/xml/dom_elementimpl.cpp #556109:556110 @@ -836,6 +836,9 @@ result += "</"; result += tagName(); result += ">"; + } else if (result.length() == 1) { + // ensure we dont get results like < /> can happen when serialize document + result = ""; } else { result += " />"; }