git.asbjorn.biz
/
jquery.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
d5d4e4d
)
Make sure that undefined is returned for not found data- attributes, not null.
author
John Resig
<jeresig@gmail.com>
Tue, 21 Sep 2010 04:44:47 +0000
(
00:44
-0400)
committer
John Resig
<jeresig@gmail.com>
Tue, 21 Sep 2010 04:44:47 +0000
(
00:44
-0400)
src/data.js
patch
|
blob
|
history
diff --git
a/src/data.js
b/src/data.js
index
cc02715
..
dda1683
100644
(file)
--- a/
src/data.js
+++ b/
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 === 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;
data = data === "true" ? true :
data === "false" ? false :
data === "null" ? null :
rnum.test( data ) ? parseFloat( data ) :
data;
+
+ } else {
+ data = undefined;
}
}
}
}
}
}