-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
Optional arguments currently don't work with default values when the argument is undefined or null. This issue has also been observed by @artemgurzhii.
// component.js
@argument(optional('string'))
foo = 'defaultValue'{{! parent-template.hbs}}
<Component />{{! component-template.hbs}}
{{log foo}} {{! => undefined}}Also, setting the value of the optional argument in the component during any point of the component lifecycle does not mutate the value:
// component.js
didInsertElement () {
super.didInsertElement(...arguments)
this.set('foo', 'mutatedValue')
}{{! component-template.hbs}}
{{log foo}} {{! => undefined (still)}}This is also true when argument values are supplied to the component:
{{! parent-template.hbs}}
<Component @foo="providedValue" />// component.js
didInsertElement () {
super.didInsertElement(...arguments)
this.set('foo', 'mutatedValue')
}{{! component-template.hbs}}
{{log foo}} {{! => providedValue}}If this is a bug, I assume it's a problem with the getter logic for optional arguments.
artemgurzhii
Metadata
Metadata
Assignees
Labels
No labels