703 Commits

Author SHA1 Message Date
Paul Gschwendtner ca81661c95 fix(core): fix property_create instruction breaking binding to Zone targets
The property create instruction is currently failing to bind to Zone
targets if there is no advance call before the virtual instruction
that selects the intended element.
2023-10-12 17:29:21 +00:00
Paul Gschwendtner c8ac2b6d1e test: setup signal acceptance tests to also run with AOT compilation
This allows us to test the template pipeline TS emit (where we already
caught a bug using this), and also allows us to test the proper
recognition of e.g. `input`, `output`, `viewChild` etc- while also
testing type-checking.
2023-10-12 17:28:05 +00:00
Paul Gschwendtner 7504f24fe2 test: rework and enable outputs test to verify functionality 2023-10-12 17:27:39 +00:00
Pawel Kozlowski 63084b6502 feat(core): add runtime support for outputs in signal components
Runtime implementation is very simple - it adds the output function that
acts as an alias to the existing EventEmitter class constructor.
2023-10-12 17:27:39 +00:00
Paul Gschwendtner 0dbccabdf9 feat(compiler): support signal based content queries
Compiler portion for supporting content queries in signal components.
This is based on the preparation work, for detecting such queries. See
previous commits.
2023-10-12 17:27:39 +00:00
Pawel Kozlowski 1d2f7545c5 feat(core): reactive content queries
Runtime part of the reactive content queries.
2023-10-12 17:27:39 +00:00
Paul Gschwendtner 3e01740e43 feat(compiler): support generating queries for signal components 2023-10-12 17:27:39 +00:00
Pawel Kozlowski 968700c5f9 refactor(core): rename queryCreate to viewQueryCreate
In the end we need to distinguish between view and content query
creation and need separate names for those instructions.
2023-10-12 17:27:39 +00:00
Pawel Kozlowski c77976d9aa feat(core): reactive queries
Initial runtime implementation of the reactive view queries
(in preparation for the compiler work).
2023-10-12 17:27:39 +00:00
Pawel Kozlowski 2c754081e1 fix(core): fix stringify logic for interpolated values
Make sure that null, undefined and NaN interpolated values
are rendered consistently with the current ivy approach:
- null and undefined are rendered as empty strings;
- NaN is rendered as-is.
2023-10-12 17:27:38 +00:00
Paul Gschwendtner 1a2a6659a0 feat: support property interpolation in signal components 2023-10-12 17:27:38 +00:00
Pawel Kozlowski e94b474b96 refactor(core): fix lint issues
Fixing lint issues that I've just introduced...
2023-10-12 17:27:38 +00:00
Pawel Kozlowski 34f002db7e feat(core): introduce property interpolation and make DOM property bindings reactive
DOM bindings are wrapped into computed now so their values
are memoized. As the result expression in DOM bindings are
re-evaluated when a component is change-detected.
2023-10-12 17:27:38 +00:00
Pawel Kozlowski b263c00d36 test: add basic test for event listeners
Adding a passing test for a listener invocation
that changes signal value.
2023-10-12 17:27:20 +00:00
Pawel Kozlowski 3bd2fcd044 Revert "feat(core): propertyInterpolationCreate"
This reverts commit 2e3fe0747990647c5cfbba5429e90ed621b18e6e.

Based on the recent design discussion we are going to express property
interpolation as a computed function and reuse the propertyCreate
infrastructure.
2023-10-12 17:27:20 +00:00
Alex Rickabaugh 7feda88abb wip: support local references in signal property bindings
This commit adds support for local refs in signal property bindings, by
generating variables in the creation block. To implement this support:

* a new instruction shallowReference() is introduced, which is not tied to
  the current view context.
* variables are now generated for creation mode as well as update mode
* a new template pipeline pass (`phaseCreationVarColocation`) handles
  ordering of reference variable declaration and assignment in the creation
  block (guaranteeing references are only read after declarations).
2023-10-12 17:27:20 +00:00
Pawel Kozlowski f5edc3e9a8 feat(core): propertyInterpolationCreate
Skeleton of the propertyInterpolationCreate instruction.
2023-10-12 17:26:52 +00:00
Paul Gschwendtner 9bf377a424 build: fix lint errors 2023-10-12 17:26:52 +00:00
Pawel Kozlowski 0eced157a9 test: add failing tests for property interpolation
Adding failing tests for the property interpolation so we
keep those instructions on our radar.
2023-10-12 17:26:52 +00:00
Pawel Kozlowski 5dea0312d6 test: binding to a mix of zone and signal inputs
This commit adds a test for a case of a binding targetting
multiple inputs with the same name. Test passes for both
signal based components as well as a mix of zone and signal
based components.
2023-10-12 17:26:52 +00:00
Pawel Kozlowski 7b15e261ad test: enable passing tests after recent code changes
Enabling newly passing tests.
2023-10-12 17:26:51 +00:00
Paul Gschwendtner 24d689730d test: add test to ensure variable bindings work 2023-10-12 17:26:51 +00:00
Paul Gschwendtner 6310ccc221 WIP: prepare tests for failing scenarios discovered during collab
* Local refs needs more testing
* Basic variable read failed
* We do not have any tests for listeners? there was some restore view
  issue: https://github.com/angular/angular/commit/3acfdf4861d5eeed5b2ad42978547da929cc3567
