Improved check for plain objects
authorAlexander Ebert <ebert@woltlab.com>
Fri, 29 May 2015 22:14:28 +0000 (00:14 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 29 May 2015 22:14:28 +0000 (00:14 +0200)
wcfsetup/install/files/js/WoltLab/WCF/Core.js

index cd8649a37bba4e2c078300c43393305a30c80651..b37850c5432b774113f5fc8a06da0a09c484840e 100644 (file)
@@ -125,15 +125,11 @@ define([], function() {
                 * @returns     {boolean}       true if target is an object literal
                 */
                isPlainObject: function(obj) {
-                       if (obj === window || obj.nodeType) {
+                       if (typeof obj !== 'object' || obj === null || obj.nodeType) {
                                return false;
                        }
                        
-                       if (obj.constructor && !obj.constructor.prototype.hasOwnProperty('isPrototypeOf')) {
-                               return false;
-                       }
-                       
-                       return true;
+                       return (Object.getPrototypeOf(obj) === Object.prototype);
                },
                
                /**