Skip to main content

Bug Tracker

Side navigation

#14057 closed bug (duplicate)

Opened June 21, 2013 05:03PM UTC

Closed June 21, 2013 05:06PM UTC

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

Reported by: amirgrozki@gmail.com 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.

Attachments (0)
Change History (1)

Changed June 21, 2013 05:06PM UTC by rwaldron comment:1

resolution: → duplicate
status: newclosed

Duplicate of #14047.