diff options
author | Timmy Willison <timmywillisn@gmail.com> | 2013-09-09 12:13:41 -0400 |
---|---|---|
committer | Timmy Willison <timmywillisn@gmail.com> | 2013-09-09 13:54:46 -0500 |
commit | 99191a510ecb5584addc0391edd56d626067b28a (patch) | |
tree | dd74972f85d47ed898e15dd24dedd722fac47440 /src/data.js | |
parent | cd4a9cd7fa7093df92e64d5da9f18742254a8ca7 (diff) | |
download | jquery-99191a510ecb5584addc0391edd56d626067b28a.tar.gz jquery-99191a510ecb5584addc0391edd56d626067b28a.zip |
Apply consistent ordering in all modules. -38 bytes. Order modules like functions > jQuery.extend > jQuery.fn.extend.
Diffstat (limited to 'src/data.js')
-rw-r--r-- | src/data.js | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/src/data.js b/src/data.js index 2857cecb1..e4d15da3c 100644 --- a/src/data.js +++ b/src/data.js @@ -20,6 +20,35 @@ define([ var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/, rmultiDash = /([A-Z])/g; +function dataAttr( elem, key, data ) { + var name; + + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : + // Only convert to a number if it doesn't change the string + +data + "" === data ? +data : + rbrace.test( data ) ? JSON.parse( data ) : + data; + } catch( e ) {} + + // Make sure we set the data so it isn't changed later + data_user.set( elem, key, data ); + } else { + data = undefined; + } + } + return data; +} + jQuery.extend({ hasData: function( elem ) { return data_user.hasData( elem ) || data_priv.hasData( elem ); @@ -143,34 +172,5 @@ jQuery.fn.extend({ } }); -function dataAttr( elem, key, data ) { - var name; - - // If nothing was found internally, try to fetch any - // data from the HTML5 data-* attribute - if ( data === undefined && elem.nodeType === 1 ) { - name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); - data = elem.getAttribute( name ); - - if ( typeof data === "string" ) { - try { - data = data === "true" ? true : - data === "false" ? false : - data === "null" ? null : - // Only convert to a number if it doesn't change the string - +data + "" === data ? +data : - rbrace.test( data ) ? JSON.parse( data ) : - data; - } catch( e ) {} - - // Make sure we set the data so it isn't changed later - data_user.set( elem, key, data ); - } else { - data = undefined; - } - } - return data; -} - return jQuery; }); |