Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

angular.equals(a, b) != angular.equals(b, a) where a = {} && b = {x:undefined} #1648

Closed
noreal81 opened this issue Dec 5, 2012 · 0 comments

Comments

@noreal81
Copy link

noreal81 commented Dec 5, 2012

Parameter ordering is affecting the output of angular.equals when there are undefined, but present, properties on one of the objects.

a = {};
b = {x:undefined};
angular.equals(a, b) == angular.equals(b, a) // returns false.

http://jsfiddle.net/YCDRx/3/

It appears that this is not fixed between 1.0.2 and HEAD.

IgorMinar added a commit to IgorMinar/angular.js that referenced this issue Jan 18, 2013
previously:

a = {};
b = {x:undefined};
angular.equals(a, b) == angular.equals(b, a) // returns false.

both should return false because these objects are not equal.

unlike in implemented in angular#1695 the comparison should be stricter
and return false not true. if we need to relax this in the future
we can always do so.

Closes angular#1648
jamessharp pushed a commit to jamessharp/angular.js that referenced this issue Jan 18, 2013
previously:

a = {};
b = {x:undefined};
angular.equals(a, b) == angular.equals(b, a) // returns false.

both should return false because these objects are not equal.

unlike in implemented in angular#1695 the comparison should be stricter
and return false not true. if we need to relax this in the future
we can always do so.

Closes angular#1648
dbinit pushed a commit to dbinit/angular.js that referenced this issue Jan 18, 2013
previously:

a = {};
b = {x:undefined};
angular.equals(a, b) == angular.equals(b, a) // returns false.

both should return false because these objects are not equal.

unlike in implemented in angular#1695 the comparison should be stricter
and return false not true. if we need to relax this in the future
we can always do so.

Closes angular#1648
IgorMinar added a commit that referenced this issue Jan 22, 2013
in 5ae63fd the comparison was made consistent but strict, so that

angular.equals({}, {foo: undefined}) // always returns false

this turns out to cause issues for data that is being roundtripped via network
and serialized via JSON because JSON.stringify serializes {foo: undefined} as {}.

Since angular.equals() behaved like this before the 5ae63fd in 50% of the cases,
changing the behavior in this way should not introduce any significant issues.

Closes #1648
IgorMinar added a commit that referenced this issue Jan 22, 2013
in 5ae63fd the comparison was made consistent but strict, so that

angular.equals({}, {foo: undefined}) // always returns false

this turns out to cause issues for data that is being roundtripped via network
and serialized via JSON because JSON.stringify serializes {foo: undefined} as {}.

Since angular.equals() behaved like this before the 5ae63fd in 50% of the cases,
changing the behavior in this way should not introduce any significant issues.

Closes #1648
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants