Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#14799 closed bug (notabug)

Data with hyphenated keys, set via plain object, becomes inaccessible via hyphenated key

Reported by: Rick Waldron Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.11.0-rc1
Keywords: Cc:
Blocked by: Blocking:

Description

test(".data should not miss data-* w/ hyphenated property names #14047", function() {

  expect(2);

  var div = jQuery("<div>");

  div.data({ "foo-bar": 1 });
  div.data( "foo-bar", 2 );

  equal( div.data( "foo-bar" ), 2, "data with property 'foo-bar' was correctly found");
  equal( div.data( "fooBar" ), 2, "data with property 'fooBar' was correctly found");
});

This test fails the first assertion.

Change History (2)

comment:1 Changed 10 years ago by Rick Waldron

Resolution: notabug
Status: newclosed

Intentional behaviour.

comment:2 Changed 10 years ago by Rick Waldron

This can be fixed if jQuery updates both hyphenated and camel case keys

https://github.com/jquery/jquery/pull/1515

Note: See TracTickets for help on using tickets.