Bug Tracker

Opened 6 years ago

Closed 6 years ago

#14057 closed bug (duplicate)

Using data() with key containing dashes does not create copy of data with original key

Reported by: amirgrozki@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 2.0.2
Keywords: Cc:
Blocked by: Blocking:

Description

When calling data() using a key containing dashes (an example for this is jQuery UI's sortable trying to add "sortable-item"), on the first attempt, a data entry will be created by the name of "sortableItem", as expected.

However, on the same attempt, the original key will not be saved, and thus dragging will fail on first drag attempt.

Referring to this piece of code (line 3261 and lines 3628-3633 of a built 2.0.2 jquery.js):

var data = data_user.get( this, camelKey ); // #3621

// *... In the case of properties that might _actually_ #3628
// have dashes, we need to also store a copy of that
// unchanged property.
if ( key.indexOf("-") !== -1 && data !== undefined ) {
  data_user.set( this, key, value );
}

In such case, data will be undefined since the camel-cased key doesn't yet exist, therefore the original key will not be stored.

This breaks UI sortable's behavior, but seems to be a jQuery bug according to the comment in the code above.

Change History (1)

comment:1 Changed 6 years ago by Rick Waldron

Resolution: duplicate
Status: newclosed

Duplicate of #14047.

Note: See TracTickets for help on using tickets.