juan valdez juan valdez - 6 months ago 22
Javascript Question

Why does Element.children fail for Safari?

but not for Chrome, Opera and Firefox?

I noticed that Safari appends

Element.children
with what appears to be the number of children in
Element
. Is this expected behavior and if so why the divergence from what the other browsers do?

$A.forEach(this.E.mi_control.children, function (val) {
$A.log(val);
}, this);

Answer

This is b.c. not every browser implements the DOM consistently. In this case, Safari adds an extra property to your children, namely length.

Just filter this property and your results should be consistent.

Comments