mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-26 05:57:00 +03:00
implement childElementCount
This commit is contained in:
parent
99d3633e03
commit
fa9046fc97
@ -187,3 +187,30 @@ getter nextElementSibling %{
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
getter childElementCount %{
|
||||
dom_node *element;
|
||||
dom_exception exc;
|
||||
dom_node_type node_type;
|
||||
dom_node *next_node;
|
||||
|
||||
exc = dom_node_get_first_child(private->node, &element);
|
||||
if (exc != DOM_NO_ERR) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
while (element != NULL) {
|
||||
exc = dom_node_get_node_type(element, &node_type);
|
||||
if ((exc == DOM_NO_ERR) && (node_type == DOM_ELEMENT_NODE)) {
|
||||
jsret += 1;
|
||||
}
|
||||
|
||||
exc = dom_node_get_next_sibling(element, &next_node);
|
||||
dom_node_unref(element);
|
||||
if (exc == DOM_NO_ERR) {
|
||||
element = next_node;
|
||||
} else {
|
||||
element = NULL;
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
11
test/js/dom-element-childElementCount.html
Normal file
11
test/js/dom-element-childElementCount.html
Normal file
@ -0,0 +1,11 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="tst.css">
|
||||
<title>DOM childElementCount reference</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>DOM childElementCount reference</h1>
|
||||
<p><b>head.childElementCount:</b> <script>document.write(document.head.childElementCount);</script></p>
|
||||
<p><b>body.childElementCount:</b> <script>document.write(document.body.childElementCount);</script></p>
|
||||
</body>
|
||||
</html>
|
@ -27,6 +27,7 @@
|
||||
<li><a href="dom-element-firstElementChild.html">firstElementChild</a></li>
|
||||
<li><a href="dom-element-lastElementChild.html">lastElementChild</a></li>
|
||||
<li><a href="dom-element-next_prev_ElementSibling.html">previousElementSibling nextElementSibling</a></li>
|
||||
<li><a href="dom-element-childElementCount.html">childElementCount</a></li>
|
||||
<li><a href="doc-dom2.html">getElementById</a></li>
|
||||
<li><a href="dom-getElementsByTagName.html">getElementsByTagName</a></li>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user