Commit graph

2214 commits

Author SHA1 Message Date
Alan Agius
9b9c818f99 perf(core): change RendererType2.styles to accept a only a flat array (#49072)
While unlikely, prior to this change it was possible to provide a nested array of styles to the render. This required the framework to handle this by doing a flatten operation. This change also renames the `flattenStyles` method as it no longer flattens the styles.

BREAKING CHANGE: `RendererType2.styles` no longer accepts a nested arrays.

Closes #48317

PR Close #49072
2023-02-17 11:11:48 -08:00
Matthieu Riegler
f12ba1c6dd refactor: remove unnecessary file (#49042)
view had a single export from a file located in the same package, no need to keep it.

PR Close #49042
2023-02-17 11:08:33 -08:00
Matthieu Riegler
07db67b4d7 refactor: restore tree shaking for a warning message (#49064)
`getInheritedInjectableDef` logs a depreciation warning that can be tree shaked in prod. Let's do it.

PR Close #49064
2023-02-16 15:55:44 -08:00
Ilyass
6b8636fff8 docs(core): typo adding missing comma (#49088)
PR Close #49088
2023-02-16 15:49:09 -08:00
Matthieu Riegler
2ceff3f0c2 refactor(core): remove IE11 only sanitization code (#48438)
As IE11 support has been drop with v13, this specific code isn't needed anymore.

PR Close #48438
2023-02-03 09:45:03 -08:00
Matthieu Riegler
fd539a298e docs: fix the documentation for BootstrapOptions (#48834)
Inline code was being rendered on aio, this commit fixes this.

PR Close #48834
2023-01-25 18:31:08 +00:00
Alex Rickabaugh
f00bf71411 fix(core): makeEnvironmentProviders should accept EnvironmentProviders (#48720)
`makeEnvironmentProviders` constructs the wrapped `EnvironmentProviders`
type, which can only be used in environment injectors (not element
injectors). It makes sense that `makeEnvironmentProviders` should be able
to accept existing `EnvironmentProviders`-wrapped providers, since it will
be providing the same guarantee, but the current types do not allow this.

This commit fixes the typings to allow nesting `EnvironmentProviders` and
adds a test to verify that it will work.

PR Close #48720
2023-01-12 13:47:59 -08:00
Matthieu Riegler
c8310a842d refactor(core): cleanup type any (#48623)
Removing every type any in core with a reference to #9100

PR Close #48623
2023-01-04 12:15:16 -08:00
Pawel Kozlowski
dacfe4372e refactor(core): move attachDebugGetter to i18n specifc code (#48549)
The attachDebugGetter function is only used in the i18n specific code
so could be moved closer to the sole usage site instead of being
exported to the entire framework code. It also lets us remove the
entire packages/core/src/render3/util/debug_utils.ts file.

PR Close #48549
2023-01-04 12:14:30 -08:00
Pawel Kozlowski
1085e5c2ce refactor(core): remove unused attachDebugObject function (#48549)
This commit removes the unused attachDebugObject function.

PR Close #48549
2023-01-04 12:14:30 -08:00
Matthieu Riegler
687ab0447b docs: fix typo on SkipSelf (#48511)
fixes #48506

PR Close #48511
2023-01-04 11:53:31 -08:00
robertIsaac
c5a84851ea docs: add NG0403.md for Bootstrapped NgModule doesn't specify which component to initialize error (#48483)
- update `errors.ts` to annotate the error NG0403, so that the runtime can add a link to that guide when an error is thrown
- update `application_ref_spec.ts` to include the new link of the error
- update `errors.md` as a result of running `yarn bazel test packages/core/test`

Fixes #47985

PR Close #48483
2023-01-04 09:59:24 -08:00
Andrew Scott
ff84c73603 docs(core): Document invalid multi token (#48267)
Add error page for invalid multi token runtime error

PR Close #48267
2022-12-13 14:05:59 -08:00
Kristiyan Kostadinov
5f9c7ceb90 fix(core): unable to inject ChangeDetectorRef inside host directives (#48355)
When injecting the `ChangeDetectorRef` into a node that matches a component, we create a new ref using the component's LView. This breaks down for host directives, because they run before the component's LView has been created.

These changes resolve the issue by creating the LView before creating the node injector for the directives.

Fixes #48249.

PR Close #48355
2022-12-07 09:06:46 -08:00
Alan Agius
eae182da84 refactor(core): simplify array flatten logic (#48358)
We can now use modern Javascript to get the same result.

PR Close #48358
2022-12-06 12:48:41 -08:00
Alan Agius
8189b64d7d refactor(core): remove old AJD workaround for G3 (#48363)
This workaround does not seem to be needed any longer.

PR Close #48363
2022-12-06 09:14:23 -08:00
Alan Agius
cf51690341 refactor(core): remove several private utils and APIs (#48357)
These APIs are no longer used.

PR Close #48357
2022-12-05 14:35:08 -08:00
Matthieu Riegler
38421578a2 feat(core): Make the isStandalone() function available in public API (#48114)
This commit updates an internal `isStandalone` function and exposes it as a public API,
so that it can be used in applications code.

fixes #47919

PR Close #48114
2022-12-01 13:21:21 -08:00
Pawel Kozlowski
da7318e2fa refactor(core): remove debug data structures (#48281)
This commit removes several debug data structures from
the framework runtime. The data structures in question
were introduced in the framework in the past with the
idea of having debugging aid in the form of the human-redable
data structures. It turned out that in practice those
data structures were not used (most of the fwk developers
didn't even know about their existence!), yet we kept
paying the price of maintaining those duplicated (prod
and debug) version of the data structures.

PR Close #48281
2022-11-30 09:27:59 -08:00
Alan Agius
7368ee1e5c refactor(core): remove unused private APIs (#48234)
Remove private code which is not used by the Framework.

PR Close #48234
2022-11-28 09:11:25 -08:00
Derek Cormier
431c562815 build(bazel): add bazel targets for aio doc generation
This is an incremental step to produce dgeni output with bazel. The
generated outputs are not yet used by other targets.
2022-11-22 13:51:16 -07:00
Bjarki
414b1b2d5f docs: extract XSS security doc URL into a constant (#48082)
We plan to change the link in google3 to point to google3-specific
documentation. Replacing a single constant will make for a smaller and
more maintainable patch.

PR Close #48082
2022-11-17 13:21:16 -08:00
Pawel Kozlowski
1e561f9d86 refactor(core): remove usage of the useCapture arg to the listener instruction (#48046)
The useCapture argument of the listener instruction was only
meaningful in the Renderer3 case. Since the Renderer3 code was
removed this argument has no use. Note that we can perform
additional cleanup and remove the useCapture argument from the
listener instruction (this would require change to the instruction
signature, though).

PR Close #48046
2022-11-17 09:34:30 -08:00
Pawel Kozlowski
89f044375f refactor(core): remove Renderer3-related cleanup code paths (#48046)
Renderer3 had to store reference to the listener function in order to
properly cleanup event listeners. Since the Renderer3 abstraction was
removed the corresponding code path is no longer needed (Renderer2
returns a cleanup function that can be called directly).

PR Close #48046
2022-11-17 09:34:30 -08:00
Jeremy Elbourn
fc4714113c docs: add host directives guide (#48057)
PR Close #48057
2022-11-15 20:36:59 +00:00
Andrew Kushnir
ec8b52af69 docs(core): add an error details page for unsafe <iframe> bindings (#48027)
PR Close #48027
2022-11-11 11:28:35 -08:00
Andrew Kushnir
2d8d562604 fix(core): hardening attribute and property binding rules for <iframe> elements (#47964)
This commit updates the logic related to the attribute and property binding rules for <iframe> elements. There is a set of <iframe> attributes that may affect the behavior of an iframe and this change enforces that these attributes are only applied as static attributes, making sure that they are taken into account while creating an <iframe>.

If Angular detects that some of the security-sensitive attributes are applied as an attribute or property binding, it throws an error message, which contains the name of an attribute that is causing the problem and the name of a Component where an iframe is located.

BREAKING CHANGE:

Existing iframe usages may have security-sensitive attributes applied as an attribute or property binding in a template or via host bindings in a directive. Such usages would require an update to ensure compliance with the new stricter rules around iframe bindings.

PR Close #47964
2022-11-09 00:47:56 -08:00
Dylan Hunn
8e6ec72beb fix(forms): Runtime error pages must begin with leading zero (#47991)
I recently checked in a new error guide. The corresponding page must have a leading zero because it is a runtime error. Otherwise links to this error guide will be invalid.

PR Close #47991
2022-11-08 10:35:09 -08:00
Kristiyan Kostadinov
917816f672 refactor(core): remove duplicate createRenderer call (#47981)
Fixes that we were calling `createRenderer` even though we had one already. This likely wasn't a performance issue since the renderer factory caches the renderer, but it's still better to reuse it to avoid confusion in the future.

Fixes #47980.

PR Close #47981
2022-11-07 12:33:23 -08:00
Andrew Kushnir
13b863a1bf Revert "fix(core): hardening rules related to the attribute order on iframe elements (#47935)" (#47959)
This reverts commit 2d08965b1a.

The reason for revert is that we've identified some issues with implementation. The issues will get addressed soon and the fix would be re-submitted.

PR Close #47959
2022-11-03 11:20:32 -07:00
Andrew Kushnir
2d08965b1a fix(core): hardening rules related to the attribute order on iframe elements (#47935)
This commit updates the logic related to the attribute order on iframes and makes the rules more strict. There is a set of iframe attributes that may affect the behavior of an iframe, this change enforces that these attributes are applied before an `src` or `srcdoc` attributes are applied to an iframe, so that they are taken into account.

If Angular detects that some of the attributes are set after the `src` or `srcdoc`, it throws an error message, which contains the name of ann attribute that is causing the problem and the name of a Component where an iframe is located. In most cases, it should be enough to change the order of attributes in a template to move the `src` or `srcdoc` ones to the very end.

BREAKING CHANGE:

Existing iframe usages may have `src` or `srcdoc` preceding other attributes. Such usages may need to be updated to ensure compliance with the new stricter rules around iframe bindings.

PR Close #47935
2022-11-02 09:07:31 -07:00
Pawel Kozlowski
2d085dc037 fix(core): allow readonly arrays for standalone imports (#47851)
Standalone components should support readonly arrays in the
`@Component.imports`.

Fixes #47643

PR Close #47851
2022-10-27 09:29:24 +02:00
Andrew Kushnir
0d65e1de2c docs: declare Standalone APIs as stable (#47754)
In v14, we've introduced core concepts to allow Components, Directives and Pipes to configure their dependencies
 without the need to use NgModules and without the need to be declared in an NgModule. The concepts and initial
set of APIs were marked as "developer preview" to allow developers to use these APIs and share the feedback.

Since v14, we've been reviewing the entire API surface of the framework and either updating existing APIs to support standalone or creating new APIs that allowed to use Router, HttpClient and other abstractions without NgMod
ules.

Based on the mentioned work to review and stabilize APIs and also based on the positive feedback from the commun
ity, we are happy to announce that the Standalone APIs are promoted to stable!

This commit updates vast majority of standalone-related APIs to drop the `@developerPreview` label, which effect
ively documents then as stable.

Two APIs that retained the `@developerPreview` annotations are:
- withRequestsMadeViaParent (from `@angular/common/http`)
- renderApplication (from `@angular/platform-server`)

We plan to collect some additional feedback for the mentioned APIs and drop the `@developerPreview` annotation b
efore the next major release.

Co-Authored-By: Alex Rickabaugh <alx@alxandria.net>
Co-Authored-By: Andrew Scott <atscott@google.com>
Co-Authored-By: Dylan Hunn <dylhunn@gmail.com>
Co-Authored-By: Jessica Janiuk <jessicajaniuk@google.com>
Co-Authored-By: JoostK <joost.koehoorn@gmail.com>
Co-Authored-By: Kristiyan Kostadinov <crisbeto@abv.bg>
Co-Authored-By: Pawel Kozlowski <pkozlowski.opensource@gmail.com>

PR Close #47754
2022-10-17 12:15:20 +02:00
Kristiyan Kostadinov
f97bebf17a fix(compiler-cli): implement more host directive validations as diagnostics (#47768)
Implements more of the runtime validations for host directives as compiler diagnostics so that they can be caught earlier. Also does some minor cleanup.

PR Close #47768
2022-10-17 12:12:22 +02:00
Alex Rickabaugh
7de1469be6 feat(core): introduce EnvironmentProviders wrapper type (#47669)
This commit introduces a new type `EnvironmentProviders` which can be used
in contexts where Angular accepted `Provider`s destined for
`EnvironmentInjector`s. This includes contexts such as `@NgModule.providers`
and `Route.providers`.

The new type is useful for preventing such providers from accidentally
ending up in `@Component.providers`. It can be used as the return type of
provider functions (such as `provideRouter`) to enforce this safety.

Because `Provider` allows `any[]` nested arrays, the compile-time safety
provided by `EnvironmentProviders` is easily circumvented. However, the
runtime shape of `EnvironmentProviders` is not compatible with component
injectors and will result in a runtime error if it leaks through (NG0207).

A new function `makeEnvironmentProviders` is used to construct this new type
from an array of providers.

The existing `importProvidersFrom` operation previously returned a very
similar type `ImportedNgModuleProviders` which had the same goal. This
machinery is switched over to use the new `EnvironmentProviders` interface
instead (in fact, `ImportedNgModuleProviders` is now just an alias to
`EnvironmentProviders`).

PR Close #47669
2022-10-07 14:03:13 -07:00
Alex Rickabaugh
c5a1b90b25 refactor(core): support EnvironmentProviders types internally (#47669)
This commit modifies `R3Injector` and other code in Angular that deals with
providers, to handle `EnvironmentProviders` objects as well as normal
`Provider` types. There is no user-visible impact to this change, but it
prepares the core of the DI system for the introduction of
`EnvironmentProviders` as a public feature.

PR Close #47669
2022-10-07 14:03:13 -07:00
Alex Rickabaugh
3133351f25 refactor(core): define shape of EnvironmentProviders interface (#47669)
This commit introduces the `EnvironmentProviders` interface, but does not
yet export it as public API.

PR Close #47669
2022-10-07 14:03:13 -07:00
Kristiyan Kostadinov
db28badfe6 feat(core): enable the new directive composition API (#47642)
Enables the new directive composition API by exposing the `hostDirectives` property on the `Directive` and `Component` decorators. Also cleans up some casts that were put in place while the feature was being developed.

Fixes #8785.

PR Close #47642
2022-10-06 18:11:45 +00:00
Alex Rickabaugh
e3cef4a784 docs(core): deprecate providedIn: NgModule and providedIn: 'any' (#47616)
This commit deprecates the above two forms of `providedIn`.

DEPRECATED:

- The ability to pass an `NgModule` to the `providedIn` option for
`@Injectable` and `InjectionToken` is now deprecated.

`providedIn: NgModule` was intended to be a tree-shakable alternative to
NgModule providers. It does not have wide usage, and in most cases is used
incorrectly, in circumstances where `providedIn: 'root'` should be
preferred. If providers should truly be scoped to a specific NgModule, use
`NgModule.providers` instead.

- The ability to set `providedIn: 'any'` for an `@Injectable` or
`InjectionToken` is now deprecated.

`providedIn: 'any'` is an option with confusing semantics and is almost
never used apart from a handful of esoteric cases internal to the framework.

PR Close #47616
2022-10-04 11:52:38 -07:00
Kristiyan Kostadinov
02f3d12a0d refactor(core): support host directives on a root component (#47620)
Adds support for host directives on the root component by calling `findHostDirectiveDefs` and passing the results to the relevant functions.

PR Close #47620
2022-10-04 11:51:29 -07:00
Kristiyan Kostadinov
07d9a27da2 refactor(core): handle ngOnChanges in host directives (#47597)
The `NgOnChanges` feature matches some legacy ViewEngine behavior where the keys in the `SimpleChanges` object are based on the *declared* names of the inputs, not the public or minified names. This is achieved by constructing the `DirectiveDef.declaredInputs` object at the same time as when `DirectiveDef.inputs` is created.

This logic breaks down for host directives, because they can re-alias the input under a different public name which won't be present in the `declaredInputs`.

These changes add some logic to patch the directive def aliases onto the `declaredInputs`. There is some validation in place to ensure that this patching doesn't overwrite any pre-existing inputs.

PR Close #47597
2022-10-03 10:07:51 -07:00
Kristiyan Kostadinov
50f8928d56 refactor(core): add host directive definitions validation (#47589)
Adds some logic to ensure that host directives are configured correctly.

PR Close #47589
2022-09-30 10:52:12 -07:00
Ciprian Sauliuc
752e2245f4 docs: add oxford commas and rephrase sentences (#47540)
PR Close #47540
2022-09-29 16:41:32 -07:00
Kristiyan Kostadinov
76a8c68cc1 refactor(core): add input and output filtering for host directives (#47536)
Adds the logic that will filter out unexposed inputs/outputs and apply the aliases that the author specified when writing the host directives.

PR Close #47536
2022-09-29 15:48:59 -07:00
Kristiyan Kostadinov
002ee3226c refactor(core): support applying directives to the root component (#47530)
Currently the code that creates a root component assumes that it's always going to deal with a single component definition which won't work with host directives. These changes rework the code so that it's able to apply multiple directives, allowing us to eventually add support for host directives.

I also tried to make the root component creation easier to follow by breaking it up into smaller functions.

PR Close #47530
2022-09-27 10:49:21 -07:00
Andrew Kushnir
120555a626 feat(core): support object-based DI flags in TestBed.inject() (#46761)
This commit applies the changes similar to the ones performed for the `inject()` function in df246bb235.

The `TestBed.inject` function is updated to use previously added object-based API for options: now the flags argument supports passing an object which configures injection flags.

DEPRECATED:

The bit field signature of `TestBed.inject()` has been deprecated, in favor of the new options object.

PR Close #46761
2022-09-27 10:09:53 -07:00
Andrew Kushnir
841c8e5138 feat(core): support object-based DI flags in Injector.get() (#46761)
This commit applies the changes similar to the ones performed for the `inject()` function in df246bb235.

The `Injector.get` function is updated to use previously added object-based API for options: now the flags argument supports passing an object which configures injection flags.

DEPRECATED:

The bit field signature of `Injector.get()` has been deprecated, in favor of the new options object.

PR Close #46761
2022-09-27 10:09:53 -07:00
JiaLiPassion
86372538ab refactor(zone.js): remove zone-async-tagging from zone.js (#47416)
1. Remove `zone-async-tagging` implementation from zone.js and move the
implementation to `@angular/core`, so `@angular/core` can import this
package more easily for better treeshaking.
2. Add `async tagging zone` implemenation into `@angular/core` package.
So we don't need to get the `AsyncStackTaggingZoneSpec` from `global`
instance, we can import the `class` directly for better treeshaking.
3. Only load this ZoneSpec when `ngDevMode` is `true`.

PR Close #47416
2022-09-23 14:44:38 -07:00
Alan Agius
aef8d0bb02 fix(core): correctly check for typeof of undefined in ngDevMode check (#47480)
Previously, this check was wrong as typeof returns a string.

PR Close #47480
2022-09-23 14:00:46 -07:00
Alan Agius
85330f3fd9 fix(core): update isDevMode to rely on ngDevMode (#47475)
This commits update `isDevMode` to rely on the `ngDevMode` which in the CLI is set by the bundler.

We also update `@angular/platform-dynamic-browser` and `@angular/compiler` to remove usage of `jitDevMode`, with this change we remove all internal usages of `isDevMode`.

PR Close #47475
2022-09-23 13:58:45 -07:00