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
_.extend should work-around JScript's DontEnum bug #60
Comments
I'm not sure which patch in that ticket you're proposing we adopt -- can you link directly to the patch itself? I considered this when doing |
Well, the idea is that internally you should never use (for ... in ...). Because it's broken. Instead you use a function that incorporates the fix. I'd say _.each nominates for that. A work-around is not so complicated. I'm succesfully using the following code to patch the same problem in jQuery (
|
I'm afraid this sort of fix won't work. As far as I'm aware ... there's no complete workaround for this bug in IE, given that you can't traverse the prototype chain upwards in IE either. Even if there were a workaround, it would probably be prohibitively expensive... Fortunately, the problem isn't total disaster, because it only affects objects that are being used as hashes that contains one of the unenumerable keys. You need to be aware of when you're using a hash of this type (rare, unless you're writing a compiler or code generator), and use an array instead. Closing the ticket, but I'd love to continue to hear your thoughts about this... |
Hmm good points. I guess I never realized that Fortunately for my particular use case this is not a problem, but it means my work-around is use case specific and not generic. So I'll need to reorganize my code a bit. Thanks for improving my code! ;) |
See: https://developer.mozilla.org/en/ECMAScript_DontEnum_attribute#JScript_DontEnum_Bug
This should evaluate to true:
_.extend({}, {a: 1, toString: 'x'}).toString === 'x'
But in IE (I tested version 8) it evaluates to false.
I suggest a patch along these lines: https://prototype.lighthouseapp.com/projects/8886/tickets/23-object-keys-object-values-dontenum-ie-fix
The text was updated successfully, but these errors were encountered: