1706 Commits

Author SHA1 Message Date
Paul Gschwendtner
3b9c802dee fix(ngcc): detect synthesized delegate constructors for downleveled ES2015 classes ()
Similarly to the change we landed in the `@angular/core` reflection
capabilities, we need to make sure that ngcc can detect pass-through
delegate constructors for classes using downleveled ES2015 output.

More details can be found in the preceding commit, and in the issue
outlining the problem: .

Fixes .

PR Close 
2020-08-17 10:55:40 -07:00
Paul Gschwendtner
ca07da4563 fix(core): detect DI parameters in JIT mode for downleveled ES2015 classes ()
In the Angular Package Format, we always shipped UMD bundles and previously even ES5 module output.
With V10, we removed the ES5 module output but kept the UMD ES5 output.

For this, we were able to remove our second TypeScript transpilation. Instead we started only
building ES2015 output and then downleveled it to ES5 UMD for the NPM packages. This worked
as expected but unveiled an issue in the `@angular/core` reflection capabilities.

In JIT mode, Angular determines constructor parameters (for DI) using the `ReflectionCapabilities`. The
reflection capabilities basically read runtime metadata of classes to determine the DI parameters. Such
metadata can be either stored in static class properties like `ctorParameters` or within TypeScript's `design:params`.

If Angular comes across a class that does not have any parameter metadata, it tries to detect if the
given class is actually delegating to an inherited class. It does this naively in JIT by checking if the
stringified class (function in ES5) matches a certain pattern. e.g.

```js
function MatTable() {
  var _this = _super.apply(this, arguments) || this;
```

These patterns are reluctant to changes of the class output. If a class is not recognized properly, the
DI parameters will be assumed empty and the class is **incorrectly** constructed without arguments.

This actually happened as part of v10 now. Since we downlevel ES2015 to ES5 (instead of previously
compiling sources directly to ES5), the class output changed slightly so that Angular no longer detects
it. e.g.

```js
var _this = _super.apply(this, __spread(arguments)) || this;
```

This happens because the ES2015 output will receive an auto-generated constructor if the class
defines class properties. This constructor is then already containing an explicit `super` call.

```js
export class MatTable extends CdkTable {
    constructor() {
        super(...arguments);
        this.disabled = true;
    }
}
```

If we then downlevel this file to ES5 with `--downlevelIteration`, TypeScript adjusts the `super` call so that
the spread operator is no longer used (not supported in ES5). The resulting super call is different to the
super call that would have been emitted if we would directly transpile to ES5. Ultimately, Angular no
longer detects such classes as having an delegate constructor -> and DI breaks.

