Commit graph

256 commits

Author SHA1 Message Date
Kristiyan Kostadinov
b9e2ccdda8 refactor(common): remove unused import (#64699)
Cleans up unused code to improve readability and maintainability.

PR Close #64699
2025-10-30 19:27:33 +00:00
Jessica Janiuk
70332b0453 fix(core): pass element removal property through in all locations (#64565)
The `requireSynchronousElementRemoval` property was not being passed in all the locations it was needed. This was preventing leave animation timing from behaving properly in some cases.

fixes: #64525

PR Close #64565
2025-10-21 18:08:34 +00:00
JoostK
2b257b3659 fix(animations): account for Element.animate exceptions (#64506)
In certain scenarios `Element.animate` fails, manifesting in an exception (Firefox)
or a null return value (Chromium). The null value is not conform WebIDL but handled
gracefully in this commit regardless.

Closes #64486

PR Close #64506
2025-10-21 16:49:42 +00:00
Jessica Janiuk
dde5badb71 fix(core): prevent animations renderer from impacting animate.leave (#63921)
This adds an optional flag to the renderer on `removeChild` called `requireSynchronousElementRemoval`, which can tell any downstream renderer that elements need to be removed synchronously. This gets passed down to the legacy animation renderer to ensure that any elements that set this flag aren't impacted by that renderers changes to timing.

fixes: #63893

PR Close #63921
2025-09-19 21:26:18 +00:00
Amila Welihinda
ec8cd3e189 refactor(animations): optimize resolveTimeExpression (#62927)
This moves a regexp expression into a const to optimize performance.

PR Close #62927
2025-08-06 15:09:18 +02:00
Jessica Janiuk
9766116cea refactor(animations): deprecate the animations package (#62795)
This deprecates the animations package in favor of using `animate.enter` and `animate.leave` with intent to remove the full package in v22.2.

DEPRECATED: @angular/animations

PR Close #62795
2025-07-29 09:50:09 +00:00
Paul Gschwendtner
3a106a35bc build: move private testing helpers outside platform-browser/testing (#61472)
These helpers are often imported by various tests throughout the
repository, but the helpers aren't exported/exposed from the public
entry-point; even though they confusingly reside in there.

This commit fixes this, and moves the helpers into
`packages/private/testing`. This is a preparation for the `ts_project`
migration where we don't want to leverage deep imports between packages.

PR Close #61472
2025-05-20 10:00:43 +00:00
arturovt
7aae854f5e refactor(animations): mark non-default new expressions as pure (#61452)
Adds `__PURE__` annotations to non-default `new` expressions to enable tree-shaking, even if they are not referenced. These variables are not dropped when Angular is imported from a module that has `sideEffects` set to `true`.

PR Close #61452
2025-05-19 08:26:56 +00:00
Andrew Kushnir
006a14da89 refactor(animations): convert scripts within packages/animations to relative imports (#60230)
This commit updates scripts within `packages/animations` to relative imports as a prep work to the upcoming infra updates.

PR Close #60230
2025-03-27 18:28:01 +00:00
arturovt
25db666a93 refactor(animations): tree-shake regular expressions (#60095)
Adds a pure annotation to regular expressions because if the animations package is indirectly referenced in the code, it would include regular expressions in the bundle, even if they're unused (since `new` is side-effectful).

PR Close #60095
2025-02-27 17:53:24 +00:00
Kristiyan Kostadinov
b76be83b4d fix(core): animation sometimes renderer not being destroyed during HMR (#59574)
These changes aim to resolve the issue that prompted #59514. The animations module is a bit tricky for HMR, because it schedules the destruction of its renderer after the currently-running animations are done. If there are no running animations, the renderer gets destroyed next time around. This is a problem, because it means that the styles can stay around for a long time.

These changes resolve the issue by:
1. Moving the cleanup of the renderer to after the destruction of the old view. This ensures that the usual clean up flow has been kicked off.
2. Flushing the animations when a component is replaced to ensure that the renderer is cleaned up in a timely manner.

PR Close #59574
2025-01-16 11:36:43 -08:00
arturovt
5884153e12 refactor(animations): drop warning functions in production (#59408)
Prior to this commit, functions that issued warnings were not wrapped with `ngDevMode` at the point
of invocation but had the `ngDevMode` check inside. This meant they acted as no-ops in production.
In this commit, we wrap them externally with `ngDevMode`, so they are entirely removed.

PR Close #59408
2025-01-09 13:15:06 -05:00
Kristiyan Kostadinov
0e23f20c41 fix(platform-browser): styles not replaced during HMR when using animations renderer (#59393)
When we replace a component during HMR, we clear it from the cache of the renderer factory, however when using animations, there's an animation-specific renderer factory that wraps the base DOM one and was preventing the cache from being cleared.

These changes rework the logic that clear the cache to go through a method so we can forward the call to the delegated factory.

PR Close #59393
2025-01-07 15:55:38 +00:00
Kristiyan Kostadinov
d010e11b73 feat(core): add event listener options to renderer (#59092)
Updates the `Renderer2.listen` signature to accept event options, as well as all adjacent types to it.

PR Close #59092
2024-12-10 13:39:47 -08:00
hawkgs
0513fbc9fc docs: set syntax highlighting of code examples MD code blocks (#59026)
Set the syntax highlighting based on the code examples' language.

PR Close #59026
2024-12-04 17:30:28 +01:00
Joey Perrott
9dbe6fc18b refactor: update license text to point to angular.dev (#57901)
Update license text to point to angular.dev instead of angular.io

PR Close #57901
2024-09-24 15:33:00 +02:00
Kristiyan Kostadinov
513a4fe05e refactor(core): replace usages of removeChild (#57203)
These changes replace most usages of `removeChild` with `remove`. The latter has the advantage of not having to look up the `parentNode` and ensure that the child being removed actually belongs to the specific parent.

The refactor should be fairly safe since all the browsers we cover support `remove`. [Something similar was done in Components](https://github.com/angular/components/pull/23592) some time ago and there haven't been any bug reports as a result.

PR Close #57203
2024-08-07 16:46:09 +00:00
Andrew Scott
024e9bf54d refactor(core): Ensure animations are flushed before running render hooks (#55564)
This commit ensures we flush animations by calling renderFactory
begin/end in cases where the ApplicationRef._tick happens in a mode that
skips straight to the render hooks.

PR Close #55564
2024-04-30 15:39:56 -07:00
Andrew Scott
bf8814c6c3 refactor(core): Omit listeners from out-of-zone scheduling when using ZoneJS (#55492) (#55525)
In Angular today, a bound listener automatically marks the view for
check. When using ZoneJS, these listeners are most often executed in the
Angular Zone as well, so synchronization (`ApplicationRef.tick`) will
eventually happen. _However_, developers can opt out of zone-patching
for events in several ways, and often do this for very frequent
listeners like `mousemove`, `resize`, and `scroll`. We do not want to
break existing expectations that these are now "safe" events to have
listeners for by automatically scheduling change detection regardless of
whether the listener executed inside or outside the Angular zone.

In contrast, in order for developers to more easily transition to zoneless,
we need to be able to ensure that components which are using `OnPush`
are, for the most part, compatible with zoneless as well. Because listeners
automatically mark the component for check, developers using `OnPush`
did not/do not need to also call `ChangeDetectorRef.markForCheck` or a
similar API. Unfortunately, this means that we need to consider the
listener callbacks as a notification to schedule a `tick` when Zoneless
is enabled. In the future, we would like to have an opt-out for this
(i.e. signal components) since it's not really how we _want_ things to work.

Also includes the fix for #54919 that got reverted only because it was
easier to revert the set of conflicting commits

PR Close #55525
2024-04-25 12:56:37 -07:00
Andrew Kushnir
e3d5607caf Revert "refactor(core): Ensure DOM removal happens when no app views need refresh (#55132)" (#55524)
This reverts commit a07ea069e5.

PR Close #55524
2024-04-24 16:35:57 -07:00
Andrew Kushnir
28905ab9ae Revert "refactor(animations): Ensure async animations applies changes when loaded in zoneless (#55132)" (#55524)
This reverts commit 9ab36cfe0a.

PR Close #55524
2024-04-24 16:35:57 -07:00
Andrew Scott
9ab36cfe0a refactor(animations): Ensure async animations applies changes when loaded in zoneless (#55132)
Async animations currently works in Zones because the render factory
promise resolve causes change detection to happen.

fixes #54919

PR Close #55132
2024-04-24 10:33:47 -07:00
Andrew Scott
a07ea069e5 refactor(core): Ensure DOM removal happens when no app views need refresh (#55132)
This change ensures that `ApplicationRef.tick` flushes animations by
calling `rendererFactory2.end`. This might not have happened before if
there were no views that needed to be refreshed.

This is also likely to fix a potential regression caused by #53718 even
in zone apps where animations don't get flushed when no views attached
to ApplicationRef are dirty.

PR Close #55132
2024-04-24 10:33:47 -07:00
Alan Agius
bcce85af72 refactor(animations): remove deprecated matchesElement from AnimationDriver (#55479)
BREAKING CHANGE: Deprecated `matchesElement` method has been removed from `AnimationDriver` as it is unused.

PR Close #55479
2024-04-23 13:06:27 -07:00
Joey Perrott
bbbe477f47 refactor: migrate animations to prettier formatting (#53977)
Migrate formatting to prettier for animations from clang-format

PR Close #53977
2024-01-19 20:08:57 +01:00
Andrew Scott
5ae85e4849 refactor(core): node removal notifies scheduler only when animations are enabled (#53857)
Node removal is immediate and does not require change detection to run
when animations are not provided. This refactor makes the animation
engine notify the scheduler rather than doing it on all node removals.

PR Close #53857
2024-01-19 10:28:24 +01:00
Matthieu Riegler
d7e7409e81 refactor(animations): drop convertToMap & copyStyles and use native functions. (#52441)
`copyStyles` was side-effectful and also returned a value : not great.

PR Close #52441
2023-12-14 12:33:24 -08:00
Matthieu Riegler
d28ce0a4cf refactor(animations): use a spread operator instead of custom copyObj (#52441)
Using the spread operator is the fastest way to shallow copy an object.

PR Close #52441
2023-12-14 12:33:24 -08:00
Matthieu Riegler
6a347d36eb refactor(animations): use a spread operator to convert an iterable to an array. (#52441)
Using the spread operator is the fastest way to convert an iterable to an array.

PR Close #52441
2023-12-14 12:33:24 -08:00
Matthieu Riegler
635c3b4fa8 refactor(animations): use existing helper methods. (#52441)
Saving a few bytes.

PR Close #52441
2023-12-14 12:33:24 -08:00
arturovt
a02a745a4a fix(animations): remove finish listener once player is destroyed (#51136)
This commit removes the `finish` listener from the Animation object once
the animation is finished, effectively resolving a memory leak. Previously,
the `finish` listener captured `this`, which prevented `this` from being garbage collected.

PR Close #51136
2023-11-02 10:29:38 -07:00
Matthieu Riegler
1c4a3677eb refactor(animations): make AnimationBuilder tree-shakable (#52097)
This commit allows also to use the `AnimationBuilder` when using `provideAnimationsAsync()`

fixes #52096

PR Close #52097
2023-10-12 18:13:22 +02:00
Matthieu Riegler
75d610d420 fix(platform-browser): set animation properties when using async animations. (#52087)
Animations properties set on the default renderer weren't set on the animation renderer once it was loaded. This commit fixes this.

PR Close #52087
2023-10-10 11:59:13 -07:00
Matthieu Riegler
5b375d106f fix(platform-browser): Fire Animations events when using async animations. (#52087)
Animations events registered against the default renderer weren't registered against the animation renderer once it was loaded. This commit fixes this.

fixes #52076

PR Close #52087
2023-10-10 11:59:13 -07:00
Matthieu Riegler
81e7f5be03 test(animations): update the integration test (#50738)
Let's have the same test app for async and eagerly loaded animations.

PR Close #50738
2023-09-29 10:49:41 -07:00
Matthieu Riegler
e753278faa feat(animations): Add the possibility of lazy loading animations code. (#50738)
`provideLazyLoadedAnimations()` returns providers which allow the lazy loading of the animation module.

Lazy loading of the animation code can shave off up to 16KB gzipped of the main bundle.

PR Close #50738
2023-09-29 10:49:39 -07:00
Jessica Janiuk
ac1afd8649 refactor: relocate animation renderer class for private exports (#51910)
this is a pre-emptive move of the animation renderer to prepare for #50738 to land safely.

PR Close #51910
2023-09-26 15:23:15 -07:00
Matthieu Riegler
0598613950 refactor(animations): deprecation of AnimationDriver.NOOP (#51843)
The `NoopAnimationDriver` as static property of `AnimationDriver` prevents it from being removed by tree shaking. This commit deprecates it and exposes the `NoopAnimationDriver` on the public API to replace its usage.

DEPRECATED:
The `AnimationDriver.NOOP` symbol is deprecated, use `NoopAnimationDriver` instead.

PR Close #51843
2023-09-22 12:15:45 -07:00
Matthieu Riegler
e5d327d049 refactor(animations): Use the Writable type when overwriting readonly properties. (#49754)
The `Writable` type is usefull when we want overwrite readonly properties and we still want to maintain code navigation/reference. It should be use instead of  type assertions.

PR Close #49754
2023-09-22 10:02:14 -07:00
Kristiyan Kostadinov
52cc7f839b build: align with internal tsconfig options (#51728)
Currently internally Angular has some customized tsconfig files, because we don't align with the tsconfig of the rest of g3. These changes enable `noImplicitReturns` and `noPropertyAccessFromIndexSignature` to align better with the internal config.

PR Close #51728
2023-09-12 11:39:42 -07:00
Matthieu Riegler
a1bad49703 refactor(animations): cleanup ahead of animation lazy loading (#51249)
There are no functional changes.

PR Close #51249
2023-08-31 18:35:48 +00:00
Joey Perrott
18be804c03 fix(animations): remove unnecessary escaping in regex expressions (#51554)
Correct various Useless regular-expression character escape issues.

PR Close #51554
2023-08-29 21:52:33 +00:00
Paul Gschwendtner
698c058e1c fix(animations): remove code duplication between entry-points (#51500)
The animations packages were duplicating a little bit of code due
to relative imports between entry-points. This caused bundlers to
inline shared functions twice in both FESM outputs.

PR Close #51500
2023-08-29 17:55:34 +00:00
Matthieu Riegler
10bab47b4f refactor(animations): remove unecessary interface (#50662)
`Animation` is provided by `lib.dom`.

PR Close #50662
2023-08-07 09:26:22 -07:00
Matthieu Riegler
a14bdfe859 fix(animations): Ensure elements are removed from the cache after leave animation. (#50929)
This commit fixes a memory leak.

`_namespaceLookup` was cleared before the call to `processLeaveNode()` which was using the lookup.
Without that lookup `clearElementCache()` wasn't called thus keeping a reference to the element.

Fixes #24197 & #50533

PR Close #50929
2023-07-11 08:28:10 -07:00
Alan Agius
29f6912e95 refactor(animations): remove redundant castings (#50860)
This commit removes unnecessary castings.

PR Close #50860
2023-06-27 06:27:15 -07:00
Alan Agius
0380564f85 fix(platform-browser): wait until animation completion before destroying renderer (#50860)
Prior to this commit, the renderer destroy method was being called before the animation complete. This is problematic when using `REMOVE_STYLES_ON_COMPONENT_DESTROY` as it causes the styles to be removed too early.

This commit, updates this destroy logic to be call the render destroy once the animations complete.

This has been reported internally in:
- http://b/271251353#comment12
- http://b/282004950#comment5

PR Close #50860
2023-06-27 06:27:15 -07:00
Andrew Kushnir
452a3e9ca0 Revert "fix(platform-browser): wait until animation completion before destroying renderer (#50677)" (#50857)
This reverts commit 2b55103e94.

PR Close #50857
2023-06-26 12:18:39 -07:00
Andrew Kushnir
ed8b088de2 Revert "refactor(animations): remove redundant castings (#50677)" (#50857)
This reverts commit d22734766b.

PR Close #50857
2023-06-26 12:18:38 -07:00
Alan Agius
d22734766b refactor(animations): remove redundant castings (#50677)
This commit removes unnecessary castings.

PR Close #50677
2023-06-26 09:02:42 -07:00