1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-21 00:25:37 +00:00

[js] Improved innerHTML. It accepts html now, not only xhtml.

This commit is contained in:
Witold Filipczyk 2021-06-08 16:13:09 +02:00
parent e674a7c9d1
commit b4c3c6f171
3 changed files with 8 additions and 6 deletions

View File

@ -1634,10 +1634,12 @@ element_set_property_innerHtml(JSContext *ctx, unsigned int argc, JS::Value *vp)
text += JS_EncodeString(ctx, args[0].toString());
text += "</root>";
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();

View File

@ -18,7 +18,7 @@ function myFunction() {
var i;
for (i = 0; i < c.length; i++) {
txt = txt + c[i].nodeName + "<br/>";
txt = txt + c[i].nodeName + "<br>";
}
document.getElementById("demo").innerHTML = txt;

View File

@ -14,7 +14,7 @@ function myFunction() {
var txt = "";
var i;
for (i = 0; i < c.length; i++) {
txt = txt + c[i].tagName + "<br/>";
txt = txt + c[i].tagName + "<br>";
}
document.getElementById("demo").innerHTML = txt;