MCPcopy Create free account
hub / github.com/JsAaron/jQuery / dataAttr

Function dataAttr

2.0.3/2.0.3.js:3635–3662  ·  view source on GitHub ↗
( elem, key, data )

Source from the content-addressed store, hash-verified

3633 });
3634
3635 function dataAttr( elem, key, data ) {
3636 var name;
3637
3638 // If nothing was found internally, try to fetch any
3639 // data from the HTML5 data-* attribute
3640 if ( data === undefined && elem.nodeType === 1 ) {
3641 name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
3642 data = elem.getAttribute( name );
3643
3644 if ( typeof data === "string" ) {
3645 try {
3646 data = data === "true" ? true :
3647 data === "false" ? false :
3648 data === "null" ? null :
3649 // Only convert to a number if it doesn't change the string
3650 +data + "" === data ? +data :
3651 rbrace.test( data ) ? JSON.parse( data ) :
3652 data;
3653 } catch( e ) {}
3654
3655 // Make sure we set the data so it isn't changed later
3656 data_user.set( elem, key, data );
3657 } else {
3658 data = undefined;
3659 }
3660 }
3661 return data;
3662 }
3663 jQuery.extend({
3664 queue: function( elem, type, data ) {
3665 var queue;

Callers 1

2.0.3.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected