Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#10144 closed bug (duplicate)

Erroneous return in .data()

Reported by: arcanis Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:

Description

Hello,

There is a bug in the jQuery.data() function. Minimal showcase here : http://jsfiddle.net/NB2Ln/1/

It happens if the data key is in camelcase, and if the content can be implicitely casted to false. If it happens, any call to the getter of the data will return 'undefined' instead of the real value.

The problem is at line 1516 of the 1.6.2 development source code :

thisCache[ jQuery.camelCase( name ) ] || thisCache[ name ]

In the jsfiddle, this line will be evaluated as zero or undefined, and the return value of such operation is undefined.

You should do something like

thisCache[ jQuery.camelCase( name ) ] !== undefined ? thisCache[ jQuery.camelCase( name ) ] || thisCache[ name ] :

Change History (4)

comment:1 Changed 8 years ago by arcanis

Note : developers can bypass this bug by using names which are not modified when calling jQuery.camelCase (so using CamelCase name is fine, there will be no conversion).

comment:2 Changed 8 years ago by arcanis

In the ticket, I've forgotten a word :

It happens if the data key is NOT in camelcase

(sorry)

comment:3 Changed 8 years ago by dmethvin

Resolution: duplicate
Status: newclosed

Should be fixed in 1.6.3.

comment:4 Changed 8 years ago by dmethvin

Duplicate of #10016.

Note: See TracTickets for help on using tickets.