2140 Commits

Author SHA1 Message Date
Alex Rickabaugh 791fa9aa53 Revert "fix(animations): fix stagger timing not handling params (#47208)" (#47222)
This reverts commit 05f5e8ad86.

Reason: breaks internal g3 tests

PR Close #47222
2022-08-22 14:53:20 -07:00
dario-piotrowicz ae9f1657cc fix(animations): fix stagger timing not handling params (#47208)
prior to this change the stagger timing was being built during the
ast building instead of dynamically when visiting the stagger animation,
thus it could not handle params correctly, this change makes it so that
during ast building a timing ast is built instead and that ast is used
dynammically to build animations which can handle params correctly

resolves #19786

PR Close #47208
2022-08-22 10:51:29 -07:00
Jeremy Elbourn 9b0fd078aa refactor(core): remove obsolete data: url validation (#45860)
Validation for `data:` urls is obsolete now that modern browsers ([Firefox as of v57+](https://blog.mozilla.org/security/2017/10/04/treating-data-urls-unique-origins-firefox-57)) don't treat `data:` urls as same-origin resources.

Googlers can see  internal change cl/363609175 for additional context.

PR Close #45860
2022-08-18 13:41:43 -07:00
Andrew Scott 439d77e852 fix(router): Fix route recognition behavior with some versions of rxjs (#47098) (#47112)
Some versions of rxjs cause the algorithm used in the Router to not recognize Route configs correctly.
This commit updates the algorithm to be compatible in the same way as other code locations internally.

Context:
https://github.com/angular/angular/commit/1160b8194f78141b40d1d4885ec182d033ff2659

fixes #47089

Note: This does not have a test because I was unable to identify the
version of rxjs that would cause a failure here.

PR Close #47098

PR Close #47112
2022-08-10 10:43:50 -07:00
Eduardo Speroni 5ff715c549 fix(core): check if transplanted views are attached to change detector (#46974)
Prevents change detection on views transplanted in OnPush components that have been detached from change detection.

PR Close #46974
2022-08-08 11:33:29 -07:00
Kristiyan Kostadinov 6d215d3124 refactor(core): remove unused module tracking (#47066)
We used to track all modules in a top-level constant called `autoRegisterModuleById` which was used by `getRegisteredNgModuleType`. As of #45024 the constant isn't being used anymore so we can remove it.

PR Close #47066
2022-08-08 11:32:17 -07:00
Paul Gschwendtner 4e9492cf6d build: update dev-infra packages and account for build-tooling split from ng-dev (#46976)
The dev-infra build tooling is now decoupled from `ng-dev`. This will
make it easier to update `ng-dev` without necessarily needing to upgrade
the whole build system, Bazel etc. This is useful when e.g. new release
tool features have been added and should also be ported to active LTS
branches.

PR Close #46976
2022-08-02 09:37:38 -07:00
Andrew Scott 6307f3586e refactor(router): Remove unused ANALYZE_FOR_ENTRY_COMPONENTS (#46942)
`entryComponents` is a feature that is not used or necessary in Angular
anymore.

PR Close #46942
2022-08-01 11:18:10 -07:00
Asaf M cbfd91b0f2 docs: fixed typos (#47008)
Used my script: https://github.com/Uziel302/websites-spell-checker/blob/master/mdnversion

PR Close #47008
2022-08-01 11:15:55 -07:00
Cédric Exbrayat 3606917732 fix(core): improve the missing control flow directive message (#46903)
Similarly to what has been done in #46846 for the extended diagnostics about missing control flow directive that was only mentioning that the `CommonModule` should be imported, this commit improves the validation done by the JiT compiler.
Now that the control flow directives are available as standalone, the message mentions that directive itself can be imported.

The message now also mentions which import should be used for the directive (as it can be tricky to figure out that `NgForOf` is the directive corresponding to `*ngFor`).

PR Close #46903
2022-07-21 08:27:32 +00:00
Andrew Scott 0cbbd6aeec refactor(router): Update Router to be providedIn: 'root' (#46914)
This commit updates the Router itself to be `providedIn: 'root'` with a
factory function rather than provided in the `RouterModule`.

PR Close #46914
2022-07-20 12:21:05 -07:00
Andrew Kushnir 2e5bd88ebf refactor(core): NgModuleRef should not implement EnvironmentInjector interface (#46896)
This commit refactors the `NgModuleRef` implementation to drop functions required by the `EnvironmentInjector` interface. Previously the idea was that the `NgModuleRef` can act as an Injector to facilitate easier transition to standalone. However, from the mental model perspective, the `NgModuleRef` has the `injector` field, which is the correct injector reference and can be used is needed as an `EnvironmentInjector`.

PR Close #46896
2022-07-20 08:49:15 -07:00
Andrew Scott 9b8ea9b5ca Revert "fix(core): Fix runInContext for NgModuleRef injector (#46877)" (#46896)
This reverts commit 14081dc48d.

PR Close #46896
2022-07-20 08:49:15 -07:00
Paul Gschwendtner b431b5c6d6 test: convert source-map core tests to use async/await instead of fakeAsync (#46888)
The source map tests rely on asynchronous logic from the `source-map`
package. The tests itself are written using `fakeAsync` but this
unnecessarily complicates the interaction with the asynchronous
source-map helpers/package.

To fix this, we just make the tests use async/await as we don't intend
to test fakeAsync in this `describe` block..

PR Close #46888
2022-07-19 09:40:57 -07:00
Paul Gschwendtner 36361b0506 test: update source-map tests to account for source-map breaking change (#46888)
The source-map package now requires the
`SourceMapConsumer`/`SourceMapGenerator` classes to be instantiated
asynchronously. This commit updates our tests to account for that.

PR Close #46888
2022-07-19 09:40:57 -07:00
Andrew Scott 945a3ad359 fix(core): Fix runInContext for NgModuleRef injector (#46877)
The `runInContext` for `NgModuleRef` was previously an infinite loop.

PR Close #46877
2022-07-19 09:37:32 -07:00
dario-piotrowicz 536ded2280 fix(animations): make sure falsy values are added to _globalTimelineStyles (#46863)
style values get added to the `_globalTimelineStyles` map in order to keep
them so that they can be used across different timelines

`_globalTimelineStyles` was previously a plain object but has been
refactored to a map in #44482, as part of the update a check has been
changed from a ternary operation to an or (||), causing falsy values (as 0)
not to be added to the map anymore, apply the nullish coalescing operator (??)
instead to make sure only `undefined` and `null` are filtered out

also since this aspect was clearly not covered by tests, add a new test
to ensure that such regression doesn't happen in the future

resolves #46833

PR Close #46863
2022-07-18 21:46:13 +00:00
Paul Gschwendtner 92c9661165 test: update tests to account for karma-jasmine v5.0.0
Karma jasmine updated the `jasmine-core` dependency. Jasmine is now more
strict when:

* The done callback is invoked multiple times
* The done callback is used, while a promise is also returned
* The done callback is treated as error when e.g. a number is returned
  as first argument. This was the case with `requestAnimationFrame`.
2022-07-18 17:18:49 +00:00
Andrew Kushnir 114011d2a0 refactor(core): move the code to avoid circular dependencies
This commit refactors the code to move some functions around to avoid circular dependencies in TS imports. The newly added functions are now located in the `packages/core/src/render3/component.ts` file (instead of `packages/core/src/render3/component_ref.ts`), which is a better place for them anyway.
2022-07-15 14:58:58 -07:00
Andrew Kushnir b5153814af feat(core): add reflectComponentType function
This commit introduces a new function that allows creating a object which exposes a number of getters to retrieve information about a given component.
2022-07-15 14:58:58 -07:00
Andrew Kushnir e8e8e5f171 feat(core): add createComponent function
This commit introduces a new function that allows creating a `ComponentRef` instance based on provided Component and a set of options. The function can be used to cover a number of use-cases where the `ComponentFactory` symbol was used previously.
2022-07-15 14:58:58 -07:00
Andrew Kushnir d36a9e6bf3 refactor(core): improve an error message when ENVIRONMENT_INITIALIZER is not a multi provider (#46829)
Currently if the `ENVIRONMENT_INITIALIZER` token is not configured with `multi: true` flag, the code fails while trying to iterate over the value. This commit checks whether the `ENVIRONMENT_INITIALIZER` token value type is an array and throws a helpful error message.

PR Close #46829
2022-07-13 22:01:15 +00:00
dario-piotrowicz a4ec1096a1 refactor(animations): refactor non-animatable check to be timeline based (#46666)
move the check for non-animatable properties from the animation building
phase to the application of the animation's transition instead, in such
a way we can check it against the keyframes of the transition's timeline
in order to only provide warnings for properties which are being
animated, thus not providing any warning for non-animatable properties
being applied to elements via the style function

this change has the benfit just mentioned above but it comes with two
drawbacks:
 - the warning handling is not done in the building time so it is a bit
inconsistent with other type of validations (such as the unsupported css
properties one for example)
 - before the warning was being applied only when the animation's data
was being parsed, so it happed only once but now since it is applied
when the animation is actually being prepared to be played, it happens
each time the animation runs

resolves #46602

PR Close #46666
2022-07-12 22:36:22 +00:00
Paul Gschwendtner f6859e8da2 build: replace size-tracking test with rule from shared dev-infra (#46802)
The JS size-tracking logic has been moved into the dev-infra repository
and the rule has been updated to work better with Bazel labels. The
Starlark target is updated accordingly in this commit.

PR Close #46802
2022-07-12 19:06:30 +00:00
Andrew Kushnir a6d5fe202c feat(core): alias createNgModuleRef as createNgModule (#46789)
This commit adds the `createNgModuleRef` function alias to the public API. The alias is called `createNgModule`. The `createNgModule` name is more consistent with the rest of the API surface, where functions that return `*Ref`s don't include the `Ref` into the function name, for example: `createPlatform`, `ViewContainerRef.createComponent`, etc.

DEPRECATED:

The `createNgModuleRef` is deprecated in favor of newly added `createNgModule` one.

PR Close #46789
2022-07-12 16:11:41 +00:00
Jessica Janiuk 9ad296a55f Revert "refactor(router): Remove use of OutletInjector" (#46775)
This reverts commit e288d87742.

PR Close #46775
2022-07-11 19:13:20 +00:00
Andrew Scott bf5bee6d43 refactor(router): move around some code to eliminate circular deps (#46752)
This commit eliminates some circular dependencies by moving around
interfaces and type guards.

PR Close #46752
2022-07-11 17:59:31 +00:00
Andrew Scott 9acec3f0f7 refactor(router): Remove use of OutletInjector (#46755)
OutletInjector doesn't do anything special. Injector.create can be used instead

PR Close #46755
2022-07-08 21:56:01 +00:00
dario-piotrowicz b3c20add72 Revert "fix(animations): enable shadowElements to leave when their parent does (#46459)" (#46739)
This reverts commit b417370383.

The change applied is no longer appropriate since the use of animations
and shadow dom components is discouraged (as of #46738)

PR Close #46739
2022-07-07 13:51:30 -07:00
Pawel Kozlowski 71e606d3c3 feat(core): expose EnvironmentInjector on ApplicationRef (#46665)
There are legitimate cases where access to an EnvironmentInjector
of a bootstrapped application is required / convenient. It will be also
required for support of standalone components with Angular elements.

PR Close #46665
2022-07-07 13:05:27 -07:00
Pawel Kozlowski 96c6139c9a feat(core): add ability to set inputs on ComponentRef (#46641)
This change adds the setInput method to the ComponentRef.

Previously users had to call `componentRef.instance['inputName']`
to change inputs of a dynamically created component. This had
several problems:

*  OnPush components were not marked for check and thus very
difficult to test;
* input aliasing was not take into account - a property name
on a component could have been different from the actual input
name so setting input properties was fragile;
* manually setting input propertie would NOT trigger the
`NgOnChanges` lifecycle hook.

This modifications unifies `@Input` accross dynamically created
components and the ones referenced in templates. This also opens
doors to other changes: as an example router could use this new
method to set `@Input`s from router params.

Closes #12313
Closes #22567

PR Close #46641
2022-07-01 13:45:46 -07:00
Alex Rickabaugh fa52b6e906 feat(core): options object to supersede bit flags for inject() (#46649)
`inject()` originated as a private API and was made public to support
`InjectionToken` factories in Ivy. For code-size and performance reasons,
when we code generate `inject()` calls we use a bit field to indicate the
various injection modes (optional, skip-self, etc). However, this doesn't
make for a very nice public API.

This commit introduces an alternative object-based API for options. All 4
flags are supported as `boolean` fields on an options object, and converted
to bit flags internally. If TypeScript can prove that `optional` injection
is not requested, it can narrow the return type and remove the `null` type.

DEPRECATED:

The bit field signature of `inject()` has been deprecated, in favor of the
new options object. Correspondingly, `InjectFlags` is deprecated as well.

Fixes #46251

PR Close #46649
2022-07-01 10:21:18 -07:00
Paul Gschwendtner 8d6cb830a8 test: refactor bundle tests to not directly access CommonJS module.exports (#46642)
The test apps are bundled using their production ESM JS output using
`esbuild`. ESBuild warns about any CJS usages, like `module.exports.`

```
INFO: From Bundling Javascript packages/core/test/bundling/todo_i18n/index.ts [esbuild]:
▲ [WARNING] The CommonJS "module" variable is treated as a global variable in an ECMAScript module and may not work as expected

    bazel-out/k8-fastbuild/bin/packages/core/test/bundling/todo_i18n/index.mjs:494:0:
      494 │ module.exports = {
          ╵ ~~~~~~

  This file is considered to be an ECMAScript module because the file name ends in ".mjs".
```

Some bundling tests currently use `module.exports` to make
functions/symbols available to specs later requiring the bundle (in
order to run the bundle). Instead of using the CJS global here, the
logic can be attached consistently to `window` (there is currently a
mismatch of window vs. module.exports anyway..).

PR Close #46642
2022-07-01 10:20:51 -07:00
Pawel Kozlowski af20112222 feat(core): support the descendants option for ContentChild queries (#46638)
This change adds the support for the descendants option for ContentChild queries.

Closes #31921

PR Close #46638
2022-07-01 10:20:26 -07:00
Alex Rickabaugh a7a14df5f8 feat(core): introduce EnvironmentInjector.runInContext API (#46653)
This commit introduces a new API on `EnvironmentInjector` to run a function
in the context of the injector. This makes `inject()` available within the
body of the function to inject dependencies. We expect this functionality to
be very useful for designing ergonomic APIs both in and out of Angular, as
it should allow for a smaller and more functional API style.

Note that it's possible to implement nearly identical functionality in user
code already today:

```typescript
function runInContext<T>(injector: EnvironmentInjector, fn: () => T): T {
  const token = new InjectionToken<T>('TOKEN');
  const tmpInjector = createEnvironmentInjector([
    {provide: token, useFactory: () => fn()},
  ], injector);

  return tmpInjector.get(token);
}
```

The factory provider for `token` in this example runs in the context of the
`tmpInjector`, giving it access to `inject` that can retrieve values from
`injector` as well. This is nearly identical, although because of the child
injector `self` and `skipSelf` injection options don't function correctly.

PR Close #46653
2022-07-01 08:54:52 -07:00
Alex Rickabaugh 1434ba904d refactor(core): remove experimental Renderer3 abstraction (#46605)
This commit removes the `Renderer3` experiment which attempted to use the
real DOM API as Angular's renderer. As shown in the diff, having this
experiment around added real code complexity to Angular that could not be
removed by an optimizer.

Since we no longer feel this experiment is worth continuing, we're removing
the `Renderer3` concept and all supporting code.

PR Close #46605
2022-06-30 09:04:56 -07:00
Alex Rickabaugh af600cd2b7 refactor(core): disable automatic usage of Renderer3 (#46605)
Previously, when instantiating a component, Angular would look in the DI
hierarchy for `RendererFactory2`. Any DI tree which rolls up through an
application injector (that is, one created with `BrowserModule`) should be
able to provide this interface. If not found, Angular would switch to the
experimental `Renderer3` mechanism. This switch was designed this way,
because it allowed for the creation of experimental applications where
`RendererFactory2` was not included in the bundle at all.

In this commit, instead of automatically falling back on `Renderer3`-style
rendering, an error is raised instead if `RendererFactory2` is missing from
the DI hierarchy.

PR Close #46605
2022-06-30 09:04:56 -07:00
Alex Rickabaugh 31b396d49c test(core): migrate tests off of Renderer3 interfaces (#46605)
This commit migrates any remaining Angular tests which are using some form
of Renderer3 interfaces. Instead, they're switched to Renderer2.

PR Close #46605
2022-06-30 09:04:56 -07:00
Alex Rickabaugh 5111dbf973 refactor(core): rename the ProceduralRenderer3 interface to Renderer (#46605)
Due to the restrictions of circular dependency checking, we need a separate
internal interface for a renderer. We cannot use `Renderer2` as a type
internally as even importing it as a type incurs a dependency on its
implementation, which creates a major potential for circular dependencies.

Previously this role was served by the `Renderer3` type. As we prepare to
remove the `Renderer3` abstraction (the idea of using `document` as a
differently-shaped renderer), this commit renames `ProceduralRenderer3` to
the more generic term `Renderer`.

`RendererFactory3` is also renamed to the more generic `RendererFactory` for
consistency.

PR Close #46605
2022-06-30 09:04:55 -07:00
Pawel Kozlowski 08733b0566 test(core): remove enableRenderer3 and Renderer3 from tests (#46612)
Remove calls to enableRenderer3 in the functional unit tests.
This effectivelly cuts code paths going through the Renderer3
in the functional tests.

PR Close #46612
2022-06-29 11:18:22 -07:00
Andrew Kushnir 957744f215 refactor(core): remove no longer needed utils (#46571)
This commit removes a file that contained utils (including `TemplateFixture`) that are no longer used.

PR Close #46571
2022-06-29 10:01:35 -07:00
Andrew Kushnir eac7b588c1 test(core): update various tests to avoid referencing TemplateFixture (#46571)
This commit updates the remaining set of tests to avoid referencing `TemplateFixture` class.

PR Close #46571
2022-06-29 10:01:35 -07:00
Andrew Kushnir f5b3b56761 test(core): avoid TemplateFixture usages in LViewDebug spec (#46571)
This commit further reduces the use of an obsolete `TemplateFixture` class.

PR Close #46571
2022-06-29 10:01:35 -07:00
Andrew Kushnir 55db2271f0 test(core): avoid TemplateFixture usages in i18n spec (#46571)
This commit further reduces the use of an obsolete `TemplateFixture` class.

PR Close #46571
2022-06-29 10:01:35 -07:00
Andrew Kushnir d287d9cb33 test(core): move Pipe-related tests to the acceptance folder (#46571)
This commit refactors a  Pipe-related test to use TestBed and moves it to the `acceptance` folder.

PR Close #46571
2022-06-29 10:01:35 -07:00
Alan Agius 1289425cf8 test: update golden symbols (#46582)
This is causing CI to fail

PR Close #46582
2022-06-29 00:53:52 -07:00
Alex Rickabaugh 036dbb7e6d test(core): convert remaining bundling tests to not use renderComponent (#46559)
This commit converts the remaining bundling tests which were using
`renderComponent` to use regular bootstrapping instead.

Since `renderComponent` is synchronous and regular bootstrapping is not,
some test adjustments were necessary to wait for bootstrapping before test
assertions could run.

Additionally, debug servers were adjusted in some cases where they'd broken
(likely some time ago).

PR Close #46559
2022-06-28 21:37:45 -07:00
Alex Rickabaugh 2f91758c55 test(core): add symbol tests back to todo, hello_world bundling tests (#46559)
The deleted r3 versions of these tests had symbol tests, but their r2
equivalents did not. This commit adds symbol tests to the r2 variants.

PR Close #46559
2022-06-28 21:37:45 -07:00
Alex Rickabaugh 65820181a2 test(core): rename r2-based hello_world and todo bundling tests (#46559)
In the previous commit, the r3-based hello_world and todo tests were deleted
in favor of the r2 versions. This commit renames the r2 versions to drop the
r2 suffix.

PR Close #46559
2022-06-28 21:37:45 -07:00
Alex Rickabaugh 842a3f31e6 test(core): remove redundant renderComponent-based bundling tests (#46559)
The `hello_world` and `todo` bundling tests use the experimental
`renderComponent` function (and `Renderer3`) as a result, and have
corresponding `Renderer2` equivalents. This commit removes these tests in
favor of the `Renderer2` versions, which will be renamed in a future commit.

PR Close #46559
2022-06-28 21:37:45 -07:00