Permalink
Browse files

Data: avoid Object.defineProperties for nodes

Closes gh-1668
Fixes gh-1728
Ref gh-1734
Ref gh-1428
  • Loading branch information...
jbedard authored and timmywil committed Sep 26, 2014
1 parent 2380028 commit 95fb798980d7e404c413e29e20016db9052e2bf2
Showing with 9 additions and 13 deletions.
  1. +9 −13 src/data/Data.js
View
@@ -29,24 +29,20 @@ Data.prototype = {
return 0;
}
var descriptor = {},
// Check if the owner object already has a cache key
unlock = owner[ this.expando ];
// Check if the owner object already has a cache key
var unlock = owner[ this.expando ];
// If not, create one
if ( !unlock ) {
unlock = Data.uid++;
// Secure it in a non-enumerable, non-writable property
try {
descriptor[ this.expando ] = { value: unlock };
Object.defineProperties( owner, descriptor );
// Support: Android<4
// Fallback to a less secure definition
} catch ( e ) {
descriptor[ this.expando ] = unlock;
jQuery.extend( owner, descriptor );
// If it is a node unlikely to be stringify-ed or looped over
// use plain assignment
if ( owner.nodeType ) {
owner[ this.expando ] = unlock;
// Otherwise secure it in a non-enumerable, non-writable property
} else {
Object.defineProperty( owner, this.expando, { value: unlock } );
}
}

0 comments on commit 95fb798

Please sign in to comment.