MCPcopy Index your code
hub / github.com/JsAaron/jQuery / dataAttr

Function dataAttr

1.7/data.js:312–340  ·  view source on GitHub ↗
( elem, key, data )

Source from the content-addressed store, hash-verified

310});
311
312function dataAttr( elem, key, data ) {
313 // If nothing was found internally, try to fetch any
314 // data from the HTML5 data-* attribute
315 if ( data === undefined && elem.nodeType === 1 ) {
316
317 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
318
319 data = elem.getAttribute( name );
320
321 if ( typeof data === "string" ) {
322 try {
323 data = data === "true" ? true :
324 data === "false" ? false :
325 data === "null" ? null :
326 jQuery.isNumeric( data ) ? parseFloat( data ) :
327 rbrace.test( data ) ? jQuery.parseJSON( data ) :
328 data;
329 } catch( e ) {}
330
331 // Make sure we set the data so it isn't changed later
332 jQuery.data( elem, key, data );
333
334 } else {
335 data = undefined;
336 }
337 }
338
339 return data;
340}
341
342// checks a cache object for emptiness
343function isEmptyDataObject( obj ) {

Callers 1

data.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected