MCPcopy Create free account
hub / github.com/benoitpointet/jquery-scrollsnap-plugin / dataAttr

Function dataAttr

demo/foundation/javascripts/jquery.js:1800–1829  ·  view source on GitHub ↗
( elem, key, data )

Source from the content-addressed store, hash-verified

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

Callers 1

jquery.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected