Skip to content

Commit 5c82d36

Browse files
committed
Revert 8d1c422
1 parent 8d1c422 commit 5c82d36

File tree

2 files changed

+5
-49
lines changed

2 files changed

+5
-49
lines changed

src/core.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,8 @@ jQuery.extend({
422422
},
423423

424424
isPlainObject: function( obj ) {
425-
var key;
426425
// Not plain objects:
427426
// - Any object or value whose internal [[Class]] property is not "[object Object]"
428-
// ...Unless it was a constructor, whose prototype property was paved over by
429-
// by a plain object at its declaration. #13571
430427
// - DOM nodes
431428
// - window
432429
if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
@@ -445,11 +442,9 @@ jQuery.extend({
445442
return false;
446443
}
447444

448-
// Own properties are enumerated firstly, so to speed up,
449-
// if last one is own, then all properties are own.
450-
for ( key in obj ) {}
451-
452-
return key === undefined || core_hasOwn.call( obj, key );
445+
// If the function hasn't returned already, we're confident that
446+
// |obj| is a plain object, created by {} or constructed with new Object
447+
return true;
453448
},
454449

455450
isEmptyObject: function( obj ) {

test/unit/core.js

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,9 @@ test("type", function() {
296296
});
297297

298298
asyncTest("isPlainObject", function() {
299-
expect(16);
299+
expect(15);
300300

301-
var pass, iframe, doc, c, extended,
301+
var pass, iframe, doc,
302302
fn = function() {};
303303

304304
// The use case that we want to match
@@ -360,45 +360,6 @@ asyncTest("isPlainObject", function() {
360360
} catch(e) {
361361
window.iframeDone( Object, "iframes not supported" );
362362
}
363-
364-
// #13571
365-
function C() {}
366-
C.prototype = {
367-
x: 1
368-
};
369-
c = new C();
370-
371-
extended = jQuery.extend( true, {}, {
372-
target: c
373-
});
374-
375-
strictEqual(
376-
extended.target, c,
377-
"Instances, whose constructor defined its prototype by assigning a plain object, " +
378-
"will lie about their true identity to preserve a broken user-code expectation"
379-
);
380-
//
381-
// The test above is broken and tests a broken feature, to support a misinformed
382-
// assumption, as documented here:
383-
//
384-
// http://bugs.jquery.com/ticket/13571#comment:4
385-
//
386-
// It will not pass if the object being assigned as the prototype
387-
// has no properties:
388-
//
389-
// function C() {}
390-
// C.prototype = {};
391-
// c = new C();
392-
393-
// extended = jQuery.extend( true, {}, {
394-
// target: c
395-
// });
396-
397-
// strictEqual( extended.target, c, "Undetectable, will fail every time" );
398-
//
399-
// The solution is to reset the constructor property of your plain object prototypes.
400-
//
401-
//
402363
});
403364

404365
test("isFunction", function() {

0 commit comments

Comments
 (0)