Input parameter order does matter
See original GitHub issueAfter updating from 8th to the 10th version, the input parameter order does matter.
š bug report
Affected Package
The issue is caused by package @angular/coreIs this a regression?
Yes, the previous version in which this bug was not present was: 8th versionDescription
In case the Input decorator is used on a setter and a parallel input parameter is used inside the setter, this parallel parameter is not available during the setter execution.
š¬ Minimal Reproduction
https://stackblitz.com/edit/angular-ivy-parameter-order-bug?file=src%2Fapp%2Fapp.component.htmlš„ Exception or Error
Error: cannot read property 'bla' of undefined
š Your Environment
Angular Version:
10.2.3
Anything else relevant?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Why does the order of parameters matter? - python
The only way to know what value you meant to pass for each parameter is by using the correct order. For python, you...
Read more >Name of Property: The Order Of Parameters in a Function ...
As the title says: I have a function where the order of parameters does not matter. An example would be ADD : ADD(1,2)...
Read more >Does order of parameters matter? - C++ Forum
Nope, order does not matter. No there is no set rule about the order of parameters, however you should strive to keep the...
Read more >Why does the order of the arguments matter? - Python FAQ
It doesn't matter what order they are given in the parameter so long as the arguments in the call expression match the correct...
Read more >Change the order of a paginated report parameter
Change the order of paginated report parameters when you have a dependent parameter that is listed before the parameter it is dependent on....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This isnāt actually the case. I think thereās an issue with your stackblitz examples. The
a
setter is defined as:this.text
includes two values here, both of which are values fora
(unlike what theB:
label implies). Really itās showing the value before and after the binding is evaluated, which will predictably beundefined
and then the singular incoming value.In actuality, in View Engine bindings were set in the order of
@Input
field declaration in the directive/component being consumed. This wasnāt a chosen or specified behavior, merely an implementation detail of how the inputs were captured when iterating members of the directive class.Despite being rather arbitrary, this ordering does intuitively make a certain amount of sense. Itās stable and well-defined, and doesnāt vary from consumer to consumer. If one inputās setter consumes the value of another input, developers tend to naturally write the declaration for the dependency first, and then its consumer. A lot of the time then, this approach just āworkedā.
The Ivy design initially leaned towards following the ordering at the template usage site instead. This was favored for two reasons:
In practice, this constraint proved overly restrictive. We realized it would limit our ability to optimize templates down the road, and decided that like View Engine, Ivy would not commit to a particular import binding order. I believe the decision at the time was:
The
[a]
binding will always be evaluated/set before the[b]
binding.The template compiler may evaluate both
[a]
and[c]
beforeb
, in order to chain the binding instructions and generate a smaller template:Well, I hope nothing changed since this comment š