Skip to main content

Bug Tracker

Side navigation

#12214 closed bug (invalid)

Opened August 07, 2012 05:15PM UTC

Closed August 07, 2012 05:17PM UTC

$.data inconsistent with $().data

Reported by: dh10110@gmail.com Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.8rc1
Keywords: Cc:
Blocked by: Blocking:
Description

While testing jQuery 1.8 RC1, I encountered inconsistent behavior between $.data and $().data when reading inline data attributes.

When $.data is used first, the return value is always undefined. Once $().data is used with the same element, then $.data will work.

jsFiddle: http://jsfiddle.net/t76Kc/6/

The specific use case I encountered this was inside a $().each function, trying to add specific data to each individual element. Since .each provides the element, I was trying to avoid an extra $() wrapper around the element if I did not need it.

I think this bug also existed in previous versions of jQuery.

Attachments (0)
Change History (1)

Changed August 07, 2012 05:17PM UTC by dmethvin comment:1

resolution: → invalid
status: newclosed

As documented, $.data doesn't read HTML data- attributes, by design.