From: John Resig Date: Tue, 21 Sep 2010 04:44:47 +0000 (-0400) Subject: Make sure that undefined is returned for not found data- attributes, not null. X-Git-Tag: 1.4.3rc1~102 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ae9df1412c41b1ae676d3808c323b0f01e0b0600;p=jquery.git Make sure that undefined is returned for not found data- attributes, not null. --- diff --git a/src/data.js b/src/data.js index cc027158c..dda1683a5 100644 --- 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 != null ) { + if ( typeof data === "string" ) { data = data === "true" ? true : data === "false" ? false : data === "null" ? null : rnum.test( data ) ? parseFloat( data ) : data; + + } else { + data = undefined; } } }