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:
parent
b9e8b01e8c
commit
2ec72fa89f
@ -897,7 +897,7 @@ mjs_fragment_appendChild(js_State *J)
|
|||||||
js_error(J, "error");
|
js_error(J, "error");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dom_node *el2 = (dom_node *)(mjs_getprivate_fragment(J, 1));
|
dom_node *el2 = (dom_node *)(mjs_getprivate_any(J, 1));
|
||||||
|
|
||||||
if (!el2) {
|
if (!el2) {
|
||||||
js_error(J, "error");
|
js_error(J, "error");
|
||||||
|
32
test/js/assert/fragment.appendChild.html
Normal file
32
test/js/assert/fragment.appendChild.html
Normal 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>
|
@ -74,6 +74,7 @@ took = [
|
|||||||
#'event.html',
|
#'event.html',
|
||||||
'eventListener.html',
|
'eventListener.html',
|
||||||
'fetch.html',
|
'fetch.html',
|
||||||
|
'fragment.appendChild.html',
|
||||||
'fragment.getElementsByTagName.html',
|
'fragment.getElementsByTagName.html',
|
||||||
'keyboardEvent.html',
|
'keyboardEvent.html',
|
||||||
'navigator.appCodeName.html',
|
'navigator.appCodeName.html',
|
||||||
|
Loading…
Reference in New Issue
Block a user