Skip to content

Commit

Permalink
Adds a workaround for forEach to work on IE8
Browse files Browse the repository at this point in the history
  • Loading branch information
pjparra committed Dec 4, 2013
1 parent 9a81b86 commit 8c2ed24
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Angular.js
Expand Up @@ -213,7 +213,8 @@ function forEach(obj, iterator, context) {
if (obj) {
if (isFunction(obj)){
for (key in obj) {
if (key != 'prototype' && key != 'length' && key != 'name' && obj.hasOwnProperty(key)) {
// This uglyness around hasOwnProperty is for IE8 to work properly (hasOwnProperty doesn't exist)
if (key != 'prototype' && key != 'length' && key != 'name' && (obj.hasOwnProperty && obj.hasOwnProperty(key) || Object.prototype.hasOwnProperty.call(obj, key))) {
iterator.call(context, obj[key], key);
}
}
Expand Down

3 comments on commit 8c2ed24

@pjparra
Copy link
Owner Author

@pjparra pjparra commented on 8c2ed24 Dec 5, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original bug seems to occur only on IE11 in IE8 mode.

@aronayne
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi pjparra,

I'm considering applying your fix. Have you experience any issue with your update ? I'm using AngularJS v1.2.5

Thanks for sharing this.

Adrian

@pjparra
Copy link
Owner Author

@pjparra pjparra commented on 8c2ed24 Oct 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Adrian,

I've been using it for some time, and didn't experience any issue with it.
However, I "recently" switched to 1.2.23, and it seems that a similar fix is now in the official repository.

I think it's safe to use, but I would try to upgrade to the latest version if possible.

Please sign in to comment.