MCPcopy
hub / github.com/jquery-backstretch/jquery-backstretch / dataAttr

Function dataAttr

libs/jquery/jquery.js:1801–1830  ·  view source on GitHub ↗
( elem, key, data )

Source from the content-addressed store, hash-verified

1799});
1800
1801function dataAttr( elem, key, data ) {
1802 // If nothing was found internally, try to fetch any
1803 // data from the HTML5 data-* attribute
1804 if ( data === undefined && elem.nodeType === 1 ) {
1805
1806 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
1807
1808 data = elem.getAttribute( name );
1809
1810 if ( typeof data === "string" ) {
1811 try {
1812 data = data === "true" ? true :
1813 data === "false" ? false :
1814 data === "null" ? null :
1815 // Only convert to a number if it doesn't change the string
1816 +data + "" === data ? +data :
1817 rbrace.test( data ) ? jQuery.parseJSON( data ) :
1818 data;
1819 } catch( e ) {}
1820
1821 // Make sure we set the data so it isn't changed later
1822 jQuery.data( elem, key, data );
1823
1824 } else {
1825 data = undefined;
1826 }
1827 }
1828
1829 return data;
1830}
1831
1832// checks a cache object for emptiness
1833function isEmptyDataObject( obj ) {

Callers 1

jquery.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected