fix(foreach): change foreach to support NamedNodeMap

Change foreach to support the NamedNodeMap interface (implemented by e.g. Element.attributes).  Most but not all browsers make Element.attributes pass the isArrayLike() test, which is why this bug was not caught earlier.