Side navigation
#10144 closed bug (duplicate)
Opened August 26, 2011 10:33AM UTC
Closed August 27, 2011 08:11PM UTC
Last modified March 09, 2012 07:01PM UTC
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 ] :
Attachments (0)
Change History (4)
Changed August 26, 2011 10:40AM UTC by comment:1
Changed August 26, 2011 10:43AM UTC by comment:2
In the ticket, I've forgotten a word :
It happens if the data key is NOT in camelcase
(sorry)
Changed August 27, 2011 08:11PM UTC by comment:3
resolution: | → duplicate |
---|---|
status: | new → closed |
Should be fixed in 1.6.3.
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).