MCPcopy Create free account
hub / github.com/HtmlUnit/htmlunit / dataAttr

Function dataAttr

src/test/resources/libraries/jQuery/1.8.2/jquery/src/data.js:293–322  ·  view source on GitHub ↗
( elem, key, data )

Source from the content-addressed store, hash-verified

291});
292
293function dataAttr( elem, key, data ) {
294 // If nothing was found internally, try to fetch any
295 // data from the HTML5 data-* attribute
296 if ( data === undefined && elem.nodeType === 1 ) {
297
298 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
299
300 data = elem.getAttribute( name );
301
302 if ( typeof data === "string" ) {
303 try {
304 data = data === "true" ? true :
305 data === "false" ? false :
306 data === "null" ? null :
307 // Only convert to a number if it doesn't change the string
308 +data + "" === data ? +data :
309 rbrace.test( data ) ? jQuery.parseJSON( data ) :
310 data;
311 } catch( e ) {}
312
313 // Make sure we set the data so it isn't changed later
314 jQuery.data( elem, key, data );
315
316 } else {
317 data = undefined;
318 }
319 }
320
321 return data;
322}
323
324// checks a cache object for emptiness
325function isEmptyDataObject( obj ) {

Callers 1

data.jsFile · 0.70

Calls 4

replaceMethod · 0.45
getAttributeMethod · 0.45
testMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…