aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Bedard <jason+github@jbedard.ca>2015-07-18 11:27:11 -0700
committerMichał Gołębiowski <m.goleb@gmail.com>2015-09-08 20:22:54 +0200
commit0e982433eb94391b3e9f6838d9b8fbf9bb31abf9 (patch)
tree8a31c3546949a82aa3f6fea775b2a3dda06b1605 /src
parentd4def22e4cd1c2eb2571f449e226b38384fb6d81 (diff)
downloadjquery-0e982433eb94391b3e9f6838d9b8fbf9bb31abf9.tar.gz
jquery-0e982433eb94391b3e9f6838d9b8fbf9bb31abf9.zip
Data: avoid using delete on DOM nodes
Closes gh-2479
Diffstat (limited to 'src')
-rw-r--r--src/data/Data.js18
-rw-r--r--src/manipulation.js10
2 files changed, 21 insertions, 7 deletions
diff --git a/src/data/Data.js b/src/data/Data.js
index e0d1eadcd..625d203cf 100644
--- a/src/data/Data.js
+++ b/src/data/Data.js
@@ -20,13 +20,12 @@ Data.prototype = {
if ( owner.nodeType ) {
owner[ this.expando ] = value;
- // Otherwise secure it in a non-enumerable, non-writable property
- // configurability must be true to allow the property to be
- // deleted with the delete operator
+ // Otherwise secure it in a non-enumerable property
+ // configurable must be true to allow the property to be
+ // deleted when data is removed
} else {
Object.defineProperty( owner, this.expando, {
value: value,
- writable: true,
configurable: true
} );
}
@@ -144,7 +143,16 @@ Data.prototype = {
// Remove the expando if there's no more data
if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
- delete owner[ this.expando ];
+
+ // Support: Chrome <= 35-45+
+ // Webkit & Blink performance suffers when deleting properties
+ // from DOM nodes, so set to undefined instead
+ // https://code.google.com/p/chromium/issues/detail?id=378607
+ if ( owner.nodeType ) {
+ owner[ this.expando ] = undefined;
+ } else {
+ delete owner[ this.expando ];
+ }
}
},
hasData: function( owner ) {
diff --git a/src/manipulation.js b/src/manipulation.js
index b85ef1824..ceb970cbd 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -290,10 +290,16 @@ jQuery.extend( {
}
}
}
- delete elem[ dataPriv.expando ];
+
+ // Support: Chrome <= 35-45+
+ // Assign undefined instead of using delete, see Data#remove
+ elem[ dataPriv.expando ] = undefined;
}
if ( elem[ dataUser.expando ] ) {
- delete elem[ dataUser.expando ];
+
+ // Support: Chrome <= 35-45+
+ // Assign undefined instead of using delete, see Data#remove
+ elem[ dataUser.expando ] = undefined;
}
}
}