Skip to content
Permalink
Browse files

Make sure that undefined is returned for not found data- attributes, …

…not null.
  • Loading branch information...
jeresig committed Sep 21, 2010
1 parent d5d4e4d commit ae9df1412c41b1ae676d3808c323b0f01e0b0600
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/data.js
@@ -152,12 +152,15 @@ jQuery.fn.extend({
if ( data === undefined && this[0].nodeType === 1 ) {
data = this[0].getAttribute( "data-" + key );

if ( data != null ) {
if ( typeof data === "string" ) {
data = data === "true" ? true :
data === "false" ? false :
data === "null" ? null :
rnum.test( data ) ? parseFloat( data ) :
data;

} else {
data = undefined;
}
}
}

0 comments on commit ae9df14

Please sign in to comment.
You can’t perform that action at this time.