Elliott Sprehn b9aaf7d8e2 Clean up child checks in ContainerNode.
We can simplify the checks given that there's fewer node types now. This does
make the error messages from Range a little worse, but it's weird that Range
is doing its own error checking anyway.

I also took this as an opportunity to add a bunch of DOM tests.

R=ojan@chromium.org

Review URL: https://codereview.chromium.org/732203004
2014-11-18 16:49:48 -08:00

20 lines
477 B
Plaintext

<script>
function childNodeCount(parent) {
var count = 0;
for (var node = parent.firstChild; node; node = node.nextSibling)
++count;
return count;
}
function childElementCount(parent) {
var count = 0;
for (var element = parent.firstElementChild; element; element = element.nextElementSibling)
++count;
return count;
}
module.exports = {
childNodeCount: childNodeCount,
childElementCount: childElementCount,
};
</script>