2023-10-12 17:26:51 +00:00
Pawel Kozlowski faf5b21275 fix(core): properly bind to the same input from multiple views
Before this fix bindings to the same input from multiple LViews didn't
work properly as the binding expression was assigned to LView only on
the first create pass (instead of assigning on each durective usage pass).
2023-10-12 17:26:51 +00:00
Alex Rickabaugh 317ddb0d00 wip: allocate vars for PropertyCreateOp
This commit adds the `ConsumesVarsTrait` to `PropertyCreateOp` which causes
vars to be counted for use in the virtual instructions it might add. This
allows the DOM test to pass.
2023-10-12 17:26:51 +00:00
Pawel Kozlowski b7f33034e8 test: failing test case for non-primitive literals in a template 2023-10-12 17:26:51 +00:00
Pawel Kozlowski a79e202f33 test: add test veryfing bindings to multiple directives 2023-10-12 17:26:51 +00:00
Pawel Kozlowski 92f4d0127f test: add failing test for dom property bindings
The test is skipped as we are not propagating number of vars
based on the bindings found in a template.
2023-10-12 17:26:51 +00:00
Pawel Kozlowski 43cf37aa3e test: re-organize tests 2023-10-12 17:26:51 +00:00
JoostK 41db51bf91 test: add test to bind a signal to a signal input 2023-10-12 17:26:51 +00:00
JoostK 1ae67024cb test: allow signal component test to pass 2023-10-12 17:26:51 +00:00
Paul Gschwendtner dadd751a48 refactor: fix lint warnings 2023-10-12 17:26:50 +00:00
Paul Gschwendtner 84e0908b29 WIP: setup template pipeline acceptance tests on CI and base setup 2023-10-12 17:26:50 +00:00
Payam Valadkhan 5fba8902d8 refactor(core): add forbidOrphanRendering option to class debug info (#52061)
The flag `forbidOrphanRendering` is only set for non-standalone components, and indicates that the dev mode runtime should through error if the component is rendered without its ngModule loaded in the browser. This runtime error can help with further debugging.

PR Close #52061
2023-10-10 15:30:26 -07:00
Paul Gschwendtner df58c0b714 fix(core): disallow afterRender in reactive contexts (#52138)
Using `afterRender` schedules long-living lifecycle hooks. Scheduling
such hooks inside reactive contexts could mean that many of the
same hooks would be scheduled, quickly piling up every time a
consumed signal changes. This is likely unintended and could degrade
application performance or result in unexpected behavior.

Additionally, scheduling `afterRender` inside a `computed` is considered
a side effect. Computed expressions are expected to be pure/ i.e. free
of side effects. We can avoid this caveat by detecting the reactive
context in development.

PR Close #52138
2023-10-10 13:56:56 -07:00
Kristiyan Kostadinov d5dad3eb4c fix(core): viewport trigger deregistering callbacks multiple times (#52115)
Adds a check to the viewport cleanup function to prevent it from re-processing elements that have been fully cleaned up, because it can lead to the `IntersectionObserver` being destroyed even though there are still pending triggers. This can happen, because we have cleanup callbacks both for the block is loaded, but also when the placeholder view is destroyed.

Fixes #52113.

PR Close #52115
2023-10-10 09:51:20 -07:00
Kristiyan Kostadinov 861ce3a7c5 fix(compiler): pipes using DI not working in blocks (#52112)
Fixes that the new block syntax was generating instructions in the wrong order which meant that pipes were being declared too early. This meant that if the block is first in the template, any pipes used in it won't be able to inject things like `ChangeDetectorRef`.

These changes update the compiler and add a bunch of tests to ensure that pipes work as expected.

Fixes #52102.

PR Close #52112
2023-10-10 09:48:37 -07:00
Payam Valadkhan 9e7d243455 refactor(core): implement the runtime ɵsetClassDebugInfo for components (#51919)
A new field `debugInfo` is added to the component definition. Now the runtime  ɵsetClassDebugInfo stores the debug info for components in this new field.

PR Close #51919
2023-10-09 15:57:03 -07:00
Andrew Scott 0ec66b85e6 refactor(core): Use flag instead of counter for dirty child transplanted views (#51515)
This commit updates the tracking of dirty child views to be a flag
rather than a counter. This is a much more simple method and less likely
to get into the same 'always-wrong' situation that could happen with the
counter (if it is off by 1 once, it's off by 1 forever and you either
get infinite change detection or your view is never refreshed).

PR Close #51515
2023-10-09 14:44:01 -07:00
Kristiyan Kostadinov 7368b8aaeb fix(core): host directive validation not picking up duplicate directives on component node (#52073)
Fixes that, depending on the matching and import order, in some cases we weren't throwing the error saying that a directive matched multiple times on the same element.

Fixes #52072.

PR Close #52073
2023-10-09 12:39:19 -07:00
Andrew Kushnir 422e8582c4 refactor(core): support OnPush components in @defer blocks (#52095)
This commit adds the code to mark newly created embedded views (that represent `@defer` block states) as dirty to indicate that the view sgould be checked during the next change detection cycle.

Resolves #52094.

PR Close #52095
2023-10-09 10:55:38 -07:00
Alex Rickabaugh 8f5cbcc845 refactor: move signals code into primitives package (#51986)
This commit reorganizes the Angular code a bit, and moves signals into a
newly defined `@angular/core/primitives` location. This will be used inside
g3 to allow non-Angular targets to depend on the signals core without
incurring a dependency on the whole framework.

PR Close #51986
2023-10-06 15:12:00 -07:00
Alex Rickabaugh b91d143fe4 refactor(core): extract signals API away from the 'signals' package (#51986)
This commit refactors the signals API surface of Angular out of the
//packages/core/src/signals package. This is done in preparation of moving
the core signals package into a new 'primitives' package that's decoupled
from the public API.

PR Close #51986
2023-10-06 15:11:59 -07:00
Andrew Kushnir 486cc611a5 refactor(core): add focusin event to on hover trigger of @defer block (#52059)
This commit adds the `focusin` event to `on hover` trigger of `@defer` block to improve compatibility with screen readers.

PR Close #52059
2023-10-06 08:46:21 -07:00
Andrew Kushnir f06d97e86d test(core): await all async work to be completed before checking test results (#52064)
This change should help make currently flaky test more stable.

PR Close #52064
2023-10-06 08:33:38 -07:00
Pawel Kozlowski 05d1fac41f test(core): more tests around built-in for (#52045)
Add some more tests around list diffing (created in
a different branch while working in the list diffing).

PR Close #52045
2023-10-05 16:21:58 -07:00
Pawel Kozlowski 0fb742402e test(core): move control flow acceptance tests (#52045)
Moves each control flow test (if, switch, for) into their
corresponding file.

PR Close #52045
2023-10-05 16:21:58 -07:00
Andrew Kushnir caa8eb28d5 refactor(core): add after and minimum parameter support to @defer blocks (#52009)
This commit adds runtime code to support `after` and `minimum` parameters in the `@placeholder` and `@loading` blocks. The code uses the `TimerScheduler` service added earlier for `on timer` triggers.

PR Close #52009
2023-10-05 13:35:42 -07:00
Andrew Kushnir 706838950c refactor(core): allow nested @defer block to contain the same dependency (#51964)
Currently, if there are 2 nested @defer blocks with the same dependency, Angular throws an error at runtime to indicate that there was a duplicate component def in the registry. This commit updates the logic to only append dependencies when they didn't previously exist in the registry.

PR Close #51964
2023-10-04 09:00:23 -07:00
Paul Gschwendtner 9b9e11fcaf refactor(core): deprecate allowing full context object to be replaced in EmbeddedViewRef (#51887)
This partially reverts commit a3e17190e7
and deprecates behavior added.

The context of an embedded view ref at some point was switched from a
getter to an actual assignable property. This is something we revert
as it introduces additional complexity for our generated code
(in terms of closures capturing the `ctx`), creates technical
limitations for Angular's internals and the usage pattern is rarely
used (and can be addressed via simple assignments, `Object.assign` or
the use of a proxy if replacing the full context object is still
desirable)

DEPRECATED: Swapping out the context object for `EmbeddedViewRef`
is no longer supported. Support for this was introduced with v12.0.0, but
this pattern is rarely used. There is no replacement, but you can use
simple assignments in most cases, or `Object.assign , or alternatively
still replace the full object by using a `Proxy` (see `NgTemplateOutlet`
as an example).

Also adds a warning if the deprecated

PR Close #51887
2023-10-04 08:14:35 -07:00