Skip to main content

Bug Tracker

Side navigation

#10784 closed bug (invalid)

Opened November 14, 2011 02:48PM UTC

Closed November 29, 2011 08:16AM UTC

Last modified November 29, 2011 08:53AM UTC

$.removeData is not working in 1.7

Reported by: istvan.m.antal Owned by: istvan.m.antal
Priority: undecided Milestone: None
Component: unfiled Version: 1.7
Keywords: Cc:
Blocked by: Blocking:
Description

As of 1.7, removeData is not working, here is a simple test case: http://jsfiddle.net/gGvHT/

After the second click, the alert should not show "test", but it still does, in other words, the data is not getting removed.

Attachments (0)
Change History (3)

Changed November 14, 2011 02:57PM UTC by dmethvin comment:1

owner: → istvan.m.antal
status: newpending

Did you expect .removeData to remove the data attribute from the HTML? That's not how it works. The data APIs only remove the data from the internal object. When you ask for the data the next time, it finds a match in the data- attribute on the element.

The docs clearly mention this:

Removing data from jQuery's internal .data() cache does not effect any HTML5 data- attributes in a document; use .removeAttr() to remove those. -- http://api.jquery.com/removeData/

More information is here:

http://www.learningjquery.com/2011/09/using-jquerys-data-apis

In general, if you are not interested in the performance benefit of having the data cached by jQuery, skip the .data() API altogether and work directly with .attr() on the attribute.

Changed November 29, 2011 08:16AM UTC by trac-o-bot comment:2

resolution: → invalid
status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Changed November 29, 2011 08:53AM UTC by istvan.m.antal comment:3

.removeData could simply set the cache to null like it probably does in earlier versions, that way I would not get back the data that is supposed to be removed.