MCPcopy Create free account
hub / github.com/F-Stack/f-stack / dataAttr

Function dataAttr

tools/libxo/xohtml/external/jquery.js:1982–2010  ·  view source on GitHub ↗
( elem, key, data )

Source from the content-addressed store, hash-verified

1980});
1981
1982function dataAttr( elem, key, data ) {
1983 // If nothing was found internally, try to fetch any
1984 // data from the HTML5 data-* attribute
1985 if ( data === undefined && elem.nodeType === 1 ) {
1986
1987 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
1988
1989 data = elem.getAttribute( name );
1990
1991 if ( typeof data === "string" ) {
1992 try {
1993 data = data === "true" ? true :
1994 data === "false" ? false :
1995 data === "null" ? null :
1996 jQuery.isNumeric( data ) ? parseFloat( data ) :
1997 rbrace.test( data ) ? jQuery.parseJSON( data ) :
1998 data;
1999 } catch( e ) {}
2000
2001 // Make sure we set the data so it isn't changed later
2002 jQuery.data( elem, key, data );
2003
2004 } else {
2005 data = undefined;
2006 }
2007 }
2008
2009 return data;
2010}
2011
2012// checks a cache object for emptiness
2013function isEmptyDataObject( obj ) {

Callers 1

jquery.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected