From 274a6734ef1fff543cc50388a0958d1988baeb57 Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Wed, 18 Dec 2013 18:51:56 -0800 Subject: fix(forEach): allow looping over result of querySelectorAll in IE8 In IE8 the result object of calling `node.querySelectorAll` does not have a `hasOwnPropery` function. However, it should be usable with `forEach`. Related to #5400. --- src/Angular.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Angular.js b/src/Angular.js index 88ea452b..386682a3 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -213,7 +213,9 @@ function forEach(obj, iterator, context) { if (obj) { if (isFunction(obj)){ for (key in obj) { - if (key != 'prototype' && key != 'length' && key != 'name' && obj.hasOwnProperty(key)) { + // Need to check if hasOwnProperty exists, + // as on IE8 the result of querySelectorAll is an object without a hasOwnProperty function + if (key != 'prototype' && key != 'length' && key != 'name' && (!obj.hasOwnProperty || obj.hasOwnProperty(key))) { iterator.call(context, obj[key], key); } } -- cgit v1.2.3