Side navigation
#14659 closed feature (fixed)
Opened December 31, 2013 09:25PM UTC
Closed March 09, 2014 10:32PM UTC
Avoid use of Object.keys() in cleanData()
Reported by: | hiroshi | Owned by: | m_gol |
---|---|---|---|
Priority: | low | Milestone: | 2.1.1 |
Component: | manipulation | Version: | 2.1.0-beta2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Object.keys() is still not supported by some old browsers.
http://kangax.github.io/es5-compat-table/
Also ''for in'' is used to iterate event types in other places (i.e. jQuery.event.remove).
for ( type in events ) { jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); }
I think we should avoid use of Object.keys() in terms of followings.
- Browser compatibility
- Code consistency
Attachments (0)
Change History (9)
Changed December 31, 2013 10:21PM UTC by comment:1
Changed December 31, 2013 10:25PM UTC by comment:2
_comment0: | I think the consistency issue is a better argument, since we don't use `Object.keys` anywhere else. However, the good thing about it would be that potentially we could survive augmentation of `Object` if we used this everywhere, since it only enumerates own properties? The for/in makes the code a bit shorter and simpler, I haven't looked to see the impact on gzip though. → 1388528759194254 |
---|
I think the consistency issue is a better argument, since we don't use Object.keys
anywhere else. However, the good thing about it would be that potentially we could survive augmentation of Object.prototype
if we used this everywhere, since it only enumerates own properties? The for/in makes the code a bit shorter and simpler, I haven't looked to see the impact on gzip though.
Changed December 31, 2013 10:33PM UTC by comment:3
_comment0: | While this is not high priority, I think I would prefer to use the for-in loop to save a few bytes. Supporting `Object.prototype` augmentation is not something we've pursued historically and I don't think we would want to make the necessary changes to the 1.x branch to keep it consistent with 2.x if we wanted to start. → 1388529301933810 |
---|---|
component: | unfiled → event |
priority: | undecided → low |
status: | new → open |
type: | bug → feature |
While this is not high priority, I think I would prefer to use the for-in loop to save a few bytes. That is, if the argument is for consistency, the bytes would add up if we used Object.keys
ubiquitously. Supporting Object.prototype
augmentation is not something we've pursued historically and I don't think we would want to make the necessary changes to the 1.x branch to keep it consistent with 2.x if we wanted to start.
Changed January 01, 2014 05:37AM UTC by comment:4
I added some analysis. Performance and file size seem better.
Changed March 04, 2014 02:31PM UTC by comment:5
milestone: | None → 1.11.1/2.1.1 |
---|
Changed March 05, 2014 01:26AM UTC by comment:6
milestone: | 1.11.1/2.1.1 → 2.1.1 |
---|
Changed March 09, 2014 10:28PM UTC by comment:7
owner: | → m_gol |
---|---|
status: | open → assigned |
Changed March 09, 2014 10:31PM UTC by comment:8
component: | event → manipulation |
---|
This is not a relevant "issue" for jQuery 2.x, which only supports browsers that _will_ have Object.keys