Skip to main content

Bug Tracker

Side navigation

#6918 closed bug (worksforme)

Opened August 19, 2010 04:00PM UTC

Closed October 09, 2010 07:24PM UTC

Attaching data() to two different elements with identical markup

Reported by: jonraasch Owned by:
Priority: undecided Milestone: 1.4.3
Component: data Version: 1.4.2
Keywords: data identical markup Cc:
Blocked by: Blocking:
Description

When attaching data() to two different elements with identical markup, I experienced a bug where the second element's data() object was being retrieved from both the first and second element. I think it is overwriting it due to the identical markup / classnames.

Here is an example of the markup associated with the error:

<a title="Goldstone 12mm faceted briolette" class="gkc-bead gkc-stone-gold12bsf" href="#"><span class="centerOuter"><span class="centerMiddle"><img class="centerInner" alt="Goldstone 12mm faceted briolette" src="/images/gke-beads/gold12bsf_1.png"></span></span>Goldstone</a>

Note that both elements with this markup also had identical styling.

I have checked and can confirm that I am applying a unique data() object to each of the two elements, and retrieving them separately, however both return the second element's data.

Attachments (0)
Change History (1)

Changed October 09, 2010 07:24PM UTC by addyosmani comment:1

keywords: identical markupdata identical markup
priority: → undecided
resolution: → worksforme
status: newclosed

I've reproduced your original code in a complete example here where two instances of the markup provided are used (http://jsfiddle.net/addyosmani/e4xSK/2/).

Selecting them by a common class and using eq(N) to narrow them down then .data() to set the data, I was able to retrieve both sets of data without any duplication/identical data from the first or second element leaking into one another.

As such it would appear that this is working fine. If you have additional information (or test cases) that you would like to send in regarding this bug, please feel free to create a new ticket and we'll reinvestigate.

Thanks!