The Issue
Current version of aurelia-bindinig@2.5.5 resolves value of non-existing member of an object differently when the object is null vs undefined or non existant.
For example, binding expression foo.bar would resolve to null for:
but would resolve to undefined for:
and
while if foo is an empty object, binding expression foo.bar would correctly return undefined:
This unpredictability produces issue in some binding scenarios. For example:
<input type="radio" model.bind="null" checked.bind="foo.bar" />
<input type="radio" model.bind="false" checked.bind="foo.bar" />
<input type="radio" model.bind="true" checked.bind="foo.bar" />
The culprit is this method:
|
evaluate(scope, lookupFunctions) { |
|
let instance = this.object.evaluate(scope, lookupFunctions); |
|
return instance === null || instance === undefined ? instance : instance[this.name]; |
|
} |
Instead of returning instance, it should return undefined:
evaluate(scope, lookupFunctions) {
let instance = this.object.evaluate(scope, lookupFunctions);
return instance === null || instance === undefined ? undefined: instance[this.name];
}
Expected behavior
foo.bar binding expression should return undefined for all 4 cases:
{ foo: null }
{ foo: undefined }
{ foo: {} }
{}
It would also be consistant with result of JavaScript optinal chaning syntax this.foo?.bar.
The Issue
Current version of
aurelia-bindinig@2.5.5resolves value of non-existing member of an object differently when the object isnullvsundefinedor non existant.For example, binding expression
foo.barwould resolve tonullfor:but would resolve to
undefinedfor:and
while if
foois an empty object, binding expressionfoo.barwould correctly returnundefined:This unpredictability produces issue in some binding scenarios. For example:
The culprit is this method:
binding/src/ast.js
Lines 251 to 254 in ed35588
Instead of returning
instance, it should returnundefined:Expected behavior
foo.barbinding expression should returnundefinedfor all 4 cases:It would also be consistant with result of JavaScript optinal chaning syntax
this.foo?.bar.