Skip to content
Permalink
Browse files

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.
  • Loading branch information...
dmethvin committed Aug 25, 2011
2 parents 3ba72f9 + ad16db3 commit e57057739bf0b272113b4b7aa0f3efa369d3fd69
Showing with 17 additions and 5 deletions.
  1. +9 −4 src/core.js
  2. +8 −1 test/unit/core.js
@@ -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;
}

@@ -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);

0 comments on commit e570577

Please sign in to comment.
You can’t perform that action at this time.