Skip to content
Permalink
Browse files

Wrap obj.constructor test in try/catch. Thanks to bkrausz. Fixes #9897

  • Loading branch information...
rwaldron committed Jul 25, 2011
1 parent 27291ff commit ad16db370e3a18819c9dea0f0e09495bafddd13c
Showing with 17 additions and 5 deletions.
  1. +9 −4 src/core.js
  2. +8 −1 test/unit/core.js
@@ -500,10 +500,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 ad16db3

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