diff options
| -rw-r--r-- | src/Angular.js | 17 | ||||
| -rw-r--r-- | test/AngularSpec.js | 8 | 
2 files changed, 20 insertions, 5 deletions
| diff --git a/src/Angular.js b/src/Angular.js index 3a11f3ea..21b3ef07 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -620,16 +620,23 @@ function equals(o1, o2) {        } else {          if (isScope(o1) || isScope(o2) || isWindow(o1) || isWindow(o2)) return false;          keySet = {}; +        length = 0;          for(key in o1) { -          if (key.charAt(0) !== '$' && !isFunction(o1[key]) && !equals(o1[key], o2[key])) { -            return false; -          } +          if (key.charAt(0) === '$') continue; + +          if (!isFunction(o1[key]) && !equals(o1[key], o2[key])) return false; + +          length++;            keySet[key] = true;          }          for(key in o2) { -          if (!keySet[key] && key.charAt(0) !== '$' && !isFunction(o2[key])) return false; +          if (key.charAt(0) === '$') { +            continue; +          } +          if (!keySet[key] && !isFunction(o2[key])) return false; +          length--;          } -        return true; +        return length === 0;        }      }    } diff --git a/test/AngularSpec.js b/test/AngularSpec.js index 47670296..f5638b9c 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -126,6 +126,14 @@ describe('angular', function() {        expect(equals(['misko'], ['misko', 'adam'])).toEqual(false);      }); +    it('should ignore undefined member variables', function() { +      var obj1 = {name: 'misko'}, +          obj2 = {name: 'misko', undefinedvar: undefined}; + +      expect(equals(obj1, obj2)).toBe(false); +      expect(equals(obj2, obj1)).toBe(false); +    }); +      it('should ignore $ member variables', function() {        expect(equals({name:'misko', $id:1}, {name:'misko', $id:2})).toEqual(true);        expect(equals({name:'misko'}, {name:'misko', $id:2})).toEqual(true); | 
