Add support for spread syntax in templates#66213
Conversation
| return this.sharedConstants.get(key)!; | ||
| } | ||
|
|
||
| getLiteralFactory(literal: o.LiteralArrayExpr | o.LiteralMapExpr): { |
There was a problem hiding this comment.
This method was unused so I deleted it and the related utilities.
9b830e5 to
016638e
Compare
|
|
||
| do { | ||
| positionals.push(this.parsePipe()); | ||
| positionals.push(this.next.isOperator('...') ? this.parseSpreadElement() : this.parsePipe()); |
There was a problem hiding this comment.
nit: should we create a custom method isSpearOperator ?
Updates the expression lexer to handle spread operators.
Updates the output AST to account for spread elements.
Updates the linker to account for spread assignments in object literals.
Updates the expression AST to have support for spread elements inside object literals.
Adds support for spread expressions inside of object literals. This can be handy when constructing maps for `class` bindings.
Adds the ability to generate spread elements in the linker.
Adds spread elements to the output AST which can be used in arrays and function calls.
Updates the expression AST to support spread elements that will be used for arrays and function calls.
Expands the template syntax to support spread elements inside arrays. This can be handy for some bindings.
016638e to
4e50304
Compare
Updates the template syntax to support rest arguments in function calls. This can be handy for functions with a variable number of arguments.
4e50304 to
355588a
Compare
|
This PR was merged into the repository. The changes were merged into the following branches:
|
|
Hey. I have found this issue when searching for the possible cause of our issues, when spread operator polyffils are added in SERVE / prod builds after the update: Is it possible this feature may be the reason? Thanks! |
|
Most likely not. If you aren't using spread operators in your templates, nothing would change. |
|
@crisbeto ok, thanks! |
|
@crisbeto it looks it is intentionally btw inside Angular esbuild "plugin": |
|
We've been polyfilling spreads for years (for performance reasons as the comment explains). If you notice so some sort of regression please file an issue with a reproduction Thank you. |
Yes, you Are absolutely right. I was mislead that this was a bug - because IT jumped out from the profilling window for the first time (and did not know about this "patch"). However, it was just coincidence and It Is ONLYbecause of the size of the data. Thank you. |

Adds support for spread/rest syntax in the following places in the template syntax:
{a: 1, ...foo}.[1, ...foo].fn(1, ...foo).For arrays and object literals the spread arguments integrate into the existing pure function infrastructure in order to avoid re-creating the object on each change detection.
Fixes #11850.
Fixes #61800.
Note: I took a couple of commits from #66206 and #66190 to avoid conflicts.