update components
This commit is contained in:
+26
-8
@@ -20,6 +20,31 @@ define( [
|
||||
var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
|
||||
rmultiDash = /[A-Z]/g;
|
||||
|
||||
function getData( data ) {
|
||||
if ( data === "true" ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( data === "false" ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( data === "null" ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Only convert to a number if it doesn't change the string
|
||||
if ( data === +data + "" ) {
|
||||
return +data;
|
||||
}
|
||||
|
||||
if ( rbrace.test( data ) ) {
|
||||
return JSON.parse( data );
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function dataAttr( elem, key, data ) {
|
||||
var name;
|
||||
|
||||
@@ -31,14 +56,7 @@ function dataAttr( elem, key, data ) {
|
||||
|
||||
if ( typeof data === "string" ) {
|
||||
try {
|
||||
data = data === "true" ? true :
|
||||
data === "false" ? false :
|
||||
data === "null" ? null :
|
||||
|
||||
// Only convert to a number if it doesn't change the string
|
||||
+data + "" === data ? +data :
|
||||
rbrace.test( data ) ? JSON.parse( data ) :
|
||||
data;
|
||||
data = getData( data );
|
||||
} catch ( e ) {}
|
||||
|
||||
// Make sure we set the data so it isn't changed later
|
||||
|
||||
Reference in New Issue
Block a user