Merge pull request #445 from rwldrn/9897

Fixes #9897. Wrap obj.constructor test in try/catch to avoid problems with host objects. Thanks to bkrausz.
This commit is contained in:
Dave Methvin 2011-08-25 12:25:58 -07:00
commit e57057739b
2 changed files with 17 additions and 5 deletions

View File

@ -502,10 +502,15 @@ jQuery.extend({
return false;
}
// Not own constructor property must be Object
if ( obj.constructor &&
!hasOwn.call(obj, "constructor") &&
!hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
try {
// Not own constructor property must be Object
if ( obj.constructor &&
!hasOwn.call(obj, "constructor") &&
!hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
return false;
}
} catch ( e ) {
// IE8,9 Will throw exceptions on certain host objects #9897
return false;
}

View File

@ -290,7 +290,7 @@ test("type", function() {
});
test("isPlainObject", function() {
expect(14);
expect(15);
stop();
@ -331,6 +331,13 @@ test("isPlainObject", function() {
// Window
ok(!jQuery.isPlainObject(window), "window");
try {
jQuery.isPlainObject( window.location );
ok( true, "Does not throw exceptions on host objects");
} catch ( e ) {
ok( false, "Does not throw exceptions on host objects -- FAIL");
}
try {
var iframe = document.createElement("iframe");
document.body.appendChild(iframe);