mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Data: avoid Object.defineProperties for nodes
Closes gh-1668 Fixes gh-1728 Ref gh-1734 Ref gh-1428
This commit is contained in:
parent
2380028ec4
commit
95fb798980
@ -29,24 +29,20 @@ Data.prototype = {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var descriptor = {},
|
// Check if the owner object already has a cache key
|
||||||
// Check if the owner object already has a cache key
|
var unlock = owner[ this.expando ];
|
||||||
unlock = owner[ this.expando ];
|
|
||||||
|
|
||||||
// If not, create one
|
// If not, create one
|
||||||
if ( !unlock ) {
|
if ( !unlock ) {
|
||||||
unlock = Data.uid++;
|
unlock = Data.uid++;
|
||||||
|
|
||||||
// Secure it in a non-enumerable, non-writable property
|
// If it is a node unlikely to be stringify-ed or looped over
|
||||||
try {
|
// use plain assignment
|
||||||
descriptor[ this.expando ] = { value: unlock };
|
if ( owner.nodeType ) {
|
||||||
Object.defineProperties( owner, descriptor );
|
owner[ this.expando ] = unlock;
|
||||||
|
// Otherwise secure it in a non-enumerable, non-writable property
|
||||||
// Support: Android<4
|
} else {
|
||||||
// Fallback to a less secure definition
|
Object.defineProperty( owner, this.expando, { value: unlock } );
|
||||||
} catch ( e ) {
|
|
||||||
descriptor[ this.expando ] = unlock;
|
|
||||||
jQuery.extend( owner, descriptor );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user