Skip to content

Commit 63317eb

Browse files
committed
Core: restore enumeration behavior in isPlainObject
Fixes jquerygh-2968 Close jquerygh-2970
1 parent 6403cf6 commit 63317eb

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

test/unit/core.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,13 +328,21 @@ QUnit.test( "type for `Symbol`", function( assert ) {
328328
} );
329329

330330
QUnit.asyncTest( "isPlainObject", function( assert ) {
331-
assert.expect( 16 );
331+
assert.expect( 20 );
332332

333-
var pass, iframe, doc,
333+
var pass, iframe, doc, parentObj, childObj, deep,
334334
fn = function() {};
335335

336336
// The use case that we want to match
337337
assert.ok( jQuery.isPlainObject( {} ), "{}" );
338+
assert.ok( jQuery.isPlainObject( new window.Object() ), "new Object" );
339+
340+
parentObj = { foo: "bar" };
341+
childObj = Object.create( parentObj );
342+
343+
assert.ok( !jQuery.isPlainObject( childObj ), "isPlainObject(Object.create({}))" );
344+
childObj.bar = "foo";
345+
assert.ok( !jQuery.isPlainObject( childObj ), "isPlainObject(Object.create({}))" );
338346

339347
// Not objects shouldn't be matched
340348
assert.ok( !jQuery.isPlainObject( "" ), "string" );
@@ -372,6 +380,10 @@ QUnit.asyncTest( "isPlainObject", function( assert ) {
372380

373381
assert.ok( !jQuery.isPlainObject( new fn() ), "fn (inherited and own properties)" );
374382

383+
// Deep object
384+
deep = { "foo": { "baz": true }, "foo2": document };
385+
assert.ok( jQuery.isPlainObject( deep ), "Object with objects is still plain" );
386+
375387
// DOM Element
376388
assert.ok( !jQuery.isPlainObject( document.createElement( "div" ) ), "DOM Element" );
377389

0 commit comments

Comments
 (0)