angular/packages/compiler/src
Kristiyan Kostadinov 05a16b973d refactor(compiler): add support for advanced tracking expressions (#51618)
These changes build on top of #51514 to add support for advanced expressions inside the `track` parameter of `for` loop blocks. There are two different outputs that the compiler can generate:

1. If the tracking function only references the item or `$index`, the compiler generates a pure arrow function as a constant references in the `repeaterCreate` instruction.
2. If the tracking function has references to properties outside of the `for` loop block, the compiler will rewrite those references to go through `this` and generate a function declaration. The runtime will `bind` the declaration to the current component instance so that the rewritten `this` references are resolved correctly.

Advanced tracking expression come with the following limitations to ensure the best possible performance:
1. They can only reference the item, `$index` and properties directly on the component instance. This means that there'll be an error when accessing this like local template variables and references. While we could get this to work, we would have to traverse the context tree at runtime which will degrade the performance of the loop, because it's a linear time operation that is performed on each comparison. Furthermore, allowing local references would require us re-evaluate the list when any one of them has changed.
2. Pipes aren't allowed inside the tracking function.
3. Object literals and pipes used inside the tracking expression will be recreated on each invocation.

PR Close #51618
2023-09-05 14:19:18 +00:00
..
compiler_util refactor(compiler): add support for advanced tracking expressions (#51618) 2023-09-05 14:19:18 +00:00
expression_parser refactor(compiler): Prepare the template pipeline to support host bindings. (#50899) 2023-07-27 15:08:04 -07:00
i18n refactor(compiler): implement block syntax in html ast (#50953) 2023-07-13 09:32:53 -07:00
ml_parser fix(compiler): return full spans for Comment nodes (#50855) 2023-07-28 14:39:18 -07:00
output refactor(compiler): allow constants pool to track shared functions (#51618) 2023-09-05 14:19:18 +00:00
render3 refactor(compiler): add support for advanced tracking expressions (#51618) 2023-09-05 14:19:18 +00:00
schema fix(core): hardening attribute and property binding rules for <iframe> elements (#47964) 2022-11-09 00:47:56 -08:00
template/pipeline perf(core): chain template instructions (#51546) 2023-08-29 16:38:52 +00:00
template_parser refactor(compiler): introduce deferred block AST (#51050) 2023-07-17 21:05:47 +00:00
assertions.ts refactor(compiler): remove unused assertion function (#44411) 2022-01-04 15:54:09 -08:00
chars.ts refactor(compiler): share isQuote() via chars.ts (#43129) 2021-08-16 13:07:23 -07:00
compiler.ts refactor(compiler): introduce AST for outputting arrow functions (#51436) 2023-08-23 14:45:33 -07:00
compiler_facade_interface.ts refactor(compiler): introduce compiler infrastructure for input transforms (#50225) 2023-05-22 14:48:02 +00:00
config.ts fix(core): update isDevMode to rely on ngDevMode (#47475) 2022-09-23 13:58:45 -07:00
constant_pool.ts refactor(compiler): allow constants pool to track shared functions (#51618) 2023-09-05 14:19:18 +00:00
core.ts refactor(compiler): introduce compiler infrastructure for input transforms (#50225) 2023-05-22 14:48:02 +00:00
injectable_compiler_2.ts refactor(compiler-cli): only use a single type expression (#49136) 2023-04-03 19:20:00 -07:00
jit_compiler_facade.ts refactor(compiler): compute the list of dependencies for defer blocks (#51162) 2023-08-01 11:50:05 -07:00
parse_util.ts refactor: replace deprecated String.prototype.substr() (#45397) 2022-03-24 11:48:09 -07:00
resource_loader.ts refactor(compiler): ensure compatibility with noImplicitOverride (#42512) 2021-07-12 13:11:14 -07:00
selector.ts feat(compiler): allow self-closing tags on custom elements (#48535) 2023-01-04 12:07:37 -08:00
shadow_css.ts feat(compiler): scope selectors in @scope queries (#50747) 2023-07-11 08:29:53 -07:00
style_url_resolver.ts refactor(compiler): make template preparser null-safe (#44411) 2022-01-04 15:54:10 -08:00
util.ts refactor(compiler): use globalThis for global (#50063) 2023-07-14 18:32:01 +00:00
version.ts docs: fix package name in version.ts files in different packages (#41208) 2021-05-10 10:26:34 -04:00