aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/data.js
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2020-03-02 23:02:42 +0100
committerMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2020-03-02 23:05:58 +0100
commit413ff796ae16611777581e7657cb5ca76c3cfb1d (patch)
treebb0c33a5732a10bc2d62b69f32a150306d025af0 /test/unit/data.js
parent524bcf39da9d9aba67d9ec92433462cd936fcc89 (diff)
downloadjquery-413ff796ae16611777581e7657cb5ca76c3cfb1d.tar.gz
jquery-413ff796ae16611777581e7657cb5ca76c3cfb1d.zip
Data:Event:Manipulation: Prevent collisions with Object.prototype
Make sure events & data keys matching Object.prototype properties work. A separate fix for such events on cloned elements was added as well. Fixes gh-3256 Closes gh-4603 (cherry picked from commit 9d76c0b163675505d1a901e5fe5249a2c55609bc)
Diffstat (limited to 'test/unit/data.js')
-rw-r--r--test/unit/data.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/unit/data.js b/test/unit/data.js
index bd0b4e882..138bb8399 100644
--- a/test/unit/data.js
+++ b/test/unit/data.js
@@ -989,3 +989,18 @@ QUnit.test( ".data(prop) does not create expando", function( assert ) {
}
}
} );
+
+QUnit.test( "keys matching Object.prototype properties (gh-3256)", function( assert ) {
+ assert.expect( 2 );
+
+ var div = jQuery( "<div/>" );
+
+ assert.strictEqual( div.data( "hasOwnProperty" ), undefined,
+ "hasOwnProperty not matched (before forced data creation)" );
+
+ // Force the creation of a data object for this element.
+ div.data( { foo: "bar" } );
+
+ assert.strictEqual( div.data( "hasOwnProperty" ), undefined,
+ "hasOwnProperty not matched (after forced data creation)" );
+} );