#7323 closed enhancement (fixed)
Allow removing multiple data keys at once with $.fn.removeData
Reported by: | Owned by: | gnarf | |
---|---|---|---|
Priority: | blocker | Milestone: | 1.7 |
Component: | data | Version: | 1.4.3 |
Keywords: | removeData, 1.7-discuss | Cc: | |
Blocked by: | Blocking: |
Description
I just saw some code in Wijmo that had a string of chained removeData() calls, and it occurred to me there should probably be a way to remove multiple data keys at once. Not sure whether this is a worthwhile addition (I know there are better ways they could have done this to avoid needing to remove one key at a time), but if so, I'd suggest an API that accepts either a string containing a single key (which is what currently works) or an array of keys.
Change History (20)
comment:1 Changed 13 years ago by
Component: | unfiled → data |
---|---|
Keywords: | removeData added |
Status: | new → open |
comment:2 follow-up: 3 Changed 13 years ago by
Yes :) Didn't want to submit one unless it was something people liked.
comment:3 Changed 13 years ago by
Replying to anonymous:
Yes :) Didn't want to submit one unless it was something people liked.
Sorry, that was me, I wasn't logged in.
comment:6 Changed 12 years ago by
Milestone: | → 1.next |
---|---|
Priority: | undecided → low |
We should consider this for 1.7.
comment:10 Changed 12 years ago by
Per the discussion on the pull request (https://github.com/jquery/jquery/pull/77) there needs to be a decision as to the API. If we go with a single string, which is consistent with existing APIs ...
$('#foo').removeData('a b c');
... then we make it impossible to remove a key with a space in it. If we go with an array, as I did in the pull request ...
$('#foo').removeData([ 'a', 'b', 'c' ]);
... then we can allow the removal of any valid key, either one or many at a time.
I have no horse in this race; I can see the merits of both solutions.
comment:11 Changed 12 years ago by
+1, In favor, but I don't think space-separated by itself is enough.
comment:12 Changed 12 years ago by
+1, I don't know if we want to break space-separated keys for 1.7 - I like the array, even thought it's "inconsistent" with other aspects of the API
comment:15 Changed 12 years ago by
Scott, keep in mind that data properties can be any valid string
https://github.com/jquery/jquery/pull/77#issuecomment-665309
illustrated here:
http://jsfiddle.net/rwaldron/Bt4nK/
But then again, we could always just say that strings with spaces are prohibited
comment:17 Changed 12 years ago by
Milestone: | 1.next → 1.7 |
---|---|
Priority: | low → blocker |
comment:18 Changed 12 years ago by
Owner: | changed from rmurphey to Timmy Willison |
---|
comment:19 Changed 12 years ago by
Owner: | changed from Timmy Willison to gnarf |
---|
comment:20 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Landing pull request 512. 1.7 - removeData now takes space separated lists and arrays of keys - Fixes #7323.
More Details:
Seems fair. Any desire to write a patch? :D