-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IE Non-Enumerable properties #2064
Conversation
b20afdd
to
5bfd4f9
Compare
This seems to work in IE8. Beat me to it. If you're waiting for @jdalton to review.. it might be awhile.. he's been banned. |
I've got it working in IE6 and 8, so I think we're set.
Well, it's been one of those days. |
What's the difference from the previous implementation? |
The only important change is determining the @@ -894,17 +896,21 @@
// Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed.
var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString');
- var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString',
+ var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString',
'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
function collectNonEnumProps(obj, keys) {
var nonEnumIdx = nonEnumerableProps.length;
- var proto = typeof obj.constructor === 'function' ? FuncProto : ObjProto;
+ var constructor = obj.constructor;
+ var proto = (_.isFunction(constructor) && constructor.prototype) || ObjProto;
+
+ // Constructor is a special case.
+ var prop = 'constructor';
+ if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop);
while (nonEnumIdx--) {
- var prop = nonEnumerableProps[nonEnumIdx];
- if (prop === 'constructor' ? _.has(obj, prop) : prop in obj &&
- obj[prop] !== proto[prop] && !_.contains(keys, prop)) {
+ prop = nonEnumerableProps[nonEnumIdx];
+ if (prop in obj && obj[prop] !== proto[prop] && !_.contains(keys, prop)) {
keys.push(prop);
}
} |
The only functional change I see really is using |
Kill the "fasley"s? |
LGTM 👍 |
You're too quick for me The tests should say "falsey" I think right? |
IE Non-Enumerable properties
|
||
//null edge cases | ||
var oCon = {'constructor': Object}; | ||
deepEqual(_.map([null, undefined, 5, {}], _.partial(_.isMatch, _, oCon)), [false, false, false, true], 'doesnt fasley match constructor on undefined/null'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"fasley"
should be "falsey"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already fixed.
I’m not sure what we were doing before with the
FuncProto
…@jdalton: mind giving this a review?