MCPcopy
hub / github.com/requirejs/requirejs / dataAttr

Function dataAttr

tests/jquery/scripts/jquery-1.7.1.js:1931–1959  ·  view source on GitHub ↗
( elem, key, data )

Source from the content-addressed store, hash-verified

1929});
1930
1931function dataAttr( elem, key, data ) {
1932 // If nothing was found internally, try to fetch any
1933 // data from the HTML5 data-* attribute
1934 if ( data === undefined && elem.nodeType === 1 ) {
1935
1936 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
1937
1938 data = elem.getAttribute( name );
1939
1940 if ( typeof data === "string" ) {
1941 try {
1942 data = data === "true" ? true :
1943 data === "false" ? false :
1944 data === "null" ? null :
1945 jQuery.isNumeric( data ) ? parseFloat( data ) :
1946 rbrace.test( data ) ? jQuery.parseJSON( data ) :
1947 data;
1948 } catch( e ) {}
1949
1950 // Make sure we set the data so it isn't changed later
1951 jQuery.data( elem, key, data );
1952
1953 } else {
1954 data = undefined;
1955 }
1956 }
1957
1958 return data;
1959}
1960
1961// checks a cache object for emptiness
1962function isEmptyDataObject( obj ) {

Callers 1

jquery-1.7.1.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…