Bug Tracker

Ticket #13850 (closed bug: fixed)

Opened 2 years ago

Last modified 2 years ago

.data() and removeData() doesn't work correctly with hyphenated property

Reported by: rospino Owned by: rwaldron
Priority: blocker Milestone: 2.0.1
Component: data Version: 2.0.0
Keywords: Cc:
Blocking: Blocked by:

Description

if data is stored for an element twice with a hyphenated property, cache stores two properties one hyphenated and one camel case. If you call removeData one property is removed. Therefore if you get the data value is returned when this should be undefined

$("#element").data("my-key", { id: 0; value: "Value0" });
$("#element").data("my-key", { id: 1; value: "Value1" });
$("#element").removeData("my-key");
$("#element").data("my-key"); //return { id: 1; value: "Value1" } when sholud be 'undefinded'

Change History

comment:1 Changed 2 years ago by rwaldron

  • Owner set to rwaldron
  • Status changed from new to assigned

comment:2 Changed 2 years ago by rospino

Demo on jsfiddle:

 http://jsfiddle.net/Kgjbv/2/

comment:3 Changed 2 years ago by timmywil

  • Priority changed from undecided to blocker
  • Component changed from unfiled to data
  • Milestone changed from None to 2.0.1

comment:4 Changed 2 years ago by Rick Waldron

  • Status changed from assigned to closed
  • Resolution set to fixed

Fixes #13850. Better removal of hyphenated data property names.

Signed-off-by: Rick Waldron <waldron.rick@…>

Changeset: 2406b5e290c1364c0a58832e0bbf4bcf82abfe10

Note: See TracTickets for help on using tickets.