Skip to main content

Bug Tracker

Side navigation

#7323 closed enhancement (fixed)

Opened October 27, 2010 04:11AM UTC

Closed September 20, 2011 01:17AM UTC

Last modified March 08, 2012 04:29PM UTC

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

Reported by: rmurphey@gmail.com 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.

Attachments (0)
Change History (20)

Changed October 27, 2010 04:44PM UTC by SlexAxton comment:1

component: unfileddata
keywords: → removeData
status: newopen

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

Changed October 27, 2010 04:45PM UTC by anonymous comment:2

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

Changed October 27, 2010 04:45PM UTC by rmurphey comment:3

Replying to [comment:2 anonymous]:

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

Sorry, that was me, I wasn't logged in.

Changed October 27, 2010 08:06PM UTC by rmurphey comment:4

Pull request 77 submitted, if you want it.

Changed November 21, 2010 10:49PM UTC by snover comment:5

owner: → rmurphey
status: openassigned

Changed April 16, 2011 09:03PM UTC by john comment:6

milestone: → 1.next
priority: undecidedlow

We should consider this for 1.7.

Changed May 22, 2011 07:27PM UTC by john comment:7

keywords: removeDataremoveData,1.7-discuss

Nominating ticket for 1.7 discussion.

Changed May 22, 2011 09:41PM UTC by rwaldron comment:8

+1, Should be consistent with existing API

Changed May 23, 2011 12:15AM UTC by jaubourg comment:9

+1, makes sense

Changed May 23, 2011 12:43AM UTC by rmurphey comment:10

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.

Changed May 23, 2011 03:53AM UTC by timmywil comment:11

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

Changed May 23, 2011 03:55PM UTC by ajpiano comment:12

+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

Changed June 03, 2011 01:41PM UTC by john comment:13

+1, Let's do this.

Changed June 03, 2011 03:29PM UTC by scottgonzalez comment:14

+1, space delimited string, like everything else

Changed June 03, 2011 03:47PM UTC by rwaldron comment:15

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

Changed June 06, 2011 03:57PM UTC by jzaefferer comment:16

+0

Changed July 12, 2011 03:00PM UTC by dmethvin comment:17

milestone: 1.next1.7
priority: lowblocker

Changed July 25, 2011 04:08PM UTC by timmywil comment:18

owner: rmurpheytimmywil

Changed September 19, 2011 04:59PM UTC by gnarf comment:19

owner: timmywilgnarf

Changed September 20, 2011 01:17AM UTC by Corey Frang comment:20

resolution: → fixed
status: assignedclosed

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

More Details:

Changeset: 9b3768b968bc99d3422355e69e2c7c35bedf681e