Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#10784 closed bug (invalid)

$.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:


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.

Change History (3)

comment:1 Changed 11 years ago by dmethvin

Owner: set to 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:


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.

comment:2 Changed 11 years ago by trac-o-bot

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!

comment:3 Changed 11 years ago by istvan.m.antal

.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.

Note: See TracTickets for help on using tickets.