aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorTimmy Willison <timmywillisn@gmail.com>2016-03-03 18:29:45 -0500
committerTimmy Willison <timmywillisn@gmail.com>2016-03-07 11:23:33 -0500
commit63397aaaeaca78dc79e7d9a0860e529c2b7194ec (patch)
tree3fb8ba74025560826bbc2d0f4631537e0314f1f4 /test
parentc5c30735311c74c60689fcabdcf2cb192524000e (diff)
downloadjquery-63397aaaeaca78dc79e7d9a0860e529c2b7194ec.tar.gz
jquery-63397aaaeaca78dc79e7d9a0860e529c2b7194ec.zip
Core: restore enumeration behavior in isPlainObject
Fixes gh-2968 Close gh-2970
Diffstat (limited to 'test')
-rw-r--r--test/unit/core.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/test/unit/core.js b/test/unit/core.js
index accdae8e1..e33f65358 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -268,13 +268,21 @@ QUnit.test( "type for `Symbol`", function( assert ) {
} );
QUnit.asyncTest( "isPlainObject", function( assert ) {
- assert.expect( 15 );
+ assert.expect( 19 );
- var pass, iframe, doc,
+ var pass, iframe, doc, parentObj, childObj, deep,
fn = function() {};
// The use case that we want to match
assert.ok( jQuery.isPlainObject( {} ), "{}" );
+ assert.ok( jQuery.isPlainObject( new window.Object() ), "new Object" );
+
+ parentObj = { foo: "bar" };
+ childObj = Object.create( parentObj );
+
+ assert.ok( !jQuery.isPlainObject( childObj ), "isPlainObject(Object.create({}))" );
+ childObj.bar = "foo";
+ assert.ok( !jQuery.isPlainObject( childObj ), "isPlainObject(Object.create({}))" );
// Not objects shouldn't be matched
assert.ok( !jQuery.isPlainObject( "" ), "string" );
@@ -302,6 +310,10 @@ QUnit.asyncTest( "isPlainObject", function( assert ) {
// Again, instantiated objects shouldn't be matched
assert.ok( !jQuery.isPlainObject( new fn() ), "new fn" );
+ // Deep object
+ deep = { "foo": { "baz": true }, "foo2": document };
+ assert.ok( jQuery.isPlainObject( deep ), "Object with objects is still plain" );
+
// DOM Element
assert.ok( !jQuery.isPlainObject( document.createElement( "div" ) ), "DOM Element" );