pipeBinding variable offsets in template pipeline (#51961)
This is a deceptively simple fix for a deep issue. Consider the following template: ``` <button [title]="myTitle" [id]="(auth().identity() | async)" [tabindex]="1"> ``` `TemplateDefinitionBuilder` allocates the following variable (binding) slots: v[0] = [title] binding v[1] = [id] binding v[2] = [tabindex] binding v[3] = pipe binding v[4] = pipe binding As you can see, all three top-level property bindings were assigned variable indices. Then, variables for nested expressions were assigned. Before this change, Template Pipeline would choose the following order: v[0] = [title] binding v[1] = [id] binding v[2] = pipe binding v[3] = pipe binding v[4] = [tabindex] binding With this order, nested expressions have their variables counted and assigned before subsequent top-level property bindings. This results in different variable indices for `pipeBinding` expressions that are not inside the final property binding. However, this is not just different -- it's actually incorrect! Consider a case like the following: ``` <button [p1]="c ? (a | pipe) : 3" [p2]="b | pipe"> ``` These pipe bindings are executed *conditionally*. This means that, because we don't count and assign all the "fixed" variable slots first, i.e. those belonging to the property bindings, their indices might end up incorrect, depending on whether or not a pipeBinding happened as part of the update block. With this change, we count all variables on top-level ops first, and then descend into all expressions. PR Close #51961
Angular - The modern web developer's platform
Angular is a development platform for building mobile and desktop web applications
using TypeScript/JavaScript and other languages.
Contributing Guidelines
·
Submit an Issue
·
Blog
Documentation
Get started with Angular, learn the fundamentals and explore advanced topics on our documentation website.
Advanced
Development Setup
Prerequisites
- Install Node.js which includes Node Package Manager
Setting Up a Project
Install the Angular CLI globally:
npm install -g @angular/cli
Create workspace:
ng new [PROJECT NAME]
Run the application:
cd [PROJECT NAME]
ng serve
Angular is cross-platform, fast, scalable, has incredible tooling, and is loved by millions.
Quickstart
Ecosystem
Changelog
Learn about the latest improvements.
Upgrading
Check out our upgrade guide to find out the best way to upgrade your project.
Contributing
Contributing Guidelines
Read through our contributing guidelines to learn about our submission process, coding rules, and more.
Want to Help?
Want to report a bug, contribute some code, or improve the documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues labeled as help wanted or good first issue.
Code of Conduct
Help us keep Angular open and inclusive. Please read and follow our Code of Conduct.
Community
Join the conversation and help the community.
Love Angular? Give our repo a star ⭐ ⬆️.
