| 1980 | }); |
| 1981 | |
| 1982 | function 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 |
| 2013 | function isEmptyDataObject( obj ) { |