1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[mujs] added fragment.appendChild test case

This commit is contained in:
Witold Filipczyk 2024-09-27 17:17:40 +02:00
parent b9e8b01e8c
commit 2ec72fa89f
3 changed files with 34 additions and 1 deletions

View File

@ -897,7 +897,7 @@ mjs_fragment_appendChild(js_State *J)
js_error(J, "error");
return;
}
dom_node *el2 = (dom_node *)(mjs_getprivate_fragment(J, 1));
dom_node *el2 = (dom_node *)(mjs_getprivate_any(J, 1));
if (!el2) {
js_error(J, "error");

View File

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<body>
<ul id="myList">
<li>Coffee</li>
<li>Tea</li>
</ul>
<p>Click the button to append an item to the end of the list.</p>
<button onclick="myFunction()">Try it</button>
<p><strong>Note:</strong><br>First create an LI node,<br> then create a Text node,<br> then append the Text node to the LI node.<br>Finally append the LI node to the list.</p>
<script>
function myFunction() {
var frag = document.createDocumentFragment();
var node = document.createElement("LI");
var textnode = document.createTextNode("Water");
node.appendChild(textnode);
frag.appendChild(node);
document.getElementById("myList").appendChild(frag);
console.assert(document.getElementsByTagName("UL")[0].outerHTML === '<ul id="myList">\n <li>Coffee</li>\n <li>Tea</li>\n<li>Water</li></ul>', 'Water');
}
console.error('fragment.appendChild.html');
myFunction();
console.exit();
</script>
</body>
</html>

View File

@ -74,6 +74,7 @@ took = [
#'event.html',
'eventListener.html',
'fetch.html',
'fragment.appendChild.html',
'fragment.getElementsByTagName.html',
'keyboardEvent.html',
'navigator.appCodeName.html',