Always keep the binding of the right in a two way binding

When having a binding such as
```
  foo <=> bar
```
The default value will always be the value of `bar` regardless what's
the value of foo.

This change of behavior is the only one that makes sense bacause if we
are having repeater or if, this will be a problem. eg:
```
property <xxx> bar;
if (some_cndition) : SomeElement {
   foo <=> bar;
}
```
Then we can't possibly take the default value of foo for the value of
bar since it depends on the condition. (and it is even worse in case of
repeater)

This is a change of behevior, this is why the tests have changed. The
cse of tests/cases/bindings/* were already covered by a warning since
0.3.0 so that should be fine. But the warning did not trigger for
builtin property such as `visible`  (eg, input/visible_mouse test)

Also some internal two way bindings had to be reversed.

cc: #1394
This commit is contained in:
Olivier Goffart 2022-11-04 11:34:17 +01:00 committed by Olivier Goffart
parent 0ea7c136f3
commit 425b477874
6 changed files with 66 additions and 73 deletions

View file

@ -1240,8 +1240,9 @@ impl BindingExpression {
if self.animation.is_none() {
self.animation = other.animation.clone();
}
let has_binding = self.has_binding();
self.two_way_bindings.extend_from_slice(&other.two_way_bindings);
if matches!(self.expression, Expression::Invalid) {
if !has_binding {
self.priority = other.priority;
self.expression = other.expression.clone();
true