]> source.dussan.org Git - jquery.git/commitdiff
Wrap obj.constructor test in try/catch. Thanks to bkrausz. Fixes #9897 445/head
authorRick Waldron <waldron.rick@gmail.com>
Mon, 25 Jul 2011 21:06:38 +0000 (17:06 -0400)
committerRick Waldron <waldron.rick@gmail.com>
Mon, 25 Jul 2011 21:06:38 +0000 (17:06 -0400)
src/core.js
test/unit/core.js

index 715d73ad37bd5057ae3dbebac5114ac328672cf7..f10d9edea089ede6bb65536361c2a77b68d61414 100644 (file)
@@ -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;
                }
 
index 8c285f6dd89411ad539e8b3efde45b2392a09449..7599455dfaa746687786b5b99acd78930edd4ea1 100644 (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);