-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Logical operators return incorrect results when used on forgiving expressions. #12099
Comments
Another example, using "forgiving" function calls: I guess that in general this weird behaviour happens when using boolean operators on the results of "forgiving" expressions. But nothing in the docs about forgiving expressions suggests that this behaviour should occur, and it's bizarre; it's a violation of the simple mental model of "calling Of course, any fix to this will be a breaking change, but it seems like a clear bug. |
The issues originally posted are fixed as part of d19504a the other is a real issue. Should have a patch soon |
When there is an expression of the form `true && a.b` and where `a == null`, then set the value of `true || a()` to `undefined`. Closes angular#12099
@lgalfaso are you sure the first issue has been fixed? In the jsbin, the first ng-if for 'AND' should evaluate to undefined, i.e. be not visible. This doesn't work with the snapshot, but it does work in 1.3.16 |
When there is an expression of the form * true && a.b.c * true && a() * true && a()() * false || a.b.c * false || a() * false || a()() where `a == null` Closes angular#12099
Mmm.. @Narretz you are right, updated the PR to fix
where These are all small variations of the same issue, hopefully this should fix all the variations |
When there is an expression of the form * true && a.b.c * true && a() * true && a()() * false || a.b.c * false || a() * false || a()() where `a == null` Closes angular#12099
When there is an expression of the form * true && a.b.c * true && a() * true && a()() * false || a.b.c * false || a() * false || a()() where `a == null` Closes angular#12099
When there is an expression of the form * true && a.b.c * true && a() * true && a()() * false || a.b.c * false || a() * false || a()() where `a == null` Closes angular#12099
@ExplodingCabbage they are all fixed, in fact we have tests for
|
When there is an expression of the form * true && a.b.c * true && a() * true && a()() * false || a.b.c * false || a() * false || a()() where `a == null` Closes angular#12099
Version: 1.4.0-rc.2
Given the following statements:
scope.$eval("true && does.not.exist");
scope.$eval("true && !does.not.exist");
Both return
true
, as long asdoes.not
is not an object on the current scope.However
scope.$eval("true && doesnotexist");
andscope.$eval("true && undefined");
both returnfalse
as expected as long asdoesnotexist
is not a truthy value on the current scope.This makes me think it has something to do with using
scope.$parse
as it only occurs when attempting to access nested properties of undefined values on the scope whichscope.$parse
suppresses errors for.For this reason any directive such as
ng-if
andng-switch
. For examples see: http://jsbin.com/muqaviwesu/1/edit?html,js,outputThe text was updated successfully, but these errors were encountered: