aboutsummaryrefslogtreecommitdiffstats
path: root/src/data
diff options
context:
space:
mode:
authorJason Bedard <jason+github@jbedard.ca>2014-09-26 08:55:48 -0700
committerTimmy Willison <timmywillisn@gmail.com>2015-03-04 14:32:24 -0500
commit95fb798980d7e404c413e29e20016db9052e2bf2 (patch)
treed258392cba8b6cd9291775d0237bb9ed27fd0286 /src/data
parent2380028ec4a6a77401b867a51de26a3cb8e8d311 (diff)
downloadjquery-95fb798980d7e404c413e29e20016db9052e2bf2.tar.gz
jquery-95fb798980d7e404c413e29e20016db9052e2bf2.zip
Data: avoid Object.defineProperties for nodes
Closes gh-1668 Fixes gh-1728 Ref gh-1734 Ref gh-1428
Diffstat (limited to 'src/data')
-rw-r--r--src/data/Data.js22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/data/Data.js b/src/data/Data.js
index 85afd64f5..7b9ec5b54 100644
--- a/src/data/Data.js
+++ b/src/data/Data.js
@@ -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 } );
}
}