Bug Tracker

Opened 7 years ago

Closed 6 years ago

Last modified 5 years ago

#7323 closed enhancement (fixed)

Allow removing multiple data keys at once with $.fn.removeData

Reported by: rmurphey@… 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 7 years ago by SlexAxton

Component: unfileddata
Keywords: removeData added
Status: newopen

Seems fair. Any desire to write a patch? :D

comment:2 Changed 7 years ago by anonymous

Yes :) Didn't want to submit one unless it was something people liked.

comment:3 in reply to:  2 Changed 7 years ago by rmurphey

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:4 Changed 7 years ago by rmurphey

Pull request 77 submitted, if you want it.

comment:5 Changed 6 years ago by snover

Owner: set to rmurphey
Status: openassigned

comment:6 Changed 6 years ago by john

Milestone: 1.next
Priority: undecidedlow

We should consider this for 1.7.

comment:7 Changed 6 years ago by john

Keywords: 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:8 Changed 6 years ago by Rick Waldron

+1, Should be consistent with existing API

comment:9 Changed 6 years ago by jaubourg

+1, makes sense

comment:10 Changed 6 years ago by rmurphey

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 6 years ago by timmywil

+1, In favor, but I don't think space-separated by itself is enough.

comment:12 Changed 6 years ago by ajpiano

+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:13 Changed 6 years ago by john

+1, Let's do this.

comment:14 Changed 6 years ago by scottgonzalez

+1, space delimited string, like everything else

comment:15 Changed 6 years ago by Rick Waldron

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:16 Changed 6 years ago by jzaefferer

+0

comment:17 Changed 6 years ago by dmethvin

Milestone: 1.next1.7
Priority: lowblocker

comment:18 Changed 6 years ago by timmywil

Owner: changed from rmurphey to timmywil

comment:19 Changed 6 years ago by gnarf

Owner: changed from timmywil to gnarf

comment:20 Changed 6 years ago by Corey Frang

Resolution: fixed
Status: assignedclosed

Landing pull request 512. 1.7 - removeData now takes space separated lists and arrays of keys - Fixes #7323.

More Details:

Note: See TracTickets for help on using tickets.