diff --git a/javascript/jsapi/htmlelement.bnd b/javascript/jsapi/htmlelement.bnd index 0730ad44b..71bb31bc1 100644 --- a/javascript/jsapi/htmlelement.bnd +++ b/javascript/jsapi/htmlelement.bnd @@ -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; + } + } +%} diff --git a/test/js/dom-element-childElementCount.html b/test/js/dom-element-childElementCount.html new file mode 100644 index 000000000..ec4b7f89a --- /dev/null +++ b/test/js/dom-element-childElementCount.html @@ -0,0 +1,11 @@ + + + +DOM childElementCount reference + + +

DOM childElementCount reference

+

head.childElementCount:

+

body.childElementCount:

+ + diff --git a/test/js/index.html b/test/js/index.html index 5341a7482..c59b54157 100644 --- a/test/js/index.html +++ b/test/js/index.html @@ -27,6 +27,7 @@
  • firstElementChild
  • lastElementChild
  • previousElementSibling nextElementSibling
  • +
  • childElementCount
  • getElementById
  • getElementsByTagName