question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

In Ivy, @Input setting order no longer matches the order of their corresponding properties in the class

See original GitHub issue

🐞 bug report

Affected Package

The issue is caused by package "@angular/core": "9.0.0-rc.5" with Ivy

Description

Before Ivy: it was possible to receive @input values in a certain order. For example: I have a following component:

@Component({
  selector: 'hello',
  template: `<h1>Hello {{name}}!</h1>`
})
export class HelloComponent  {
  public name: string = "";

  @Input() set firstName(value: string) {
    this.name += value;
  }

  @Input() set lastName(value: string) {
    this.name += value;
  }
}

In this case, thefirstName input setter used to run before the lastName input setter as their order is defined in the component class. So no matter in what order users provide values to input properties, it was possible to receive them in our desired order:

<!--displays Hello JohnDoe-->
<hello firstName="John" lastName="Doe"></hello> 

<!-- still displays Hello JohnDoe as it should-->
<hello lastName="Doe" firstName="John"></hello>

After Ivy:

I realized that input values are set as they are provided in the template, not by the order of their corresponding properties in the class. For example, using the exact same component in Ivy, we get the following result:

<!--displays Hello JohnDoe-->
<hello firstName="John" lastName="Doe"></hello> 

<!-- displays Hello DoeJohn-->
<hello lastName="Doe" firstName="John"></hello>

πŸ”¬ Minimal Reproduction

Angular 8: https://stackblitz.com/edit/angular-input-order

In Ivy: https://ivy.ng-run.com/edit/cOAOZzmer5154DINiEZT?open=app%2Fapp.component.ts

🌍 Your Environment

Angular Version:



"@angular/core": "9.0.0-rc.5" with Ivy

Anything else relevant?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

11reactions
Airbladercommented, Dec 10, 2019

I doubt that this was ever intentional, by-design behavior. This sounds like xkcd 1172 to me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration - Axon.ivy 6.7 | Designer Guide - Axon.ivy Developer
The style configuration editor allows to specify style properties for each widget or container type. Not all widget types have the same properties...
Read more >
Ivy engine in Angular: first in-depth look at compilation ...
But the order of operations appears to have changed. For example, it seems that now Angular first checks the child components and only...
Read more >
Template type checking - Angular
In the most basic type-checking mode, with the fullTemplateTypeCheck flag set to false , Angular validates only top-level expressions in a template.
Read more >
Authoring Tasks - Gradle User Manual
Gradle supports tasks that have their own properties and methods. ... a task ordering and a task dependency is that an ordering rule...
Read more >
Configuration - Spark 3.3.1 Documentation - Apache Spark
Spark properties control most application parameters and can be set by using a SparkConf object, or through Java system properties.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found