Skip to content

Commit

Permalink
Fix incorrect warning about missing interpolation variables
Browse files Browse the repository at this point in the history
Fixes aurelia#273 caused by interpolating the value before its params were bound.
  • Loading branch information
rluba committed Dec 17, 2020
1 parent 6ebb86c commit 92cb071
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/t/t-custom-attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,25 @@ export class TCustomAttribute {
};
}

const p = this.params !== null ? this.params.value : undefined;
this.subscription = this.ea.subscribe(I18N_EA_SIGNAL, () => {
this.service.updateValue(this.element, this.value, this.params !== null ? this.params.value : undefined);
});

this.service.updateValue(this.element, this.value, p);
// Don’t update the translation if params are given, but not yet bound.
// (Otherwise, we’ll get warnings about missing variables during interpolation.)
// In that case, the initial translation will happen via the paramsChanged handler.
if (!this.params || this.params.value !== undefined) {
const p = this.params ? this.params.value : undefined;
this.service.updateValue(this.element, this.value, p);
}
}

public paramsChanged(newValue: any, newParams: any) {
this.service.updateValue(this.element, newValue, newParams);
}

public valueChanged(newValue: any) {
const p = this.params !== null ? this.params.value : undefined;
const p = this.params ? this.params.value : undefined;
this.service.updateValue(this.element, newValue, p);
}

Expand Down

0 comments on commit 92cb071

Please sign in to comment.