We fix this by expanding the rather naive RegExp patterns used for the reflection capabilities
so that downleveled pass-through/delegate constructors are properly detected. There is a risk
of a false-positive as we cannot detect whether `__spread` is actually the TypeScript spread
helper, but given the reflection patterns already make lots of assumptions (e.g. that `super` is
actually the superclass, we should be fine making this assumption too. The false-positive would
not result in a broken app, but rather in unnecessary providers being injected (as a noop).

Fixes 

PR Close 
2020-08-17 10:55:37 -07:00
Andrew Kushnir
cb05c0102f fix(core): move generated i18n statements to the consts field of ComponentDef ()
This commit updates the code to move generated i18n statements into the `consts` field of
ComponentDef to avoid invoking `$localize` function before component initialization (to better
support runtime translations) and also avoid problems with lazy-loading when i18n defs may not
be present in a chunk where it's referenced.

Prior to this change the i18n statements were generated at the top leve:

```
var I18N_0;
if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
    var MSG_X = goog.getMsg(“…”);
    I18N_0 = MSG_X;
} else {
    I18N_0 = $localize('...');
}

defineComponent({
    // ...
    template: function App_Template(rf, ctx) {
        i0.ɵɵi18n(2, I18N_0);
    }
});
```

This commit updates the logic to generate the following code instead:

```
defineComponent({
    // ...
    consts: function() {
        var I18N_0;
        if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
            var MSG_X = goog.getMsg(“…”);
            I18N_0 = MSG_X;
        } else {
            I18N_0 = $localize('...');
        }
        return [
            I18N_0
        ];
    },
    template: function App_Template(rf, ctx) {
        i0.ɵɵi18n(2, 0);
    }
});
```

Also note that i18n template instructions now refer to the `consts` array using an index
(similar to other template instructions).

PR Close 
2020-08-17 10:13:57 -07:00
waterplea
b071495f92 fix(core): fix multiple nested views removal from ViewContainerRef ()
When removal of one view causes removal of another one from the same
ViewContainerRef it triggers an error with views length calculation. This commit
fixes this bug by removing a view from the list of available views before invoking
actual view removal (which might be recursive and relies on the length of the list
of available views).

Fixes .

PR Close 
2020-08-13 13:35:53 -07:00
crisbeto
a80f654af9 fix(core): error if CSS custom property in host binding has number in name ()
Fixes an error if a CSS custom property, used inside a host binding, has a
number in its name. The error is thrown because the styling parser only
expects characters from A to Z,dashes, underscores and a handful of other
characters.

Fixes .

PR Close 
2020-08-13 10:35:07 -07:00
JoostK
2e9fdbde9e fix(core): prevent NgModule scope being overwritten in JIT compiler ()
In JIT compiled apps, component definitions are compiled upon first
access. For a component class `A` that extends component class `B`, the
`B` component is also compiled when the `InheritDefinitionFeature` runs
during the compilation of `A` before it has finalized. A problem arises
when the compilation of `B` would flush the NgModule scoping queue,
where the NgModule declaring `A` is still pending. The scope information
would be applied to the definition of `A`, but its compilation is still
in progress so requesting the component definition would compile `A`
again from scratch. This "inner compilation" is correctly assigned the
NgModule scope, but once the "outer compilation" of `A` finishes it
would overwrite the inner compilation's definition, losing the NgModule
scope information.

In summary, flushing the NgModule scope queue could trigger a reentrant
compilation, where JIT compilation is non-reentrant. To avoid the
reentrant compilation, a compilation depth counter is introduced to
avoid flushing the NgModule scope during nested compilations.

Fixes 

PR Close 
2020-08-11 09:50:27 -07:00
crisbeto
5dc8d287aa fix(core): queries not matching string injection tokens ()
Queries weren't matching directives that provide themselves via string
injection tokens, because the assumption was that any string passed to
a query decorator refers to a template reference.

These changes make it so we match both template references and
providers while giving precedence to the template references.

Fixes .
Fixes .

PR Close 
2020-08-10 15:27:24 -07:00
Misko Hevery
250e299dc3 refactor(core): break i18n.ts into smaller files ()
This commit contains no changes to code. It only breaks `i18n.ts` file
into `i18n.ts` + `i18n_apply.ts` + `i18n_parse.ts` +
`i18n_postprocess.ts` for easier maintenance.

PR Close 
2020-08-10 15:07:42 -07:00
Misko Hevery
6d8c73a4d6 fix(core): Store the currently selected ICU in LView ()
The currently selected ICU was incorrectly being stored it `TNode`
rather than in `LView`.

Remove: `TIcuContainerNode.activeCaseIndex`
Add: `LView[TIcu.currentCaseIndex]`

PR Close 
2020-08-10 12:41:17 -07:00
Misko Hevery
702958e968 refactor(core): add debug ranges to LViewDebug with matchers ()
This change provides better typing for the `LView.debug` property which
is intended to be used by humans while debugging the application with
`ngDevMode` turned on.

In addition this chang also adds jasmine matchers for better asserting
that `LView` is in the correct state.

PR Close 
2020-08-06 16:58:11 -07:00
Misko Hevery
26be5b4994 refactor(core): extract icuSwitchCase, icuUpdateCase, removeNestedIcu ()
Extract `icuSwitchCase`, `icuUpdateCase`, `removeNestedIcu` into
separate functions to align them with the `.debug` property text.

PR Close 
2020-08-06 15:20:17 -07:00
Misko Hevery
3821dc5f6c refactor(core): add human readable debug for i18n ()
I18n code breaks up internationalization into opCodes which are then stored
in arrays. To make it easier to debug the codebase this PR adds `debug`
property to the arrays which presents the data in human readable format.

PR Close 
2020-08-06 15:20:17 -07:00
Doug Parker
a18f82b458 refactor(core): add noSideEffects() as private export ()
This is to enable the compiler to generate `noSideEffects()` calls. This is a private export, gated by `ɵ`.

PR Close 
2020-08-06 09:02:16 -07:00
Zara Cooper
87baa06cc6 revert: docs(core): correct SomeService to SomeComponent ()
This reverts commit b4449e35bfd04c5858ded17c0ce56248d680e8d4.

The example given from the previous change was for a component selector and not a provider selector.

This change fixes it.

Fixes .

PR Close 
2020-08-03 12:52:19 -07:00
Alex Rickabaugh
3a525d196b Revert "fix(compiler): mark NgModuleFactory construction as not side effectful ()" ()
This reverts commit 7f8c2225f2cba3dfcf3ec23e0fe08b7d2e3497e8.

This commit caused test failures internally, which were traced back to the
optimizer removing NgModuleFactory constructor calls when those calls caused
side-effectful registration of NgModules by their ids.

PR Close 
2020-07-30 12:19:35 -07:00
Doug Parker
7f8c2225f2 fix(compiler): mark NgModuleFactory construction as not side effectful ()
This allows Closure compiler to tree shake unused constructor calls to `NgModuleFactory`, which is otherwise considered
side-effectful. The Angular compiler generates factory objects which are exported but typically not used, as they are
only needed for compatibility with View Engine. This results in top-level constructor calls, such as:

```typescript
export const FooNgFactory = new NgModuleFactory(Foo);
```

`NgModuleFactory` has a side-effecting constructor, so this statement cannot be tree shaken, even if `FooNgFactory` is
never imported. The `NgModuleFactory` continues to reference its associated `NgModule` and prevents the module and all
its unused dependencies from being tree shaken. This effectively prevents all components from being tree shaken, making
Closure builds significantly larger than they should be.

The fix here is to wrap `NgModuleFactory` constructor with `noSideEffects(() => /* ... */)`, which tricks the Closure
compiler into assuming that the invoked function has no side effects. This allows it to tree-shake unused
`NgModuleFactory()` constructors when they aren't imported. Since the factory can be removed, the module can also be
removed (if nothing else references it), thus tree shaking unused components as expected.

PR Close 
2020-07-29 13:32:08 -07:00
Ajit Singh
af80bdb470 fix(core): Attribute decorator attributeName is mandatory ()
`Attribute` decorator has defined `attributeName` as optional but actually its
 mandatory and compiler throws an error if `attributeName` is undefined. Made
`attributeName` mandatory in the `Attribute` decorator to reflect this functionality

Fixes 

PR Close 
2020-07-28 11:17:24 -07:00
Ahn
b4449e35bf docs(core): correct SomeService to SomeComponent ()
PR Close 
2020-07-28 11:10:58 -07:00
JiaLiPassion
b142283ba2 fix(core): unify the signature between ngZone and noopZone ()
Now we have two implementations of Zone in Angular, one is NgZone, the other is NoopZone.
They should have the same signatures, includes
1. properties
2. methods

In this PR, unify the signatures of the two implementations, and remove the unnecessary cast.

PR Close 
2020-07-28 09:59:49 -07:00
Igor Minar
5d3ba8dec7 test: update ts-api-guardian's strip_export_pattern to exclude Ivy instructions ()
Previously the instructions were included in the golden files to monitor the frequency and rate of
the instruction API changes for the purpose of understanding the stability of this API (as it was
considered for becoming a public API and deployed to npm via generated code).

This experiment has confirmed that the instruction API is not stable enough to be used as public
API. We've since also came up with an alternative plan to compile libraries with the Ivy compiler
for npm deployment and this plan does not rely on making Ivy instructions public.

For these reasons, I'm removing the instructions from the golden files as it's no longer important
to track them.

The are three instructions that are still being included: `ɵɵdefineInjectable`, `ɵɵinject`, and
`ɵɵInjectableDef`.

These instructions are already generated by the VE compiler to support tree-shakable providers, and
code depending on these instructions is already deployed to npm. For this reason we need to treat
them as public api.

This change also reduces the code review overhead, because changes to public api golden files now
require multiple approvals.

PR Close 
2020-07-27 14:37:41 -07:00
Igor Minar
8f7d89436f refactor: correct @publicApi and @codeGenApi markers in various files ()
The markers were previously incorrectly assigned. I noticed the issues when reviewing
the golden files and this change corrects them.

PR Close 
2020-07-27 14:37:41 -07:00
Boaz Rymland
5e742d29d0 docs: fix typo from singular to plural spelling ()
This commit fixes the spelling of the singular form
of the word function to the plural spelling in
packages/core/src/application_init.ts

PR Close 
2020-07-22 10:12:44 -07:00
Andrew Kushnir
d72b1e44c6 refactor(core): rename synthetic host property and listener instructions ()
This commit updates synthetic host property and listener instruction names to better align with other instructions.
The `ɵɵupdateSyntheticHostBinding` instruction was renamed to `ɵɵsyntheticHostProperty` (to match the `ɵɵhostProperty`
instruction name) and `ɵɵcomponentHostSyntheticListener` was renamed to `ɵɵsyntheticHostListener` since this
instruction is generated for both Components and Directives (so 'component' is removed from the name).
This PR is a followup after PR .

PR Close 
2020-07-21 09:09:24 -07:00
Kapunahele Wong
5b31a0a294 docs: separate template syntax into multiple docs ()
This is part of a re-factor of template syntax and
structure. The first phase breaks out template syntax
into multiple documents. The second phase will be
a rewrite of each doc.

Specifically, this PR does the following:

- Breaks sections of the current template syntax document each into their own page.
- Corrects the links to and from these new pages.
- Adds template syntax subsection to the left side NAV which contains all the new pages.
- Adds the new files to pullapprove.

PR Close 
2020-07-20 11:16:44 -07:00
crisbeto
38a7021d5e fix(core): error due to integer overflow when there are too many host bindings ()
We currently use 16 bits to store information about nodes in a view.
The 16 bits give us 65536 entries in the array, but the problem is that while
the number is large, it can be reached by ~4300 directive instances with host
bindings which could realistically happen is a very large view, as seen in .
Once we hit the limit, we end up overflowing which eventually leads to a runtime error.

These changes bump to using 20 bits which gives us around 1048576 entries in
the array or 16 times more than the current amount which could still technically
be reached, but is much less likely and the user may start hitting browser limitations
by that point.

I picked the 20 bit number since it gives us enough buffer over the 16 bit one,
while not being as massive as a 24 bit or 32 bit.

I've also added a dev mode assertion so it's easier to track down if it happens
again in the future.

Fixes .

PR Close 
2020-07-17 12:58:15 -07:00
Misko Hevery
737506e79c fix(core): Allow modification of lifecycle hooks any time before bootstrap ()
Currently we read lifecycle hooks eagerly during `ɵɵdefineComponent`.
The result is that it is not possible to do any sort of meta-programing
such as mixins or adding lifecycle hooks using custom decorators since
any such code executes after `ɵɵdefineComponent` has extracted the
lifecycle hooks from the prototype. Additionally the behavior is
inconsistent between AOT and JIT mode. In JIT mode overriding lifecycle
hooks is possible because the whole `ɵɵdefineComponent` is placed in
getter which is executed lazily. This is because JIT mode must compile a
template which can be specified as `templateURL` and those we are
waiting for its resolution.

- `+` `ɵɵdefineComponent` becomes smaller as it no longer needs to copy
  lifecycle hooks from prototype to `ComponentDef`
- `-` `ɵɵNgOnChangesFeature` feature is now always included with the
  codebase as it is no longer tree shakable.

Previously we have read lifecycle hooks from prototype in the
`ɵɵdefineComponent` so that lifecycle hook access would be monomorphic.
This decision was made before we had `T*` data structures. By not
reading the lifecycle hooks we are moving the megamorhic read form
`ɵɵdefineComponent` to instructions. However, the reads happen on
`firstTemplatePass` only and are subsequently cached in the `T*` data
structures. The result is that the overall performance should be same
(or slightly better as the intermediate `ComponentDef` has been
removed.)

- [ ] Remove `ɵɵNgOnChangesFeature` from compiler. (It will no longer
      be a feature.)
- [ ] Discuss the future of `Features` as they hinder meta-programing.

Fix 

PR Close 
2020-07-15 16:22:46 -07:00
crisbeto
bf641e1b4b fix(core): incorrectly validating properties on ng-content and ng-container ()
Fixes the following issues related to how we validate properties during JIT:
- The invalid property warning was printing `null` as the node name
for `ng-content`. The problem is that when generating a template from
 `ng-content` we weren't capturing the node name.
- We weren't running property validation on `ng-container` at all.
This used to be supported on ViewEngine and seems like an oversight.

In the process of making these changes, I found and cleaned up a
few places where we were passing in `LView` unnecessarily.

PR Close 
2020-07-15 12:39:39 -07:00
Sonu Kapoor
f4fac406b9 docs(core): fixes minor typo in initNgDevMode function docs ()
PR Close 
2020-07-14 13:17:32 -07:00
Samuel
81542b3b72 docs(core): Fixed typo in Type JSdoc ()
Updated comment doc in packages/core/src/interface/type.ts

PR Close 
2020-07-13 14:30:55 -07:00
pkozlowski-opensource
bbe3543c69 refactor(core): remove duplicated WrappedValue class ()
Before this refactoring we had the WrappedValue class in
2 separate places:
- packages/core/src/change_detection/change_detection_util.ts
- packages/core/src/util/WrappedValue.ts

This commit removes the duplicate, leaving the class that has
the deprecation notice.

PR Close 
2020-07-08 16:02:16 -07:00
Judy Bogart
9206a26e1d docs: clean up api doc in core ()
Add introductions to usage examples and edit descriptions to be more complete and consistent with current API reference styles

PR Close 
2020-06-30 12:11:15 -07:00
Santosh Yadav
a177b1b7b1 docs: change definition of providedIn any ()
change in the definition of providedIn:any any instance creates a singleton instance
for each lazy loaded module and one instance for eager loaded module

PR Close 
2020-06-29 15:00:00 -07:00
crisbeto
543b679762 fix(core): error when invoking callbacks registered via ViewRef.onDestroy ()
Invoking a callback registered through `ViewRef.onDestroy` throws an error, because we weren't registering it correctly in the internal data structure. These changes also remove the `storeCleanupFn` function, because it was mostly identical to `storeCleanupWithContext` and was only used in one place.

Fixes .

PR Close 
2020-06-26 15:02:41 -07:00
crisbeto
c00f4ab2ae fix(core): don't consider inherited NG_ELEMENT_ID during DI ()
Special DI tokens like `ChangeDetectorRef` and `ElementRef` can provide a factory via `NG_ELEMENT_ID`. The problem is that we were reading it off the token as `token[NG_ELEMENT_ID]` which will go up the prototype chain if it couldn't be found on the current token, resulting in the private `ViewRef` API being exposed, because it extends `ChangeDetectorRef`.

These changes fix the issue by guarding the property access with `hasOwnProperty`.

Fixes .

PR Close 
2020-06-26 15:01:20 -07:00
Harri Lehtola
c509243af5 fix(core): determine required DOMParser feature availability () ()
Verify that HTML parsing is supported in addition to DOMParser existence.
This maybe wasn't as important before when DOMParser was used just as a
fallback on Firefox, but now that DOMParser is the default choice, we need
to be more accurate.

PR Close 
2020-06-26 14:54:09 -07:00
Harri Lehtola
d4544da804 refactor(core): split inert strategies to separate classes () ()
The `inertDocument` member is only needed when using the InertDocument
strategy. By separating the DOMParser and InertDocument strategies into
separate classes, we can easily avoid creating the inert document
unnecessarily when using DOMParser.

PR Close 
2020-06-26 14:54:09 -07:00
Harri Lehtola
b950d4675f fix(core): do not trigger CSP alert/report in Firefox and Chrome () ()
If [innerHTML] is used in a component and a Content-Security-Policy is set
that does not allow inline styles then Firefox and Chrome show the following
message:

> Content Security Policy: The page’s settings observed the loading of a
resource at self (“default-src”). A CSP report is being sent.

This message is caused because Angular is creating an inline style tag to
test for a browser bug that we use to decide what sanitization strategy to
use, which causes CSP violation errors if inline CSS is prohibited.

This test is no longer necessary, since the `DOMParser` is now safe to use
and the `style` based check is redundant.

In this fix, we default to using `DOMParser` if it is available and fall back
to `createHTMLDocument()` if needed. This is the approach used by DOMPurify
too.

The related unit tests in `html_sanitizer_spec.ts`, "should not allow
JavaScript execution when creating inert document" and "should not allow
JavaScript hidden in badly formed HTML to get through sanitization (Firefox
bug)", are left untouched to assert that the behavior hasn't changed in
those scenarios.

Fixes .

PR Close 
2020-06-26 14:54:08 -07:00
Santosh Yadav
fc5c34d1b8 feat(platform-browser): Allow sms-URLs ()
sms ulr is already supported by google/closure-library and and validations are added to check
if the body passed is safe or not you can refer bb7ea65319/closure/goog/html/safeurl.js (L440-L454) for more details

Fixes 

PR Close 
2020-06-26 11:12:32 -07:00
Andrew Kushnir
0879d2e85d refactor(core): throw more descriptive error message in case of invalid host element ()
This commit replaces an assert with more descriptive error message that is thrown in case `<ng-template>` or `<ng-container>` is used as host element for a Component.

Resolves .

PR Close 
2020-06-26 11:10:14 -07:00
Andrew Kushnir
9118f49a63 fix(core): cleanup DOM elements when root view is removed ()
Currently when bootstrapped component is being removed using `ComponentRef.destroy` or `NgModuleRef.destroy` methods, DOM nodes may be retained in the DOM tree. This commit fixes that problem by always attaching host element of the internal root view to the component's host view node, so the cleanup can happen correctly.

Resolves .

PR Close 
2020-06-25 14:34:35 -07:00
Tiep Phan
1d844b9bd8 docs(core): correct type for opts.read ()
The ContentChildren decorator has a metadata property named "read" which
can be used to read a different token from the queried elements. The
documentation incorrectly says "True to read..." when it should say
"Used to read...".

PR Close 
2020-06-18 16:04:09 -07:00
Judy Bogart
886e3ebcca docs: update api ref doc for platform browser ()
Edit descriptions, usage examples, and add links to be complete and consistent with API reference doc style

PR Close 
2020-06-11 18:59:12 -07:00
JiaLiPassion
284123c6ba fix(core): should fake a top event task when coalescing events to prevent draining microTaskQueue too early. ()
Close .

This is a known issue of zone.js,

```
(window as any)[(Zone as any).__symbol__('setTimeout')](() => {
  let log = '';
  button.addEventListener('click', () => {
    Zone.current.scheduleMicroTask('test', () => log += 'microtask;');
    log += 'click;';
  });
  button.click();
  expect(log).toEqual('click;microtask;');
  done();
});
```

Since in this case, we use native `setTimeout` which is not a ZoneTask,
so zone.js consider the button click handler as the top Task then drain the
microTaskQueue after the click at once, which is not correct(too early).

This case was an edge case and not reported by the users, until we have the
new option ngZoneEventCoalescing, since the event coalescing will happen
in native requestAnimationFrame, so it will not be a ZoneTask, and zone.js will
consider any Task happen in the change detection stage as the top task, and if
there are any microTasks(such as Promise.then) happen in the process, it may be
drained earlier than it should be, so to prevent this situation, we need to schedule
a fake event task and run the change detection check in this fake event task,
so the Task happen in the change detection stage will not be
considered as top ZoneTask.

PR Close 
2020-06-11 18:54:22 -07:00
Paul Gschwendtner
97dc85ba5e feat(core): support injection token as predicate in queries ()
Currently Angular internally already handles `InjectionToken` as
predicates for queries. This commit exposes this as public API as
developers already relied on this functionality but currently use
workarounds to satisfy the type constraints (e.g. `as any`).

We intend to make this public as it's low-effort to support, and
it's a significant key part for the use of light-weight tokens as
described in the upcoming guide: https://github.com/angular/angular/pull/36144.

In concrete, applications might use injection tokens over classes
for both optional DI and queries, because otherwise such references
cause classes to be always retained. This was also an issue in View
Engine, but now with Ivy, this pattern became worse, as factories are
directly attached to retained classes (ultimately ending up in the
production bundle, while being unused).

More details in the light-weight token guide and in: https://github.com/angular/angular-cli/issues/16866.

Closes . Related to .

PR Close 
2020-06-11 13:21:11 -07:00
ajitsinghkaler
e5b09cc49a docs: add example links to 'DoCheck' lifeycle hook docs ()
There were some examples for 'DoCheck' in the lifeCycle hooks guide. Added a link to the relevant section of the guide in the 'DoCheck()' api docs.

Fixes 

PR Close 
2020-06-11 11:09:58 -07:00
crisbeto
b2ccc34f9c perf(core): avoid pulling in jit-specific code in aot bundles ()
In  a call to `getCompilerFacade` was added to `ApplicationRef` which pulls in a bit of JIT-specific code. Since the code path that calls the function can't be hit for an AOT-compiled app, these changes add an `ngJitMode` guard which will allow for dead code elimination to drop it completely. Testing it out against a new CLI project showed a difference of ~1.2kb.

PR Close 
2020-06-09 13:34:43 -07:00
Ajit Singh
cb1373106b docs: wrong links in lifecycle hooks api documentaion ()
lifecycle hooks api detailed documentation contained links which were pointing to onChanges hook only which is removed, made each hook point towards its deafult page link

PR Close 
2020-06-09 11:16:43 -07:00
AleksanderBodurri
f6ee911cbb docs(core): fix path referenced in comments of both compiler facade interface files ()
Previously the comments for these files referenced a path to "packages/core/src/render3/jit/compiler_facade_interface.ts" that does not exist in the current codebase.

This PR corrects the path in these comments.

PR Close 
2020-06-09 08:28:26 -07:00
Andrew Scott
779344012a refactor(core): assert TNode is not a container when setting attribute on element ()
This PR provides a more helpful error than the one currently present:
`el.setAttribute is not a function`. It is not valid to have directives with host bindings
on `ng-template` or `ng-container` nodes. VE would silently ignore this, while Ivy
attempts to set the attribute and throws an error because these are comment nodes
and do not have `setAttribute` functionality.

It is better to throw a helpful error than to silently ignore this because
putting a directive with host binding on an `ng-template` or `ng-container` is most often a mistake.
Developers should be made aware that the host binding will have no effect in these cases.

Note that an error is already thrown in Ivy, as mentioned above, so this
is not a breaking change and can be merged to both master and patch.

Resolves 

PR Close 
2020-06-08 11:21:05 -07:00
crisbeto
ab3f4c9fe1 fix(core): infinite loop if injectable using inheritance has a custom decorator ()
If we detect that an injectable class is inheriting from another injectable, we generate code that looks something like this:

```
const baseFactory = ɵɵgetInheritedFactory(Child);

@Injectable()
class Parent {}

@Injectable()
class Child extends Parent {
  static ɵfac = (t) => baseFactory(t || Child)
}
```

This usually works fine, because the `ɵɵgetInheritedFactory` resolves to the factory of `Parent`, but the logic can break down if the `Child` class has a custom decorator. Custom decorators can return a new class that extends the original once, which means that the `ɵɵgetInheritedFactory` call will now resolve to the factory of the `Child`, causing an infinite loop.

These changes fix the issue by changing the inherited factory resolution logic so that it walks up the prototype chain class-by-class, while skipping classes that have the same factory as the class that was passed in.

Fixes .

PR Close 
2020-06-03 13:16:25 -07:00