Skip to content

iterate non-enumerables in old IE also#2696

Merged
SergioCrisostomo merged 4 commits intomootools:masterfrom
SergioCrisostomo:fix-2613
Feb 9, 2015
Merged

iterate non-enumerables in old IE also#2696
SergioCrisostomo merged 4 commits intomootools:masterfrom
SergioCrisostomo:fix-2613

Conversation

@SergioCrisostomo
Copy link
Copy Markdown
Member

fixes #2613

@megawac
Copy link
Copy Markdown

megawac commented Feb 1, 2015

👍 but why can't you guys implement all these methods by way of Object.keys which will also be faster in browsers that support keys natively

@SergioCrisostomo
Copy link
Copy Markdown
Member Author

@megawac this was the best I came up with. Input is really welcome, to make it even better :)

In this case since its a IE8- fix i think Object.keys is not a option since IE8 doesn't support it.
(do correct me if I understood you wrong)

@megawac
Copy link
Copy Markdown

megawac commented Feb 1, 2015

I mean Mootools polyfills Object.keys that also has this fix no?

Looks like this fix isn't being applied to keys: https://github.com/mootools/mootools-core/blob/master/Source/Types/Object.js#L63-69

@SergioCrisostomo
Copy link
Copy Markdown
Member Author

@megawac oh, I see. Actually Object.keys is also depending on a for var in. Maybe it should use a patched Object.each instead...

@megawac
Copy link
Copy Markdown

megawac commented Feb 1, 2015

@SergioCrisostomo I would say it should be the other way around (thats how most other frameworks otu there are doing it). Having keys be the root fix for the non enumerable bug in ie also lets other browsers benefit from a faster implementation of all the object methods as native keys is faster than for .. in.

I would argue all the object methods (each, map, filter, etc) that iterate own properties should be using keys, and the enumerable fix where keys doesn';t

@arian
Copy link
Copy Markdown
Member

arian commented Feb 2, 2015

I think that'd be better indeed.

We have to move Object.keys to Core.js from Types/Object.js. After that we could rewrite all for in occurrences to use Object.keys.

@SergioCrisostomo SergioCrisostomo force-pushed the fix-2613 branch 2 times, most recently from ca342a3 to 0ee7a00 Compare February 3, 2015 23:26
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You don't need this this here..

@SergioCrisostomo
Copy link
Copy Markdown
Member Author

@arian updated again.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think eachKey isn't a very nice name. maybe objectEach, or just each?

Also I'm thinking if this shouldn't be:

var objectKeys = Object.keys || function(object){
   // ...
   return keys;
};

And use that in the overloadSetter, with a for-loop there.

And below, just have:

Object.extend({
  keys: objectKeys,
  forEach: // ...
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seriously, use else if, not the x && y thing!

@SergioCrisostomo
Copy link
Copy Markdown
Member Author

added commit and just rebased.

SergioCrisostomo added a commit that referenced this pull request Feb 9, 2015
iterate non-enumerables in old IE also
@SergioCrisostomo SergioCrisostomo merged commit b6fdbb9 into mootools:master Feb 9, 2015
@SergioCrisostomo SergioCrisostomo deleted the fix-2613 branch February 9, 2015 02:35
@mootools mootools deleted a comment Feb 3, 2020
@mootools mootools deleted a comment Mar 14, 2020
@mootools mootools deleted a comment Mar 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ie8: non-iterable properties valueOf, constructor. Patch Object.forEach

3 participants