-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Commit
- This effectively implements our "Embrace HTML5" option - Related: http://goo.gl/GcQAtn Fixes gh-2257
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ Data.prototype = { | |
return owner[ this.expando ]; | ||
}, | ||
cache: function( owner, initial ) { | ||
|
||
// We can accept data for non-element nodes in modern browsers, | ||
// but we should not, see #8335. | ||
// Always return an empty object. | ||
|
@@ -57,14 +58,16 @@ Data.prototype = { | |
cache = this.cache( owner ); | ||
|
||
// Handle: [ owner, key, value ] args | ||
// Always use camelCase key (gh-2257) | ||
if ( typeof data === "string" ) { | ||
cache[ data ] = value; | ||
cache[ jQuery.camelCase( data ) ] = value; | ||
|
||
// Handle: [ owner, { properties } ] args | ||
} else { | ||
|
||
// Copy the properties one-by-one to the cache object | ||
for ( prop in data ) { | ||
cache[ prop ] = data[ prop ]; | ||
cache[ jQuery.camelCase( prop ) ] = data[ prop ]; | ||
} | ||
} | ||
return cache; | ||
|
@@ -73,10 +76,13 @@ Data.prototype = { | |
var cache = this.cache( owner ); | ||
|
||
return key === undefined ? | ||
cache : cache[ key ]; | ||
cache : | ||
|
||
// Always use camelCase key (gh-2257) | ||
cache[ jQuery.camelCase( key ) ]; | ||
}, | ||
access: function( owner, key, value ) { | ||
var stored; | ||
|
||
// In cases where either: | ||
// | ||
// 1. No key was specified | ||
|
@@ -89,12 +95,9 @@ Data.prototype = { | |
// 2. The data stored at the key | ||
// | ||
if ( key === undefined || | ||
((key && typeof key === "string") && value === undefined) ) { | ||
( ( key && typeof key === "string" ) && value === undefined ) ) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
timmywil
Author
Member
|
||
|
||
stored = this.get( owner, key ); | ||
|
||
return stored !== undefined ? | ||
stored : this.get( owner, jQuery.camelCase(key) ); | ||
return this.get( owner, key ); | ||
} | ||
|
||
// [*]When the key is not a string, or both a key and value | ||
|
@@ -110,7 +113,7 @@ Data.prototype = { | |
return value !== undefined ? value : key; | ||
}, | ||
remove: function( owner, key ) { | ||
var i, name, camel, | ||
var i, | ||
cache = owner[ this.expando ]; | ||
|
||
if ( cache === undefined ) { | ||
|
@@ -121,33 +124,27 @@ Data.prototype = { | |
this.register( owner ); | ||
|
||
} else { | ||
|
||
// Support array or space separated string of keys | ||
if ( jQuery.isArray( key ) ) { | ||
// If "name" is an array of keys... | ||
// When data is initially created, via ("key", "val") signature, | ||
// keys will be converted to camelCase. | ||
// Since there is no way to tell _how_ a key was added, remove | ||
// both plain key and camelCase key. #12786 | ||
// This will only penalize the array argument path. | ||
name = key.concat( key.map( jQuery.camelCase ) ); | ||
|
||
// If key is an array of keys... | ||
// We always set camelCase keys, so remove that. | ||
key = key.map( jQuery.camelCase ); | ||
} else { | ||
camel = jQuery.camelCase( key ); | ||
// Try the string as a key before any manipulation | ||
if ( key in cache ) { | ||
name = [ key, camel ]; | ||
} else { | ||
// If a key with the spaces exists, use it. | ||
// Otherwise, create an array by matching non-whitespace | ||
name = camel; | ||
name = name in cache ? | ||
[ name ] : ( name.match( rnotwhite ) || [] ); | ||
} | ||
key = jQuery.camelCase( key ); | ||
|
||
// If a key with the spaces exists, use it. | ||
// Otherwise, create an array by matching non-whitespace | ||
key = key in cache ? | ||
[ key ] : | ||
( key.match( rnotwhite ) || [] ); | ||
} | ||
|
||
i = name.length; | ||
i = key.length; | ||
|
||
while ( i-- ) { | ||
delete cache[ name[ i ] ]; | ||
delete cache[ key[ i ] ]; | ||
} | ||
} | ||
}, | ||
|
1 comment
on commit 0e79098
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/cc @rwaldron
Did the style guide change to require space on all parenthesized expressions? Used to be that nested parenthesized expressions didn't require additional padding.