diff --git a/src/ecmascript/spidermonkey/element.c b/src/ecmascript/spidermonkey/element.c index f2ce5a79..76f6ffb8 100644 --- a/src/ecmascript/spidermonkey/element.c +++ b/src/ecmascript/spidermonkey/element.c @@ -1634,10 +1634,12 @@ element_set_property_innerHtml(JSContext *ctx, unsigned int argc, JS::Value *vp) text += JS_EncodeString(ctx, args[0].toString()); text += ""; - xmlpp::DomParser example1; - example1.parse_memory(text); - auto doc1 = example1.get_document(); - auto root1 = doc1->get_root_node(); + xmlDoc* doc = htmlReadDoc((xmlChar*)text.c_str(), NULL, NULL, HTML_PARSE_RECOVER | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING); + // Encapsulate raw libxml document in a libxml++ wrapper + xmlpp::Document *doc1 = new xmlpp::Document(doc); + + auto root = doc1->get_root_node(); + auto root1 = root->find("//root")[0]; auto children2 = root1->get_children(); auto it2 = children2.begin(); auto end2 = children2.end(); diff --git a/test/ecmascript/childNodes.html b/test/ecmascript/childNodes.html index 9c2c77dc..8e0545cd 100644 --- a/test/ecmascript/childNodes.html +++ b/test/ecmascript/childNodes.html @@ -18,7 +18,7 @@ function myFunction() { var i; for (i = 0; i < c.length; i++) { - txt = txt + c[i].nodeName + "
"; + txt = txt + c[i].nodeName + "
"; } document.getElementById("demo").innerHTML = txt; diff --git a/test/ecmascript/children.html b/test/ecmascript/children.html index 52483fa5..a0cfae34 100644 --- a/test/ecmascript/children.html +++ b/test/ecmascript/children.html @@ -14,7 +14,7 @@ function myFunction() { var txt = ""; var i; for (i = 0; i < c.length; i++) { - txt = txt + c[i].tagName + "
"; + txt = txt + c[i].tagName + "
"; } document.getElementById("demo").innerHTML = txt;