Skip to main content

Bug Tracker

Side navigation

#14587 closed bug (notabug)

Opened November 28, 2013 11:00PM UTC

Closed December 02, 2013 03:48PM UTC

Last modified December 02, 2013 03:49PM UTC

DOM attributes aren't refetched during el.removeData().data()

Reported by: rbut Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.10.2
Keywords: Cc:
Blocked by: Blocking:
Description

When calling .removeData() and subsequently .data() one would expect from the documentation that the result of .data() would contain the current data-* attributes from the DOM.

Instead the result of .data() is an empty dictionary!

I have a JSfiddle showing the issue:

http://jsfiddle.net/m6TV5/

The workaround for now is to call the following on each element after .removeData() and before .data():

jQuery._data(this, "parsedAttrs", false);

It seems the private parsedAttrs data isn't being cleared in removeData().

Thank you.

Attachments (0)
Change History (2)

Changed December 02, 2013 03:48PM UTC by timmywil comment:1

resolution: → notabug
status: newclosed

This seems like expected behavior. The docs state:

The data- attributes are pulled in the first time the data property is accessed and then are no longer accessed or mutated 

Once they have been accessed, they will not accessed again. Besides, when dealing with data-* attributes, I'm inclined to recommend .attr() at this point.

Changed December 02, 2013 03:49PM UTC by timmywil comment:2

#14588 is a duplicate of this ticket.