diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2011-08-25 12:25:58 -0700 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2011-08-25 12:25:58 -0700 |
commit | e57057739bf0b272113b4b7aa0f3efa369d3fd69 (patch) | |
tree | f4c9674df0a51c6d39338b43c5444432a041d8e2 | |
parent | 3ba72f991dccbae6020c23d6f7a65435f4ca6f03 (diff) | |
parent | ad16db370e3a18819c9dea0f0e09495bafddd13c (diff) | |
download | jquery-e57057739bf0b272113b4b7aa0f3efa369d3fd69.tar.gz jquery-e57057739bf0b272113b4b7aa0f3efa369d3fd69.zip |
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.
-rw-r--r-- | src/core.js | 13 | ||||
-rw-r--r-- | test/unit/core.js | 9 |
2 files changed, 17 insertions, 5 deletions
diff --git a/src/core.js b/src/core.js index 85a381661..594910df5 100644 --- a/src/core.js +++ b/src/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; } diff --git a/test/unit/core.js b/test/unit/core.js index a6783e02e..fdf0ceb5e 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -290,7 +290,7 @@ test("type", function() { }); test("isPlainObject", function() { - expect(14); + expect(15); stop(); @@ -332,6 +332,13 @@ test("isPlainObject", function() { 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); |