From aa6e2fae09a613714ebc26368a2c6031d3fbaab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Mon, 11 Feb 2013 18:24:08 -0800 Subject: [PATCH] Improve Base#equals(). --- src/core/Base.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/Base.js b/src/core/Base.js index 5ba8ad33..3f90c741 100644 --- a/src/core/Base.js +++ b/src/core/Base.js @@ -80,13 +80,12 @@ this.Base = Base.inject(/** @lends Base# */{ return false; return true; } - if (obj1 == obj2) return true; // Call #equals() on both obj1 and obj2 - if (obj1 != null && obj1.equals) + if (obj1 && obj1.equals) return obj1.equals(obj2); - if (obj2 != null && obj2.equals) + if (obj2 && obj2.equals) return obj2.equals(obj1); // Compare arrays if (Array.isArray(obj1) && Array.isArray(obj2)) { @@ -99,7 +98,8 @@ this.Base = Base.inject(/** @lends Base# */{ return true; } // Compare objects - if (typeof obj1 === 'object' && typeof obj2 === 'object') { + if (obj1 && typeof obj1 === 'object' + && obj2 && typeof obj2 === 'object') { if (!checkKeys(obj1, obj2) || !checkKeys(obj2, obj1)) return false; for (var i in obj1) {