Commit e5705773 authored by Dave Methvin's avatar Dave Methvin

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.
parents 3ba72f99 ad16db37
...@@ -502,10 +502,15 @@ jQuery.extend({ ...@@ -502,10 +502,15 @@ jQuery.extend({
return false; return false;
} }
// Not own constructor property must be Object try {
if ( obj.constructor && // Not own constructor property must be Object
!hasOwn.call(obj, "constructor") && if ( obj.constructor &&
!hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { !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; return false;
} }
......
...@@ -290,7 +290,7 @@ test("type", function() { ...@@ -290,7 +290,7 @@ test("type", function() {
}); });
test("isPlainObject", function() { test("isPlainObject", function() {
expect(14); expect(15);
stop(); stop();
...@@ -331,6 +331,13 @@ test("isPlainObject", function() { ...@@ -331,6 +331,13 @@ test("isPlainObject", function() {
// Window // Window
ok(!jQuery.isPlainObject(window), "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 { try {
var iframe = document.createElement("iframe"); var iframe = document.createElement("iframe");
document.body.appendChild(iframe); document.body.appendChild(iframe);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment