mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Core: restore enumeration behavior in isPlainObject
Fixes gh-2968 Close gh-2970
This commit is contained in:
parent
6403cf614f
commit
63317eb474
@ -328,13 +328,21 @@ QUnit.test( "type for `Symbol`", function( assert ) {
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.asyncTest( "isPlainObject", function( assert ) {
|
QUnit.asyncTest( "isPlainObject", function( assert ) {
|
||||||
assert.expect( 16 );
|
assert.expect( 20 );
|
||||||
|
|
||||||
var pass, iframe, doc,
|
var pass, iframe, doc, parentObj, childObj, deep,
|
||||||
fn = function() {};
|
fn = function() {};
|
||||||
|
|
||||||
// The use case that we want to match
|
// The use case that we want to match
|
||||||
assert.ok( jQuery.isPlainObject( {} ), "{}" );
|
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
|
// Not objects shouldn't be matched
|
||||||
assert.ok( !jQuery.isPlainObject( "" ), "string" );
|
assert.ok( !jQuery.isPlainObject( "" ), "string" );
|
||||||
@ -372,6 +380,10 @@ QUnit.asyncTest( "isPlainObject", function( assert ) {
|
|||||||
|
|
||||||
assert.ok( !jQuery.isPlainObject( new fn() ), "fn (inherited and own properties)" );
|
assert.ok( !jQuery.isPlainObject( new fn() ), "fn (inherited and own properties)" );
|
||||||
|
|
||||||
|
// Deep object
|
||||||
|
deep = { "foo": { "baz": true }, "foo2": document };
|
||||||
|
assert.ok( jQuery.isPlainObject( deep ), "Object with objects is still plain" );
|
||||||
|
|
||||||
// DOM Element
|
// DOM Element
|
||||||
assert.ok( !jQuery.isPlainObject( document.createElement( "div" ) ), "DOM Element" );
|
assert.ok( !jQuery.isPlainObject( document.createElement( "div" ) ), "DOM Element" );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user