Commit Graph

1914 Commits

Author SHA1 Message Date
Misko Hevery 4495a46b99 refactor(ivy): clean up RNode retrieval; add better debug support for TNode (#31040)
PR Close #31040
2019-07-18 16:46:54 -07:00
Paul Gschwendtner 647d7bdd88 refactor: fix typescript strict flag failures in all tests (#30993)
Fixes all TypeScript failures caused by enabling the `--strict`
flag for test source files. We also want to enable the strict
options for tests as the strictness enforcement improves the
overall codehealth, unveiled common issues and additionally it
allows us to enable `strict` in the `tsconfig.json` that is picked
up by IDE's.

PR Close #30993
2019-07-18 14:21:26 -07:00
Paul Gschwendtner e061e638cb fix(ivy): semantic module check incorrectly handles nested arrays (#30993)
In View Engine, developers can pass bootstrap and entry components
as nested arrays. e.g.

```ts
export const MyOtherEntryComponents = [A, B, C]

@NgModule({
  entryComponents: [MyComp, MyOtherEntryComponents]
})
```

Currently using nested arrays for these properties causes
unexpected errors to be reported in Ivy since the semantic
NgModule checks aren't properly recursing into the nested
entry/bootstrap components. This issue has been unveiled by
enabling the strict function parameter checks.

PR Close #30993
2019-07-18 14:21:26 -07:00
Paul Gschwendtner dda781ecce fix(ivy): incorrect type definition for ɵɵdefineComponent (#30993)
Currently the `ɵɵdefineComponent` method has incorrect type
definitions the `directives` and `pipes` metadata property.

The incorrect types allow developers to pass in already instantiated
`DirectiveDef` or `ComponentDef` objects. This can cause unexpected
failures because the definition internally only expects `Type` objects
and now incorrectly tries to read the `ngDirectiveDef` or `ngComponentDef`
of existing definitions.

This issue has been unveiled by enabling the strict function parameter
types flag, where the directive definitions are determined from each array
element in the `directives` or `pipes` property (which can throw).

PR Close #30993
2019-07-18 14:21:26 -07:00
Paul Gschwendtner 2200884e55 refactor(core): ensure compatibility with typescript strict flag (#30993)
As part of FW-1265, the `@angular/core` package is made compatible
with the TypeScript `--strict` flag. This already unveiled a few bugs,
so the strictness flag seems to help with increasing the overall code health.

Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close #30993
2019-07-18 14:21:25 -07:00
Momin Khan 78e7fdd98d fix(core): allow Z variations of CSS transforms in sanitizer (#29264)
PR Close #29264
2019-07-18 14:10:38 -07:00
crisbeto 12fd06916b fix(ivy): don't match directives against attribute bindings (#31541)
Fixes Ivy matching directives against attribute bindings (e.g. `[attr.some-directive]="foo"`). Works by excluding attribute bindings from the attributes array during compilation. This has the added benefit of generating less code.

**Note:** My initial approach to implementing this was to have a different marker for attribute bindings so that they can be ignored when matching directives, however as I was implementing it I realized that the attributes in that array were only used for directive matching (as far as I could tell). I decided to drop the attribute bindings completely, because it results in less generated code.

PR Close #31541
2019-07-16 23:59:13 -04:00
crisbeto 9e83822679 fix(ivy): a couple of typos in error messages (#31571)
Fixes a couple of typos that were noticed after the initial PR (#31543) got merged in.

PR Close #31571
2019-07-16 23:58:52 -04:00
Judy Bogart 897bd18fbc docs: clarify meaning of injectable decorator (#31573)
PR Close #31573
2019-07-16 23:57:50 -04:00
Pawel Kozlowski 1ac07757dd refactor(ivy): cleanup implementation of container related instructions (#31142)
PR Close #31142
2019-07-16 14:27:52 -04:00
Andrew Kushnir 09576e9683 fix(ivy): use goog.LOCALE for Closure Compiler to define default LOCALE_ID (#31519)
Prior to this commit, default value for LOCALE_ID was not setup for Closure Compiler. In Closure Compiler, we can use `goog.LOCALE` as a default value, which will be replaced at build time with current locale.

PR Close #31519
2019-07-16 13:02:10 -04:00
crisbeto 40d785f0a0 perf(ivy): avoid generating extra parameters for host property bindings (#31550)
Currently we reuse the same instruction both for regular property bindings and property bindings on the `host`. The only difference between the two is that when it's on the host we shouldn't support inputs. We have an optional parameter called `nativeOnly` which is used to differentiate the two, however since `nativeOnly` is preceeded by another optional parameter (`sanitizer`), we have to generate two extra parameters for each host property bindings every time (e.g. `property('someProp', 'someValue', null, true)`).

These changes add a new instruction called `hostProperty` which avoids the need for the two parameters by removing `nativeOnly` which is always set and it allows us to omit `sanitizer` when it isn't being used.

These changes also remove the `nativeOnly` parameter from the `updateSyntheticHostBinding` instruction, because it's only generated for host elements which means that we can assume that its value will always be `true`.

PR Close #31550
2019-07-16 13:01:42 -04:00
nikz99 d5d8657d30 docs(core): Remove repeated example (#31555)
PR Close #31555
2019-07-16 13:00:26 -04:00
crisbeto 31ea254a07 fix(ivy): align NgModule assertions with ViewEngine (#31543)
Aligns Ivy's `NgModule` assertion messages with the ones from `ViewEngine` and adds a few that hadn't been implemented.

PR Close #31543
2019-07-15 13:58:19 -04:00
Joey Perrott 32aa18be78 build: add tsconfig-test to dependency for tsconfig in core/test/strict_types (#31471)
PR Close #31471
2019-07-12 11:38:16 -04:00
Andrew Kushnir 63e458dd3a fix(ivy): handle ICUs with placeholders in case other nested ICUs are present (#31516)
Prior to this fix, the logic to set the right placeholder format for ICUs was a bit incorrect: if there was a nested ICU in one of the root ICU cases, that led to a problem where placeholders in subsequent branches used the wrong ({$placeholder}) format instead of {PLACEHOLDER} one. This commit updates the logic to make sure we properly transform all placeholders even if nested ICUs are present.

PR Close #31516
2019-07-12 11:37:16 -04:00
Andrew Kushnir d545bbeee4 fix(ivy): handle ModuleWithProviders in R3TestBed correctly (#31415)
Prior to this commit, it was impossible to override providers defined via ModuleWithProviders using TestBed.overrideProvider API. The problem was caused by the fact that we were not taking into account these providers while calculating accumulated set of provider overrides. This commit updates the logic to extract providers from ModuleWithProviders and calculate the final set of overrides taking them into account.

PR Close #31415
2019-07-11 18:27:13 -04:00
Pawel Kozlowski 565a58e261 refactor(ivy): limit usage of global state (#31490)
PR Close #31490
2019-07-11 17:13:20 -04:00
Pawel Kozlowski 7014b67e51 refactor(ivy): don't pass LView where only TView is needed (#31490)
PR Close #31490
2019-07-11 17:13:20 -04:00
crisbeto ef44f51d58 refactor(ivy): remove instruction usage from other instructions (#31456)
Removes direct calls from one instruction into another, moves the shared logic into a separate function and removes the state getters from the shared function.

This PR resolves FW-1340.

PR Close #31456
2019-07-11 15:10:20 -04:00
crisbeto 53212db3ed refactor(ivy): remove duplicate forward ref logic (#31423)
Removes a file that duplicates the logic for resolving `forwardRef`, but isn't being used anywhere.

This PR resovles FW-1362.

PR Close #31423
2019-07-10 18:32:39 -04:00
Andrew Kushnir dee16a4355 fix(ivy): update ICU placeholders format to match Closure compiler (#31459)
Since `goog.getMsg` does not process ICUs (post-processing is required via goog.i18n.MessageFormat, https://google.github.io/closure-library/api/goog.i18n.MessageFormat.html) and placeholder format used for ICUs and regular messages inside `goog.getMsg` are different, the current implementation (that assumed the same placeholder format) needs to be updated. This commit updates placeholder format used inside ICUs from `{$placeholder}` to `{PLACEHOLDER}` to better align with Closure. ICU placeholders (that were left as is prior to this commit) are now replaced with actual values in post-processing step (inside `i18nPostprocess`).

PR Close #31459
2019-07-10 18:31:33 -04:00
Andrew Kushnir 6da1446afc fix(ivy): handle &ngsp; in i18n translations correctly (#31479)
Prior to this commit, the `` unicode symbol that represents `&ngsp` in translations was not handled correctly, i.e. was not replaced with a whitespace, thus appearing on a screen. This commit adds post-processing and replaces the mentioned symbol with a whitespace.

PR Close #31479
2019-07-10 18:29:32 -04:00
Olivier Combe 2b44be984e fix(ivy): i18n should not alloc expando slots when there is no new var (#31451)
`i18nStart` was calling `allocExpando` even if there was 0 new variable created.
This created a new expando instruction with the value 0 which was later interpreted as the start of a new expando block instead of just skipping 0 instructions.

FW-1417 #resolve

PR Close #31451
2019-07-09 14:31:10 -07:00
crisbeto 989ebcbb62 fix(ivy): inconsistent value returned by DebugNode.context (#31442)
Fixes Ivy's return value for `DebugNode.context` not being consistent for the case where there is both a structural directive and a component on a node. In `ViewEngine` the instance of the component would be returned, whereas in Ivy the context of the directive is returned.

Also adds a couple of extra test cases for how `DebugNode.context` deals with directives.

This PR resolves FW-1343.

PR Close #31442
2019-07-09 13:50:51 -07:00
crisbeto 23e0d65471 perf(ivy): add self-closing elementContainer instruction (#31444)
Adds a new `elementContainer` instruction that can be used to avoid two instruction (`elementContainerStart` and `elementContainerEnd`) for `ng-container` that has text-only content. This is particularly useful when we have `ng-container` inside i18n sections.

This PR resolves FW-1105.

PR Close #31444
2019-07-09 13:50:28 -07:00
Judy Bogart 40aaa42f44 docs: api doc cleanup (#31377)
PR Close #31377
2019-07-08 09:51:59 -07:00
George Kalpakas 35f8bfce8b fix(core): export provider interfaces that are part of the public API types (#31377)
Some of the provider interfaces that the [Provider][1] and
[StaticProvider][2] types comprise were not exported from
[@angular/core][3]. As a result, the docs for these symbols did not
appear on angular.io (even though both `Provider` and `StaticProvider`
are part of the public API. (See, also,
https://github.com/angular/angular/pull/31377#discussion_r299254408.)

This commit fixes it by exporting all necessary provider interfaces.

[1]: https://github.com/angular/angular/blob/9e34670b2/packages/core/src/di/interface/provider.ts#L365-L366
[2]: https://github.com/angular/angular/blob/9e34670b2/packages/core/src/di/interface/provider.ts#L283-L284
[3]: https://github.com/angular/angular/blob/9e34670b2/packages/core/src/di/index.ts#L23

PR Close #31377
2019-07-08 09:51:59 -07:00
crisbeto e30f494a39 refactor(ivy): remove interpolation instructions (#31395)
Makes the `interpolateX` instructions internal-only and removes their use of global state.

This PR resolves FW-1387.

PR Close #31395
2019-07-08 09:34:13 -07:00
crisbeto c0955975f4 feat(core): add automatic migration from Renderer to Renderer2 (#30936)
Adds a schematic and tslint rule that automatically migrate the consumer from `Renderer` to `Renderer2`. Supports:
* Renaming imports.
* Renaming property and method argument types.
* Casting to `Renderer`.
* Mapping all of the methods from the `Renderer` to `Renderer2`.

Note that some of the `Renderer` methods don't map cleanly between renderers. In these cases the migration adds a helper function at the bottom of the file which ensures that we generate valid code with the same return value as before. E.g. here's what the migration for `createText` looks like.

Before:
```
class SomeComponent {
  createAndAddText() {
    const node = this._renderer.createText(this._element.nativeElement, 'hello');
    node.textContent += ' world';
  }
}
```

After:
```
class SomeComponent {
  createAndAddText() {
    const node = __rendererCreateTextHelper(this._renderer, this._element.nativeElement, 'hello');
    node.textContent += ' world';
  }
}

function __rendererCreateTextHelper(renderer: any, parent: any, value: any) {
  const node = renderer.createText(value);
  if (parent) {
    renderer.appendChild(parent, node);
  }
  return node;
}
```

This PR resolves FW-1344.

PR Close #30936
2019-07-03 09:03:37 -07:00
crisbeto 02491a6ce8 refactor(ivy): move classMap interpolation logic internally (#31211)
Adds the new `classMapInterpolate1` through `classMapInterpolate8` instructions which handle interpolations inside the `class` attribute and moves the interpolation logic internally. This allows us to remove the `interpolationX` instructions in a follow-up PR.

These changes also add an error if an interpolation is encountered inside a `style` tag (e.g. `style="width: {{value}}"`). Up until now this would actually generate valid instructions, because `styleMap` goes through the same code path as `classMap` which does support interpolation. At runtime, however, `styleMap` would set invalid styles that look like `<div style="0:w;1:i;2:d;3:t;4:h;5::;7:1;">`. In `ViewEngine` interpolations inside `style` weren't supported either, however there we'd output invalid styles like `<div style="unsafe">`, even if the content was trusted.

PR Close #31211
2019-07-02 11:07:14 -07:00
JoostK eb6281f5b4 fix(ivy): include type parameter for `ngBaseDef` declaration (#31210)
When a class uses Angular decorators such as `@Input`, `@Output` and
friends without an Angular class decorator, they are compiled into a
static `ngBaseDef` field on the class, with the TypeScript declaration
of the class being altered to declare the `ngBaseDef` field to be of type
`ɵɵBaseDef`. This type however requires a generic type parameter that
corresponds with the type of the class, however the compiler did not
provide this type parameter. As a result, compiling a program where such
invalid `ngBaseDef` declarations are present will result in compilation
errors.

This commit fixes the problem by providing the generic type parameter.

Fixes #31160

PR Close #31210
2019-07-02 11:06:46 -07:00
Greg Magolan 361109d80f build: update to rules_nodejs 0.32.2 (#31325)
Brings in ts_library fixes required to get angular/angular building after 0.32.0:
typescript: exclude typescript lib declarations in node_module_library transitive_declarations
typescript: remove override of @bazel/tsetse (+1 squashed commit)

@npm//node_modules/foobar:foobar.js labels changed to @npm//:node_modules/foobar/foobar.js with fix for bazelbuild/rules_nodejs#802

also updates to rules_rass commit compatible with rules_nodejs 0.32.0

PR Close #31325
2019-07-01 14:16:42 -07:00
Alan f83dfd6f5a fix(core): handle `undefined` meta in `injectArgs` (#31333)
In the recent versions of the CLI we introduced a ctor downleveler tranformer for VE JIT builds based on the one found in tsickle, to fix the TDZ issue of `forwardRef`.

However this caused a regression as the injector is not handling that a position `paramType` can be undefined. Which is bubbled down to c6b29f4c6d/packages/core/src/di/injector_compatibility.ts (L162) and will crash c6b29f4c6d/packages/core/src/di/injector_compatibility.ts (L174-L186)

Fixes https://github.com/angular/angular-cli/issues/14888

PR Close #31333
2019-07-01 10:11:08 -07:00
Pawel Kozlowski 7ca611cd12 fix(ivy): properly handle re-projection with an empty set of nodes to re-project (#31306)
PR Close #31306
2019-06-28 12:21:37 -07:00
Andrew Kushnir c12b6fa028 fix(ivy): attach host element for views created via TestBed.createComponent (#31318)
Prior to this commit, host element of a view created via TestBed.createComponent was not attached to the component's host, making it problematic to use TestBed.createComponent API in component factories, which might be used for testing purposes only. This behavior is observed in google3 app tests and was supported by VE, so this commit aligns Ivy and VE.

PR Close #31318
2019-06-28 12:20:53 -07:00
crisbeto 81332150aa perf(ivy): chain host binding instructions (#31296)
Adds chaining to the `property`, `attribute` and `updateSyntheticHostBinding` instructions when they're used in a host binding.

This PR resolves FW-1404.

PR Close #31296
2019-06-28 09:26:20 -07:00
Olivier Combe 4f38419e33 fix(ivy): handle ICU expressions in `executeActionOnNode` (#31313)
When `walkTNodeTree` was refactored, the case of ICU expressions was forgotten (because it was handled in the `else` previously).
This PR fixes that to handle it like `ElementContainer`.

FW-1411 #resolve
PR Close #31313
2019-06-27 15:53:10 -07:00
Kristiyan Kostadinov f2360aab9d fix(ivy): incorrect namespace for root node created through ViewContainerRef (#31232)
Currently in Ivy whenever we encounter a new namespace, we set it in the global state so that all subsequent nodes are created under the same namespace. Next time a template is run the namespace will be reset back to HTML.

This breaks down if the last node that was rendered was under the SVG or MathML namespace and we create a component through `ViewContainerRef.create`, because the next template function hasn't run yet and it hasn't had the chance to update the namespace. The result is that the root node of the new component will retain the wrong namespace and may not end up rendering at all (e.g. if we're trying to show a `div` inside the SVG namespace). This issue has the potential to affect a lot of apps, because all components inserted through the router also go through `ViewContainerRef.create`.

PR Close #31232
2019-06-27 09:50:52 -07:00
George Kalpakas 3851544674 style: fix code style in several files (#31295)
These files have not been formatted properly, due to issues in the
`gulp format*` tasks. See previous commits (or #31295) for more details.

PR Close #31295
2019-06-26 13:29:29 -07:00
Alex Rickabaugh 32c760f5e7 fix(ivy): don't mask errors by calling lifecycle hooks after a crash (#31244)
The Angular runtime frequently calls into user code (for example, when
writing to a property binding). Since user code can throw errors, calls to
it are frequently wrapped in a try-finally block. In Ivy, the following
pattern is common:

```typescript
enterView();
try {
  callUserCode();
} finally {
  leaveView();
}
```

This has a significant problem, however: `leaveView` has a side effect: it
calls any pending lifecycle hooks that might've been scheduled during the
current round of change detection. Generally it's a bad idea to run
lifecycle hooks after the application has crashed. The application is in an
inconsistent state - directives may not be instantiated fully, queries may
not be resolved, bindings may not have been applied, etc. Invariants that
the app code relies upon may not hold. Further crashes or broken behavior
are likely.

Frequently, lifecycle hooks are used to make assertions about these
invariants. When these assertions fail, they will throw and "swallow" the
original error, making debugging of the problem much more difficult.

This commit modifies `leaveView` to understand whether the application is
currently crashing, via a parameter `safeToRunHooks`. This parameter is set
by modifying the above pattern:

```typescript
enterView();
let safeToRunHooks = false;
try {
  callUserCode();
  safeToRunHooks = true;
} finally {
  leaveView(..., safeToRunHooks);
}
```

If `callUserCode` crashes, then `safeToRunHooks` will never be set to `true`
and `leaveView` won't call any further user code. The original error will
then propagate back up the stack and be reported correctly. A test is added
to verify this behavior.

PR Close #31244
2019-06-26 08:01:14 -07:00
Pawel Kozlowski 4fe0e75365 refactor(ivy): rename applyXYZ to executeActionOnXYZ for clarity (#31182)
PR Close #31182
2019-06-25 17:03:52 -07:00
Pawel Kozlowski 103064a3d0 refactor(ivy): remove code duplication from applyXYZ functions (#31182)
PR Close #31182
2019-06-25 17:03:51 -07:00
Misko Hevery 29a9909232 refactor(ivy): simplify `walkTNodeTree` method for readability (#31182)
PR Close #31182
2019-06-25 17:03:51 -07:00
Umair Sarfraz ae1ac45981 docs(core): update code sample for "outputs" attribute (#31199)
The current code sample for (directive) "outputs" attribute is incorrect as it does not provide the usage of "outputs" attribute rather it provides the usage of "exportAs" attribute. This commit update the code sample by correcting the code sample with correct usage of "outputs" attribute.

Fixes https://github.com/angular/angular/issues/29523
Related work https://github.com/angular/angular/pull/30014

This commit continues from the unfinished (https://github.com/angular/angular/pull/30014#issuecomment-485419124, https://github.com/angular/angular/issues/29523#issuecomment-497333146) work.

PR Close #31199
2019-06-25 14:44:08 -07:00
Alex Rickabaugh 660800ca4e Revert "build: update to rules_nodejs 0.32.2 (#31019)" (#31267)
This reverts commit a38433f36b.

Reason: this causes failures in g3 with i18n extraction. See #31267.

PR Close #31267
2019-06-25 14:36:00 -07:00
Olivier Combe ef9cb6a034 perf(ivy): chain multiple `i18nExp` calls (#31258)
Implement function chaining for `i18nExp` to reduce the output size.

FW-1391 #resolve
PR Close #31258
2019-06-25 11:26:29 -07:00
Santosh Yadav b11a2057c6 docs(core): change from CSS Event to DOM event (#31229)
PR Close #31229
2019-06-25 10:22:34 -07:00
Greg Magolan a38433f36b build: update to rules_nodejs 0.32.2 (#31019)
Brings in ts_library fixes required to get angular/angular building after 0.32.0:
typescript: exclude typescript lib declarations in node_module_library transitive_declarations
typescript: remove override of @bazel/tsetse (+1 squashed commit)

@npm//node_modules/foobar:foobar.js labels changed to @npm//:node_modules/foobar/foobar.js with fix for bazelbuild/rules_nodejs#802

also updates to rules_rass commit compatible with rules_nodejs 0.32.0

PR Close #31019
2019-06-25 10:21:07 -07:00
crisbeto 23c017121e perf(ivy): chain multiple attribute instructions (#31152)
Similarly to what we did in #31078, these changes implement chaining for the `attribute` instruction.

This PR resolves FW-1390.

PR Close #31152
2019-06-24 12:33:49 -07:00
crisbeto fcb03abc72 fix(ivy): injecting incorrect Renderer2 into child components (#31063)
In ViewEngine injecting a Renderer2 returns a renderer that is specific to the particular component, however in Ivy we inject the renderer for the parent view instead. This causes it to set incorrect `ngcontent` attributes when creating elements through the renderer.

The issue comes from the fact that the `Renderer2` is created according to the current `LView`, but because DI happens before we've entered the `LView` of the component that's injecting the renderer, we end up with one that's one level up. We work around the issue by finding the `LView` that corresponds to the `previousOrParentTNode` inside of the parent view and associating the `Renderer2` with it.

This PR resolves FW-1382.

PR Close #31063
2019-06-24 11:33:31 -07:00
Judy Bogart a9502886b1 docs: mark interfaces as public (#30955)
PR Close #30955
2019-06-21 10:21:13 -07:00
Alex Rickabaugh bd3b0564e6 fix(ivy): sync ViewRefs between multiple ViewContainerRefs (#30985)
Previously, multiple ViewContainerRef instances (obtained by injecting
ViewContainerRef multiple times) each had private state that could be out of
sync with actual LContainer, if views were inserted/removed/queried across
the different instances. In particular each instance had its own array which
tracked ViewRefs inserted via that instance.

This commit moves the ViewRefs array onto the LContainer itself, so that it
can be shared across multiple ViewContainerRef instances. A test is added
that verifies ViewContainerRefs now provide a consistent view of the
container.

FW-1377 #resolve

PR Close #30985
2019-06-21 10:18:06 -07:00
Olivier Combe dc613b336d refactor(ivy): removing unused properties from i18n interfaces (#31171)
Fixes #31165
PR Close #31171
2019-06-20 18:46:20 -07:00
Olivier Combe 7ff628f8d5 refactor(ivy): make `bind` an internal-only function (#31131)
The function `bind` has been internalized wherever it was needed, this PR makes sure that it is no longer publicly exported.

FW-1385 #resolve
PR Close #31131
2019-06-20 17:20:56 -07:00
Paul Gschwendtner 70ad91ed8b refactor(compiler): recursive ast expression visitor not passing context (#31085)
Currently the `RecursiveAstVisitor` that is part of the template expression
parser does not _always_ properly pass through the context that can be
specified when visting a given expression. Only a handful of AST types
pass through the context while others are accidentally left out. This causes
unexpected and inconsistent behavior and basically makes the `context`
parameter not usable if the type of template expression is not known.

e.g. the template variable assignment migration currently depends on
the `RecursiveAstVisitor` but sometimes breaks if developers use
things like conditionals in their template variable assignments.

Fixes #31043

PR Close #31085
2019-06-20 11:12:16 -07:00
Kristiyan Kostadinov 029f1be204 perf(ivy): avoid unnecessary function call in i18n instruction (#31106)
Currently the `placeholders` parameter inside `i18nLocalize` is defaulted to `{}`, which means that we'll always hit the `Object.keys` call below. Since it's very likely that we won't have placeholders in the majority of strings, these changes add an extra guard so that we don't hit it on every invocation.

PR Close #31106
2019-06-19 15:51:42 -07:00
Alex Eagle db08fd2607 build: enable shard_count for some jasmine tests that have many specs (#31009)
This partitions the spects across multiple processes so they run in parallel.

PR Close #31009
2019-06-18 12:11:30 -07:00
Olivier Combe 87168acf39 refactor(ivy): move `bind` instruction into `i18nExp` (#31089)
i18nExp now uses `bind` internally rather than having the compiler generate it in order to bring it in line with other functions like `textBinding` & `property`.

FW-1384 #resolve
PR Close #31089
2019-06-18 09:49:27 -07:00
Olivier Combe 65544ac742 fix(ivy): reprojected ICU expression nodes when creating embedded views (#30979)
When using `createEmbeddedView` after the creation of an ICU expression, the nodes for the current selected case were not reprojected (only the anchor comment node was moved to the new location).
Now we reproject correctly all the child nodes of an ICU expression when an anchor comment node is projected.

FW-1372 #resolve

PR Close #30979
2019-06-18 09:48:46 -07:00
Ben Lesh 16aa6ceff8 refactor(ivy): update ɵɵtextBinding to not take index (#30792)
- Splits core functionality off into a shared internal function
- ɵɵtextBinding will no longer require an index
- Alters the compiler to stop generating an index argument for the instruction
- Updates tests
- Updates some usage of ɵɵtextBinding in i18n to use the helper function instead

PR Close #30792
2019-06-14 12:22:11 -07:00
Pawel Kozlowski e84b51d2b6 refactor(ivy): remove LView argument from locateDirectiveOrProvider (#31006)
The DI's `locateDirectiveOrProvider` function operates on `TView` / `TNode`
data structures only so doesn't need to access `LView`. This refactoring
changes the argument list so the mentioned function takes less info to do
its work.

This refactoring is also mandatory for the upcoming query matching move
to TView.

PR Close #31006
2019-06-14 10:44:59 -07:00
crisbeto 8f5c396a7c fix(ivy): don't throw when attempting to destroy a destroyed ComponentRef (#31022)
Currently in Ivy we throw when attempting to destroy a `ComponentRef` that has been destroyed, however in ViewEngine we didn't which can cause some tests to break. These changes remove the error to match ViewEngine.

These changes resolve FW-1379.

PR Close #31022
2019-06-14 10:44:30 -07:00
cexbrayat 6bc9c78d76 fix(core): temporarily remove @deprecated jsdoc tag for a TextBedStatic.get overload (#30714)
Followup to #30514 which did the same for `TestBed`, but `TestBedStatic` was necessary too.

PR Close #30714
2019-06-14 10:40:42 -07:00
Paul Gschwendtner 58be2ff884 fix(ivy): unable to bind to implicit receiver in embedded views (#30897)
To provide some context: The implicit receiver is part of the
parsed Angular template AST. Any property reads in bindings,
interpolations etc. read from a given object (usually the component
instance). In that case there is an _implicit_ receiver which can also
be specified explicitly by just using `this`.

e.g.

```html
<ng-template>{{this.myProperty}}</ng-template>
```

This works as expected in Ivy and View Engine, but breaks in case the
implicit receiver is not used for property reads. For example:

```html
<my-dir [myFn]="greetFn.bind(this)"></my-dir>
```

In that case the `this` will not be properly translated into the generated
template function code because the Ivy compiler currently always treats
the `ctx` variable as the implicit receiver. This is **not correct** and breaks
compatibility with View Engine. Rather we need to ensure that we retrieve
the root context for the standalone implicit receiver similar to how it works
for property reads (as seen in the example above with `this.myProperty`)

Note that this requires some small changes to the `expression_converter`
because we only want to generate the `eenextContent()` instruction if the
implicit receiver is _actually_ used/needed. View Engine determines if that is the case by recursively walking through the converted output AST and
checking for usages of the `o.variable('_co')` variable ([see here][ve_check]). This would work too for Ivy, but involves most likely more code duplication
since templates are isolated in different functions and it another pass
through the output AST for every template expression.

[ve_check]: 0d6c9d36a1/packages/compiler/src/view_compiler/view_compiler.ts (L206-L208)

Resolves FW-1366.

PR Close #30897
2019-06-11 14:29:42 -07:00
Alex Rickabaugh 7912db3829 fix(ivy): call factory functions with correct type for derived classes (#30855)
In a derived service class with no decorator (and therefore no factory) of
its own, the factory function of the base class will be used instead.
Previously this logic had a bug where the factory function would be called
with no arguments, which would incorrectly create an instance of the base
class.

This commit adds logic to call the base class' factory and pass the type of
the derived class, which will correctly construct an instance of the
derived class using the base class' factory. A test is also added to verify
correctness of this behavior.

PR Close #30855
2019-06-11 14:27:17 -07:00
Alex Rickabaugh 0ee09cdd7e refactor(ivy): fix type of factory functions to allow explicit types (#30855)
Factory functions written by the compiler optionally allow an explicit type
to be passed. If called with this type, an instance of the given type will
be created instead of the type for which the factory was generated. This is
used to power inheritance of Angular types, as if the constructor of a class
is inherited from its superclass, then the factory function of the
superclass must be used (it has all the DI info) to construct an instance of
the derived class.

This commit adjusts typings in a few places to allow factory functions to be
called with this extra type parameter.

PR Close #30855
2019-06-11 14:27:17 -07:00
Alex Rickabaugh b2937b16c3 fix(ivy): distinguish inherited injectable defs by token (#30855)
In older browsers such as IE10, inheritance of static properties on class
types is implemented by copying the properties. This makes hasOwnProperty
unreliable for checking if a static property is defined directly on a class
or is inherited. This causes problems when trying to read the
ngInjectableDef properties of inherited services, as in IE10 even inherited
definitions will appear to be local.

Instead, the 'token' property on ngInjectableDef can be leveraged to detect
when a definition is read which doesn't belong to the type itself.

PR Close #30855
2019-06-11 14:27:16 -07:00
Alex Rickabaugh a4b4f35533 feat(ivy): require 'token' for ngInjectableDef (#30855)
The compiler generates a 'token' field when it emits an ngInjectableDef,
but this field was not required by defineInjectable or the InjectableDef
interface, nor was it added by InjectionToken.

This commit makes 'token' required and adds it where missing.

PR Close #30855
2019-06-11 14:27:16 -07:00
Paul Gschwendtner 8c4bd61b2f test(core): add missing static flag to view_insertion test view queries (#30967)
17d87d4e10 has been created before the changes
to the `@ViewChild` and `@ContentChild` decorators. Meaning that it still uses the queries
without the `static` flag. This results in failures in `master` because #30625 has been merged.

PR Close #30967
2019-06-11 09:37:19 -07:00
Olivier Combe 4155ed439a fix(ivy): correctly set `TView.firstChild` with runtime i18n (#30920)
`TView.firstChild` was defined as the first node with index 0, but when we use runtime i18n then the instruction `i18nStart` can be the one with index 0 and the first node will be index 1 or more.
With this fix we set `TView.firstChild` when we see the first node with index 0 or later if `TView.firstChild` is still null.

FW-1367 #resolve
PR Close #30920
2019-06-11 00:09:32 +00:00
Pawel Kozlowski 2b9a4cc6a6 refactor(ivy): remove repeated getLView() calls (#30918)
PR Close #30918
2019-06-11 00:09:08 +00:00
Pawel Kozlowski 016b3f16a3 refactor(ivy): improve debug message for assertDataInRange (#30918)
PR Close #30918
2019-06-11 00:09:08 +00:00
Alex Eagle ef0b2cc74d build: convert entry_point to label (#30627)
PR Close #30627
2019-06-11 00:03:11 +00:00
Ben Lesh 17d87d4e10 test(ivy): Add acceptance tests for view insertion (#30625)
This work is being done ahead of changes to how view insertion is done in Ivy in accordance with [this design document](https://hackmd.io/Ae3W_2pOQlKouu9YNy1t6A?view).

The idea is to make sure we have acceptance tests ahead of that change.

PR Close #30625
2019-06-10 23:53:34 +00:00
Ben Lesh c0386757b1 refactor(ivy): inherently call ɵɵselect(0) (#30830)
- Refactors compiler to stop generating `ɵɵselect(0)` instructions
- Alters template execution to always call the equivalent of `ɵɵselect(0)` before running a template in update mode
- Updates tests to not check for or call `ɵɵselect(0)`.

The goal here is to reduce the size of generated templates

PR Close #30830
2019-06-07 08:48:31 -07:00
Pawel Kozlowski 11a4454ab3 perf(ivy): remove check for function type in renderStringify (#30838)
The `renderStringify` function shows up pretty high in the CPU profiling.
Turns out that this function contained unnecessary `typeof` check for
function types - the check only makes sense / is used in error messages.

The PR also alligns how ivy and view engine stringify functions used in
interpolations.

PR Close #30838
2019-06-06 13:47:41 -07:00
crisbeto 04587a33c5 fix(ivy): DebugNode.attributes not preserving attribute name casing (#30864)
In Ivy the `DebugNode.attributes` is populated directly from the DOM, but the problem is that the browser will lowercase all attribute names. These changes preserve the case by first going through the `TNode.attrs`, populating the map with the case-sensitive names and saving a reference to the lower case name. Afterwards when we're going through the attributes from the DOM, we can check whether we've mapped the attribute by its case-sensitive name already.

This PR resolves FW-1358.

PR Close #30864
2019-06-06 13:47:16 -07:00
Olivier Combe b4b7af86c2 fix(ivy): trigger directive inputs for each template creation (#30870)
A directive input that doesn't use a binding is triggered during the creation phase. But this was only executed at the first template pass, and not on subsequent ones.
Now only the creation of the update instruction is executed on the first template pass, anything else is executed every time a template is created.

FW-1361 #resolve
PR Close #30870
2019-06-06 13:46:40 -07:00
Ben Lesh 3859bcc70c refactor(ivy): remove ɵɵelementAttribute instruction (#30640)
PR Close #30640
2019-06-05 21:29:38 -07:00
Olivier Combe 30efb6b8ea fix(ivy): don't project removed placeholders with runtime i18n (#30783)
When translated content was projected, all of the content was reappended, even the placeholders that had been removed in the translation.
To avoid that we added a new flag on `TNode` that specifies that a node is detached, in which case it should be ignored by the projection.

FW-1319 #resolve
PR Close #30783
2019-06-05 21:28:39 -07:00
Ben Lesh d1df0a94d4 refactor(ivy): remove ɵɵelementProperty instruction (#30645)
- Removes ɵɵelementProperty instruction
- Updates tests that were using it
- NOTE: There is one test under `render3/integration_spec.ts` that is commented out, and needs to be reviewed. Basically, I could not find a good why to test what it was doing, because it was doing things that I am not sure we could generate in an acceptance test.

PR Close #30645
2019-06-05 09:04:43 -07:00
Olivier Combe 00cc905b98 feat(ivy): support `ng-content` in runtime i18n translations (#30782)
Added a new syntax for projections (`¤` will represent `ng-content` nodes) so that we can treat them specifically.
When we enter an i18n block with the instruction `i18nStart`, a new `delayProjection` variable is set to true to prevent the instruction `projection` from projecting the nodes. Once we reach the `i18nEnd` instruction and encounter a projection in the translation we will project its nodes.
If a projection was removed from a translation, then its nodes won't be projected at all.
The variable `delayProjection` is restored to `false` at the end of `i18nEnd` so that it doesn't stop projections outside of i18n blocks.

FW-1261 #resolve
PR Close #30782
2019-06-05 09:04:13 -07:00
Alex Eagle 337b6fe003 build: remove unreferenced tsconfig-build.json files (#30858)
These are no longer needed since Bazel generates a tsconfig for each compilation

PR Close #30858
2019-06-05 09:03:36 -07:00
Olivier Combe 0d4f8c7dd9 fix(ivy): allow empty cases for ICU expressions (#30846)
We used to ignore empty strings for optimization purposes, but it turns out that empty strings are also valid values for ICU cases and we shouldn't ignore those.

FW-1290 #resolve
PR Close #30846
2019-06-04 13:36:28 -07:00
Miško Hevery 55a14e4866 feat(ivy): in `ngDevMode` use named object literals and arrays for easier debugging/profiling (#30542)
PR Close #30542
2019-06-04 12:01:46 -07:00
Miško Hevery c7850fff3b refactor(ivy): rename debug.ts to lview_debug.ts (#30542)
PR Close #30542
2019-06-04 12:01:46 -07:00
JoostK 4da5e9a156 fix(ivy): type checking - apply attribute to property name mapping (#30675)
Some HTML attributes don't correspond to their DOM property name, in which
case the runtime will apply the appropriate transformation when assigning
a property using its attribute name. One example of this is the `for`
attribute, for which the DOM property is named `htmlFor`.

The type-checking machinery in ngtsc must also take this mapping into
account, as it generates type-check code in which unclaimed property bindings
are assigned to properties of (subtypes of) `HTMLElement`.

Fixes #30607
Fixes FW-1327

PR Close #30675
2019-06-04 12:01:18 -07:00
Pawel Kozlowski 8154433130 perf(ivy): limit allocation of LQueries_ objects (#30664)
Before this change we would systematically call LQueries.clone() when executting
elementStart / elementContainerStart instructions. This was often unnecessary as
LQueries can be mutated under 2 conditions only:
- we are crossing an element that has directives with content queries
  (new queries must be added);
- we are descending into element hierarchy (creating a child element of an existing element)
  and the current LQueries object is tracking shallow queries (shallow queries are removed).

With this PR LQueires.clone() is only done when needed and this gratelly reduces number
of LQueries object created: in the "expanding rows" benchmark number of allocated
(and often GCed just after!) LQueries is reduced from ~100k -> ~35k. This represents
over 1MB of memory that is not allocated.

PR Close #30664
2019-06-03 12:01:35 -07:00
Misko Hevery fcdd784667 refactor(core): cleanup code with side-effects which was preventing tree-shaking (#30580)
PR Close #30580
2019-06-03 09:01:51 -07:00
Umberto Tarantino a981dd2aab docs(core): fix typo in style bindings comment (#30661)
PR Close #30661
2019-06-03 09:01:05 -07:00
Ben Lesh b4e68025f8 refactor(ivy): add ɵɵupdateSyntheticHostBinding command (#30670)
- Refactors `ɵɵcomponentHostSyntheticProperty` into `ɵɵupdateSyntheticHostBinding`, to better align it with other new instructions.

PR Close #30670
2019-06-03 09:00:13 -07:00
Olivier Combe 680d38513b fix(ivy): correctly project bare ICU expressions (#30696)
Projecting bare ICU expressions failed because we would assume that component's content nodes would be projected later and doing so at that point would be wasteful. But ICU nodes are handled independently and should be inserted immediately because they will be ignored by projections.

FW-1348 #resolve

PR Close #30696
2019-06-03 08:59:14 -07:00
Vikram Subramanian 21328f2373 fix(ivy): add back ngDevMode to r3_injector (#30707)
Import the definition so that it doesn't cause breakage with closure conformance rules.

FW-1307 #resolve

PR Close #30707
2019-06-03 08:57:14 -07:00
Tim Deschryver dd8cf19352 docs: fix a small typo in injectable decorator description (#30785)
PR Close #30785
2019-06-03 08:56:21 -07:00
crisbeto f936590573 fix(ivy): DebugNode.queryAll matching sibling nodes (#30788)
Inside of `DebugNode.queryAll` we walk through all of the descendants of the node that we're querying against, however the logic that walks sideways through a node siblings also applies to the root node. This means that eventually we'll match against its nodes as well which will give us invalid results. These changes add an extra check to ensure that we aren't matching against the siblings of the root node.

This PR resolves FW-1353.

PR Close #30788
2019-05-31 15:19:18 -07:00
Paul Gschwendtner aca339e864 fix(ivy): unable to project into multiple slots with default selector (#30561)
With View engine it was possible to declare multiple projection
definitions and to programmatically project nodes into the slots.

e.g.

```html
<ng-content></ng-content>
<ng-content></ng-content>
```

Using `ViewContainerRef#createComponent` allowed projecting
nodes into one of the projection defs (through index)

This no longer works with Ivy as the `projectionDef` instruction only
retrieves a list of selectors instead of also retrieving entries for
reserved projection slots which appear when using the default
selector multiple times (as seen above).

In order to fix this issue, the Ivy compiler now passes all
projection slots to the `projectionDef` instruction. Meaning that
there can be multiple projection slots with the same wildcard
selector. This allows multi-slot projection as seen in the
example above, and it also allows us to match the multi-slot node
projection order from View Engine (to avoid breaking changes).

It basically ensures that Ivy fully matches the View Engine behavior
except of a very small edge case that has already been discussed
in FW-886 (with the conclusion of working as intended).

Read more here: https://hackmd.io/s/Sy2kQlgTE

PR Close #30561
2019-05-31 09:52:32 -07:00
Paul Gschwendtner 6d861f240b fix(ivy): module with providers are processed too early (#30688)
Currently with Ivy, `ModuleWithProvider` providers are processed in order
of declaration in the `NgModule` imports. This technically makes makes
sense but is a potential breaking change as `ModuleWithProvider` providers
are processed after all imported modules in View Engine.

In order to keep the behavior of View Engine, the `r3_injector` is updated
to no longer process `ModuleWithProvider` providers egarly.

Resolves FW-1349

PR Close #30688
2019-05-31 09:48:39 -07:00
Andrew Kushnir e0c36620c1 test: resotre "async" around tests where "await" is used (#30762)
The "async" around a couple tests was removed because of the merge conflict in one of the previous commits (80394ce08b). This change restores missing "async"s.

PR Close #30762
2019-05-30 23:14:16 -07:00
Alan Agius 80394ce08b fix(core): TypeScript related migrations should cater for BOM (#30719)
fix(@schematics/angular): TypeScript related migrations should cater for BOM

In the CLI `UpdateRecorder` methods such as `insertLeft`, `remove` etc.. accepts positions which are not offset by a BOM. This is because when a file has a BOM a different recorder will be used https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/schematics/src/tree/recorder.ts#L72 which caters for an addition offset/delta.

The main reason for this is that when a developer is writing a schematic they shouldn't need to compute the offset based if a file has a BOM or not and is handled out of the box.

Example
```ts
recorder.insertLeft(5, 'true');
```

However this is unfortunate in the case if a ts SourceFile is used and one uses `getWidth` and `getStart` method they will already be offset by 1, which at the end it results in a double offset and hence the problem.

Fixes #30713

PR Close #30719
2019-05-30 20:48:45 -07:00
crisbeto 99c9bcab03 test: move away from deprecated testing method (#30747)
Switches all of the tests away from the `runSchematic` method which was deprecated in 8.0 (see https://github.com/angular/angular-cli/pull/14412). Along the same lines as https://github.com/angular/components/pull/16150.

PR Close #30747
2019-05-30 20:46:48 -07:00
Alex Rickabaugh d82adbe8c4 fix(ivy): align DebugNode/DebugElement behavior with View Engine (#30756)
Two issues with DebugNode/DebugElement in Ivy were causing problems in user
tests.

1. The DebugNodes returned by Ivy were not actually instances of DebugNode.

This was due to an issue with the Ivy switch logic in debug_node.ts.
The declaration of the exported DebugNode reference was set to
`DebugNode__PRE_R3__ as any`. The cast prevented the Ivy switch transform
from detecting this as a switchable declaration. The transform cannot handle
arbitrary syntax, and exports *must* be of the form "const x = y__PRE_R3__;"
or they will not work. The cast to any in this case was not needed, so this
commit removes it.

2. DebugNodes returned by Ivy multiple times for the same element were not
reference-identical. This was previously considered a minor breaking change
in Ivy, but testing has shown that users depend on referential equality of
DebugNodes. This commit caches a DebugNode on a DOM node when first creating
it, to allow returning the same instance in subsequent operations.

PR Close #30756
2019-05-30 20:45:31 -07:00
Matias Niemelä 19bbf4bc8e test(ivy): fix sanitization state leaking issue
Due to sanitization being stored as a temp/global value between
instructions, unit tests randomly failed because one test failed
to clean up its temporary value. This patch fixes this issue.
2019-05-30 13:53:06 -07:00
Olivier Combe 53c6b78c51 feat(ivy): add `AttributeMarker.I18n` for i18n attributes (#30402)
`i18nAttributes` instructions always occur after the element instruction. This means that we need to treat `i18n-` attributes differently.
By defining a specific `AttributeMarker` we can ensure that we won't trigger directive inputs with untranslated attribute values.

FW-1332 #resolve
PR Close #30402
2019-05-30 16:39:24 -04:00
Olivier Combe 91699259b2 fix(ivy): trigger directive inputs with i18n translations (#30402)
Changed runtime i18n to define attributes with bindings, or matching directive inputs/outputs as element properties as we are supposed to do in Angular.
This PR fixes the issue where directive inputs wouldn't be trigged.

FW-1315 #resolve
PR Close #30402
2019-05-30 16:39:24 -04:00
Pawel Kozlowski 8e8c1ad47d refactor(ivy): name LQuery object for easier memory allocation tracking (#30656)
PR Close #30656
2019-05-30 15:17:30 -04:00
Alex Rickabaugh b4644d7bb0 fix(ivy): correct timing of NgModuleFactory registration (#30706)
Commit 0df719a46 introduced registration of NgModules with ids when compiled
with AOT, and f74373f2d corrected the timing to avoid issues with tree
shaking. Neither of these approaches were correct.

This commit fixes the timing to match View Engine and avoid tree shaking
issues, as well as fixes a bug with the registration of imported module ids.

A new Ivy-only test is added which verifies that modules get registered
correctly under real-world conditions.

PR Close #30706
2019-05-30 15:13:20 -04:00
Olivier Combe 5e0f982961 feat(ivy): use i18n locale data to determine the plural form of ICU expressions (#29249)
Plural ICU expressions depend on the locale (different languages have different plural forms). Until now the locale was hard coded as `en-US`.
For compatibility reasons, if you use ivy with AOT and bootstrap your app with `bootstrapModule` then the `LOCALE_ID` token will be set automatically for ivy, which is then used to get the correct plural form.
If you use JIT, you need to define the `LOCALE_ID` provider on the module that you bootstrap.
For `TestBed` you can use either `configureTestingModule` or `overrideProvider` to define that provider.
If you don't use the compat mode and start your app with `renderComponent` you need to call `ɵsetLocaleId` manually to define the `LOCALE_ID` before bootstrap. We expect this to change once we start adding the new i18n APIs, so don't rely on this function (there's a reason why it's a private export).
PR Close #29249
2019-05-30 15:09:02 -04:00
Matias Niemelä 82682bb93f refactor(ivy): enable sanitization support for the new styling algorithm (#30667)
This patch is one of the final patches to refactor the styling algorithm
to be more efficient, performant and less complex.

This patch enables sanitization support for map-based and prop-based
style bindings.

PR Close #30667
2019-05-30 01:03:39 -04:00
Paul Gschwendtner d72479b628 docs(core): template-var-assignment schematic should link to deprecation guide (#30702)
Instead of linking to a markdown file explaining what the migration warnings
are about, we should link to the deprecation guide which now also contains
an entry for that schematic. This makes the deprecation explanations
consistent and more centralized.

PR Close #30702
2019-05-29 13:50:34 -04:00
Ben Lesh dd0815095f feat(ivy): add ɵɵtextInterpolateX instructions (#30011)
- `ɵɵtextBinding(..., ɵɵinterpolationX())` instructions will now just be `ɵɵtextInterpolate(...)` instructions

PR Close #30011
2019-05-29 12:38:58 -04:00
Alex Rickabaugh 661c6e6f10 fix(ivy): fix PR collision with static: true and new test (#30666)
This fixes a collision between #30639 and #30543 where the latter added
usages of @ViewChild without the static flag present, but the former
made the flag required.

PR Close #30666
2019-05-24 18:02:17 -04:00
Alex Rickabaugh 84dd2679a9 fix(core): require 'static' flag on queries in typings (#30639)
This commit makes the static flag on @ViewChild and @ContentChild required.

BREAKING CHANGE:

In Angular version 8, it's required that all @ViewChild and @ContentChild
queries have a 'static' flag specifying whether the query is 'static' or
'dynamic'. The compiler previously sorted queries automatically, but in
8.0 developers are required to explicitly specify which behavior is wanted.
This is a temporary requirement as part of a migration; see
https://angular.io/guide/static-query-migration for more details.

@ViewChildren and @ContentChildren queries are always dynamic, and so are
unaffected.

PR Close #30639
2019-05-24 16:55:00 -04:00
Matias Niemelä dc6406e5e8 refactor(ivy): evaluate map-based styling bindings with a new algorithm (#30543)
This patch in the second runtime change which refactors how styling
bindings work in Angular. This patch refactors how map-based
`[style]` and `[class]` bindings work using a new algorithm which
is faster and less complex than the former one.

This patch is a follow-up to an earlier refactor which enabled
support for prop-based `[style.name]` and `[class.name]`
bindings (see f03475cac8).

PR Close #30543
2019-05-24 14:31:35 -04:00
Alex Rickabaugh deb77bd3df feat(ivy): TestBed support for reusing non-exported components (#30578)
This is a new feature of the Ivy TestBed.

A common user pattern is to test one component with another. This is
commonly done by creating a `TestFixture` component which exercises the
main component under test.

This pattern is more difficult if the component under test is declared in an
NgModule but not exported. In this case, overriding the module is necessary.

In g3 (and View Engine), it's possible to use an NgSummary to override the
recompilation of a component, and depend on its AOT compiled factory. The
way this is implemented, however, specifying a summary for a module
effectively overrides much of the TestBed's other behavior. For example, the
following is legal:

```typescript
TestBed.configureTestingModule({
  declarations: [FooCmp, TestFixture],
  imports: [FooModule],
  aotSummaries: [FooModuleNgSummary],
});
```

Here, `FooCmp` is declared in both the testing module and in the imported
`FooModule`. However, because the summary is provided, `FooCmp` is not
compiled within the context of the testing module, but _is_ made available
for `TestFixture` to use, even if it wasn't originally exported from
`FooModule`.

This pattern breaks in Ivy - because summaries are a no-op, this amounts
to a true double declaration of `FooCmp` which raises an error.

Fixing this in user code is possible, but is difficult to do in an
automated or backwards compatible way. An alternative solution is
implemented in this PR.

This PR attempts to capture the user intent of the following previously
unsupported configuration:

```typescript
TestBed.configureTestingModule({
  declarations: [FooCmp, TestFixture],
  imports: [FooModule],
});
```

Note that this is the same as the configuration above in Ivy, as the
`aotSummaries` value provided has no effect.

The user intent here is interpreted as follows:

1) `FooCmp` is a pre-existing component that's being used in the test
   (via import of `FooModule`). It may or may not be exported by this
   module.

2) `FooCmp` should be part of the testing module's scope. That is, it
   should be visible to `TestFixture`. This is because it's listed in
   `declarations`.

This feature effectively makes the `TestBed` testing module special. It's
able to declare components without compiling them, if they're already
compiled (or configured to be compiled) in the imports. And crucially, the
behavior matches the first example with the summary, making Ivy backwards
compatible with View Engine for tests that use summaries.

PR Close #30578
2019-05-24 14:01:44 -04:00
Pawel Kozlowski d5f96a887d refactor(ivy): refactor getBeforeNodeForView for readability (#30614)
PR Close #30614
2019-05-24 13:58:43 -04:00
Olivier Combe 68cd0cab8c fix(ivy): don't throw on unmatched placeholder replacements in `i18nPostprocess` (#30632)
Depending on which placeholders the translation uses, there are some legitimate cases where we might not use all placeholder replacements in `i18nPostprocess`. For example if some of the placeholders of the original messages have been removed in the translation.

FW-1312 #resolve
PR Close #30632
2019-05-24 13:57:44 -04:00
Paul Gschwendtner 6bf5ec241d docs(core): static-query migration should use permalink for migration guide (#30649)
8479cb4233 updated the static-query migration
to refer to the new guide on AIO. Unfortunately these URLs are currently not
valid as the guide is only available on `next.angular.io` right now. In order to
make the link work permanently (e.g. if we eventually remove the guide in future
major versions), we use the permalink from the `v8` subdomain.

PR Close #30649
2019-05-24 10:08:16 -05:00
Kara Erickson 8479cb4233 docs(core): update static query schematic with guide link (#30646)
PR Close #30646
2019-05-23 22:14:49 -07:00
Alex Rickabaugh f310a5960e feat(core): deprecate integration with the Web Tracing Framework (WTF) (#30642)
DEPRECATION:

Angular previously has supported an integration with the Web Tracing
Framework (WTF) for performance testing of Angular applications. This
integration has not been maintained and likely does not work for the
majority of Angular applications today. As a result, we are deprecating
the integration in Angular version 8.

This deprecation covers the following public APIs:
* `WtfScopeFn`
* `wtfCreateScope`
* `wtfStartTimeRange`
* `wtfEndTimeRange`
* `wtfLeave`

FW-1338 #resolve

PR Close #30642
2019-05-23 15:09:48 -07:00
Paul Gschwendtner 132c61dfd4 refactor(core): static-query migration should warn about syntax failures (#30628)
Currently if a project has source-files with syntax failures and the migration
has been started on a broken project, we silently migrate *as much as possible*,
but never notify the developer that the project was in a broken state and that
he can re-run the migration after the failures are fixed.

Additionally the template strategy does not need to exit gracefully if it detects
Angular semantic diagnostics on generated files (template type checking). These
diagnostics are not relevant for the query timing analysis.

PR Close #30628
2019-05-23 10:31:48 -07:00
Paul Gschwendtner 5640cedc82 refactor(core): static-query migration should always use template strategy (#30628)
We are removing the prompt for the `static-query` migration and make the
template strategy the migration strategy for the migration. The usage
strategy is good for best-practices, but for now we want to ensure that
the migration is a seamless as possible and that is only achievable my
re-using the same logic that View Engine uses for determining the
timing of a query.

PR Close #30628
2019-05-23 10:31:48 -07:00
Kara Erickson faac51fd2e test(core): update query-specific tests in core (#30626)
PR Close #30626
2019-05-23 10:31:32 -07:00
Kara Erickson 214ae0ea4c test(compiler): update examples and compiler tests (#30626)
PR Close #30626
2019-05-23 10:31:32 -07:00
Kara Erickson 4299ecf9be test(core): update core tests (unrelated to queries) to use static flag (#30626)
PR Close #30626
2019-05-23 10:31:32 -07:00
Misko Hevery 21e8ac1e02 refactor(ivy): createNodeAtIndex no longer depends on L* (#30453)
PR Close #30453
2019-05-23 10:30:59 -07:00
Misko Hevery 01cf04c85f refactor(ivy): createNodeAtIndex links TNodes on first pass only (#30453)
PR Close #30453
2019-05-23 10:30:59 -07:00
Misko Hevery 5c5cee9f39 refactor(ivy): t-functions should not depend on l-data (#30453)
PR Close #30453
2019-05-23 10:30:59 -07:00
Misko Hevery 2f336f15be refactor(core): unify setPreviousOrParentTNode and setIsParent into single setPreviousOrParentTNode (#30453)
PR Close #30453
2019-05-23 10:30:59 -07:00
Misko Hevery e122b44269 perf(ivy): clean up findComponentView for speed (#30453)
PR Close #30453
2019-05-23 10:30:59 -07:00
Misko Hevery 9ce9561737 perf(ivy): clean up createNodeAtIndex for speed (#30453)
PR Close #30453
2019-05-23 10:30:59 -07:00
Misko Hevery 2545445ffb perf(ivy): extract multiple reads to local var (#30453)
PR Close #30453
2019-05-23 10:30:59 -07:00
Misko Hevery 300f1b289a fix(ivy): improve assert error message (#30453)
PR Close #30453
2019-05-23 10:30:59 -07:00
Ben Lesh 2cdbe9b2ef refactor(ivy): ensure new attribute instructons are available in JIT (#30503)
PR Close #30503
2019-05-22 16:30:29 -07:00
Ben Lesh 7555a46e23 refactor(ivy): add new attribute interpolation instructions (#30503)
PR Close #30503
2019-05-22 16:30:28 -07:00
Ben Lesh 38d7acee4d refactor(ivy): add new ɵɵattribute instruction (#30503)
- adds the ɵɵattribute instruction
- adds compilation handling for Δattribute instruction
- updates tests

PR Close #30503
2019-05-22 16:30:28 -07:00
Ben Lesh 10f48278c2 test(ivy): add attribute interpolation test (#30503)
PR Close #30503
2019-05-22 16:30:28 -07:00
Andrew Kushnir 86c46908d4 fix(ivy): R3TestBed doesn't allow template overrides with an empty string (#30602)
Prior to this change a component was considered unresolved (i.e. having dynamic resources that should be loaded, like external template or stylesheets) even if template override was provided as an empty string (for example, via TestBed.overrideTemplateUsingTestingModule call). This commit fixes the condition that previously treated empty string as an absent template value.

PR Close #30602
2019-05-22 16:25:56 -07:00
Paul Gschwendtner fa6cbb3ffe fix(ivy): ng-container with ViewContainerRef creates two comments (#30611)
With Ivy, injecting a `ViewContainerRef` for a `<ng-container>` element
results in two comments generated in the DOM. One comment as host
element for the `ElementContainer` and one for the generated `LContainer`
which is needed for the created `ViewContainerRef`.

This is problematic as developers expect the same anchor element for
the `LContainer` and the `ElementContainer` in order to be able to move
the host element of `<ng-container>` without leaving the actual
`LContainer` anchor element at the original location.

This worked differently in View Engine and various applications might
depend on the behavior where the `ViewContainerRef` shares the anchor
comment node with the host comment node of the `<ng-container>`. For
example `CdkTable` from `@angular/cdk` moves around the host element of
a `<ng-container>` and also expects embedded views to be inserted next
to the moved `<ng-container>` host element.

See: f8be5329f8/src/cdk/table/table.ts (L999-L1016)

Resolves FW-1341

PR Close #30611
2019-05-22 16:25:22 -07:00
Andrew Kushnir 02523debe5 fix(ivy): handle pipes in i18n attributes properly (#30573)
Prior to this change we processed binding expression (including bindings with pipes) in i18n attributes before we generate update instruction. As a result, slot offsets for pipeBind instructions were calculated incorrectly. Now we perform binding expression processing when we generate "update block" instructions, so offsets are calculated correctly.

PR Close #30573
2019-05-22 16:23:18 -07:00
Paul Gschwendtner f74e0fd825 refactor(core): migrations should parse cli workspace config as json5 (#30582)
Currently we try to parse CLI workspace configurations gracefully by
using the native `JSON.parse()` method. This means that the CLI workspace
configuration needs to follow the strict JSON specification because otherwise
the migrations would not be able to find TypeScript configurations in the CLI
project where JSON5 workspace configurations are supported.

In order to handle such workspace configurations, we leverage the JSON
parsing logicfrom the `@angular-devkit/core` which is also used by the CLI.

PR Close #30582
2019-05-21 17:26:22 -07:00
Pawel Kozlowski 66f269c077 refactor(ivy): rename query-related functions for clarity (#30587)
PR Close #30587
2019-05-21 13:14:15 -07:00
Pawel Kozlowski b613f90146 refactor(ivy): avoid calling query instructions from static query instructions (#30587)
PR Close #30587
2019-05-21 13:14:14 -07:00
Pawel Kozlowski 2fe6f350cb refactor(ivy): avoid repeated read of LView from global state (#30587)
PR Close #30587
2019-05-21 13:14:14 -07:00
Pawel Kozlowski 514ebf402a refactor(ivy): avoid calling other instructions from the loadViewQuery instruction (#30587)
PR Close #30587
2019-05-21 13:14:14 -07:00
cexbrayat f6bf8928f2 fix(core): temporarily remove @deprecated jsdoc tag for a TextBed.get overload (#30514)
PR #29290 introduced a new `TestBed.get` signature and deprecated the existing one.
This raises a lot of TSLint deprecation warnings in projects using a strict TS config (see #29905 for context), so we are temporarily removing the `@deprecated` annotation in favor of a plain text warning until we properly fix it.

Refs #29905
Fixes FW-1336

PR Close #30514
2019-05-21 13:11:21 -07:00
Miško Hevery f3c69e7f6b refactor(ivy): rewrite flatten function to be more memory efficient (#30468)
The `flatten` function used `concat` and `slice` which created a lot of intermediary
object allocations. Because `flatten` is used from query any benchmark which
used query would exhibit high minor GC counts.

PR Close #30468
2019-05-21 13:06:23 -07:00
Kara Erickson a96976e88f fix(core): remove deprecated `TestBed.deprecatedOverrideProvider` API (#30576)
BREAKING CHANGE

In PR #19558, we fixed a bug in `TestBed.overrideProvider` where
eager providers were not being instantiated correctly. However,
it turned out that since this bug had been around for quite a bit,
many apps were relying on the broken behavior where the providers
would not be instantiated. To assist in the transition, the
`TestBed.deprecatedOverrideProvider` method was temporarily
introduced to mimic the old behavior so that apps would have a
longer time period to migrate their code.

2 years and 3 versions later, it is time to remove the temporary
method. This commit removes `TestBed.deprecatedOverrideProvider`
altogether. Any usages of `TestBed.deprecatedOverrideProvider`
should be replaced with `TestBed.overrideProvider`. This may mean
that providers that were not created before will now be instantiated,
which could mean that your tests need to provide more mocks or stubs
for the dependencies of the newly instantiated providers.

PR Close #30576
2019-05-21 12:37:17 -07:00
Miško Hevery df1d3fbd7b perf(ivy): minor cleanup; prevent sparse arrays (#30495)
PR Close #30495
2019-05-21 09:04:39 -07:00
Ben Lesh abe4433202 test(ivy): add tests around directive attribute ghosting (#30544)
This battery of tests is to ensure the instructions we are generating have the same behavior in Ivy has they did in ViewEngine.

PR Close #30544
2019-05-21 09:03:03 -07:00
Ben Lesh d7eaae6f22 refactor(ivy): Move instructions back to ɵɵ (#30546)
There is an encoding issue with using delta `Δ`, where the browser will attempt to detect the file encoding if the character set is not explicitly declared on a `<script/>` tag, and Chrome will find the `Δ` character and decide it is window-1252 encoding, which misinterprets the `Δ` character to be some other character that is not a valid JS identifier character

So back to the frog eyes we go.

```
    __
   /ɵɵ\
  ( -- ) - I am ineffable. I am forever.
 _/    \_
/  \  /  \
==  ==  ==
```

PR Close #30546
2019-05-20 16:37:47 -07:00
Miško Hevery 6454f76cf6 refactor(ivy): remove ngPrivateData megamorphic prop access (#30548)
PR Close #30548
2019-05-20 10:12:07 -07:00
Miško Hevery 28ae22ecb9 refactor(ivy): move `renderTemplate` into render_util.ts because it is only used in tests (#30548)
PR Close #30548
2019-05-20 10:12:07 -07:00
Paul Gschwendtner 8e2e9dcee6 test(ivy): move render3 view_container_ref tests to acceptance (#30488)
Moves all manual render3 view_container_ref tests that use property
bindings to acceptance tests with TestBed.

Two issues surfaced and refer to a difference between Ivy and View
engine:

* Multi-slot projection is not working with Ivy: FW-1331
* ViewContainerRef throws if index is invalid while View Engine clamped index: FW-1330

PR Close #30488
2019-05-17 13:33:22 -07:00
Ben Lesh 01919fbaae test(ivy): Add TODOs (#30522)
PR Close #30522
2019-05-17 09:56:49 -07:00
Ben Lesh 80d4fc5e26 test(ivy): remove `new Component` use from inheritance tests (#30522)
PR Close #30522
2019-05-17 09:56:49 -07:00
Matias Niemelä f03475cac8 refactor(ivy): evaluate prop-based styling bindings with a new algorithm (#30469)
This is the first refactor PR designed to change how styling bindings
(i.e. `[style]` and `[class]`) behave in Ivy. Instead of having a heavy
element-by-element context be generated for each element, this new
refactor aims to use a single context for each `tNode` element that is
examined and iterated over when styling values are to be applied to the
element.

This patch brings this new functionality to prop-based bindings such as
`[style.prop]` and `[class.name]`.

PR Close #30469
2019-05-17 09:54:19 -07:00
Kristiyan Kostadinov 1714451a6d test(ivy): move integration tests into acceptance (#30461)
Moves most of the tests from `render3/integration_spec` into `acceptance`. Note that there are still a handful of tests left in render3, because we don't have a way of moving all of them to go through `TestBed` since they either have r3-specific assertions or we don't have access to the same APIs as the raw instructions.

PR Close #30461
2019-05-16 14:40:47 -07:00
crisbeto 1f6fcb6cd3 fix(ivy): unable to bind SafeValue to clip-path (#30491)
Fixes not being able to pass in a `SafeValue` to a `clip-path` binding, because `clip-path` wasn't in the list of exceptions.

PR Close #30491
2019-05-16 14:40:21 -07:00
Ben Lesh 60235b5aef test(ivy): add additional lifecycle hook acceptance tests (#30445)
Moves additional lifecycle hook tests from render3 to acceptance

PR Close #30445
2019-05-16 14:39:22 -07:00
Ben Lesh d18c58816f test(ivy): add onChanges acceptance tests (#30445)
- moves render3 tests to acceptance tests.

PR Close #30445
2019-05-16 14:39:22 -07:00
Ben Lesh 222dde129d test(ivy): add onDestroy acceptance tests (#30445)
Ports render3 onDestroy tests over to be acceptance tests. Removes old render3 tests if possible.

Note the onlyInIvy test for one area where Ivy has a different behavior than ViewEngine

PR Close #30445
2019-05-16 14:39:22 -07:00
Ben Lesh 257e9646d0 test(ivy): add afterViewInit acceptance tests (#30445)
Migrates afterViewInit and afterViewChecked render3 tests to acceptance tests

PR Close #30445
2019-05-16 14:39:22 -07:00
Ben Lesh a5e06ba629 test(ivy): onAfterContentInit acceptance tests (#30445)
- Ports onAfterContentInit tests from render3 to acceptance tests

PR Close #30445
2019-05-16 14:39:22 -07:00
Ben Lesh 9a6d298ca7 test(ivy): doCheck lifecycle acceptance tests (#30445)
- ports render3 doCheck tests to acceptance tests

PR Close #30445
2019-05-16 14:39:21 -07:00
Ben Lesh 6ec621b72d test(ivy): onInit lifecycle acceptance tests (#30445)
Ports render3 lifecycle onInit tests to acceptance tests

PR Close #30445
2019-05-16 14:39:21 -07:00
Pawel Kozlowski 07ebe9624f docs(ivy): document rules for the global state access (#30485)
PR Close #30485
2019-05-16 14:38:46 -07:00
Filipe Silva ac34a1429b refactor: remove toplevel property accesses (#29329)
PR Close #29329
2019-05-16 12:08:49 -07:00
Ben Lesh 3f7e823b80 test(ivy): add exhaustive inheritance tests (#30442)
- Adds inheritance tests for many combinations of directive, component and bare class inheritance
- Adds tests that are failing in ivy, but should work, marks them with `xit` and a TODO.
- Removes render3 unit tests that cover the same things.

PR Close #30442
2019-05-16 11:45:17 -07:00
Kara Erickson c62c5e2999 fix(ivy): do not throw if host style is on a template node (#30498)
In View Engine, we would simply ignore host style bindings on template nodes. In Ivy,
we are throwing a "Cannot read length of undefined" error instead. For backwards
compatibility, we should also ignore these bindings rather than blowing up.

PR Close #30498
2019-05-16 09:42:34 -07:00
Olivier Combe f2ae452f01 perf(ivy): don't relink the whole tree when `TNode` exists (#30511)
PR Close #30511
2019-05-16 09:42:01 -07:00
Paul Gschwendtner 45e11915dc test(ivy): move render3 query tests to acceptance (#30382)
Moves all manual render3 query tests that use the `elementProperty`
instructions to TestBed acceptance tests.

PR Close #30382
2019-05-15 14:11:38 -07:00
Pete Bacon Darwin 1a0e500eea fix(ivy): support sub-class services that only inherit `@Injectable` (#30388)
In View engine it is possible to instantiate a service that that has no
`@Injectable` decorator as long as it satisfies one of:

1) It has no dependencies and so a constructor with no parameters.
This is already supported in Ivy.
2) It has no constructor of its own and sub-classes a service which has
dependencies but has its own `@Injectable` decorator. This second
scenario was broken in Ivy.

In Ivy, previous to this commit, if a class to be instantiated did not have
its own `@Injectable` decorator and did not provide a constructor of
its own, then it would be created using `new` with no arguments -
i.e. falling back to the first scenario.

After this commit Ivy correctly uses the `ngInjectableDef` inherited
from the super-class to provide the `factory` for instantiating the
sub-class.

FW-1314

PR Close #30388
2019-05-15 14:10:33 -07:00
Ben Lesh 35c1750fcc test(ivy): port TemplateRef tests over to acceptance tests (#30443)
- Moves template ref tests from render3 unit tests to acceptance tests.
- Marks tests testing ivy specific changes as `onlyInIvy`.
- Deletes old render3 unit tests that are no longer necessary

PR Close #30443
2019-05-15 14:10:18 -07:00
Ben Lesh 4f9b16783b refactor(ivy): deprecate ɵɵinject and ɵɵdefineInjectable (#30362)
- They are to be removed before the end of RC

PR Close #30362
2019-05-14 16:52:15 -07:00
Ben Lesh 018a5168a5 refactor(ivy): mark ΔdefineInjectable as codeGenApi. (#30362)
PR Close #30362
2019-05-14 16:52:15 -07:00
Ben Lesh cf86ed7b29 refactor(ivy): migrate ɵɵ prefix back to Δ (#30362)
Now that issues are resolved with Closure compiler, we can move back to our desired prefix of `Δ`.

PR Close #30362
2019-05-14 16:52:15 -07:00
Alex Rickabaugh dbb150a9bd Revert "fix(core): CSS sanitizer now allows parens in file names (#30322)" (#30463)
This reverts commit 728db88280.

We're reverting this commit for now, until it can be subjected to a more
thorough security review.

PR Close #30463
2019-05-14 14:49:39 -07:00
Paul Gschwendtner 9e5377a2e3 refactor(core): improve messages for static-query migrations (#30458)
Slightly improves the messages for the static-query migration in order
to make the terminal output less verbose but more helpful. Unfortunately
we are limited in what we can print due to the devkit not providing much
utilities for printing good messages from a migration schematic.

PR Close #30458
2019-05-14 14:04:44 -07:00
Paul Gschwendtner 0cdf5980e2 fix(core): static-query migration should not fallback to test strategy (#30458)
Currently if something fails in the selected strategy (e.g. AOT failures),
the migration currently accidentally falls back to the test strategy. This
is not helpful as we want to give developers the possibility to re-run
the migration after fixing potential AOT failures.

PR Close #30458
2019-05-14 14:04:43 -07:00
Paul Gschwendtner 6ceb9034dc fix(core): static-query migration errors not printed properly (#30458)
Apparently the devkit logger is not able to properly print
out error objects, so we need to convert them to a string
before in order to make the error visible to the user.

This is not testable without an e2e test that validates the CLI
terminal output.

PR Close #30458
2019-05-14 14:04:43 -07:00
cexbrayat 1b059e595f test(ivy): move common integration tests to acceptance (#30213)
PR Close #30213
2019-05-14 11:37:50 -07:00
Alex Eagle 06efc340b6 build: update rules_nodejs and clean up bazel warnings (#30370)
Preserve compatibility with rollup_bundle rule.
Add missing npm dependencies, which are now enforced by the strict_deps plugin in tsc_wrapped

PR Close #30370
2019-05-14 10:08:45 -07:00
Kristiyan Kostadinov cc2f175617 test(ivy): move discovery_utils tests to acceptance (#30416)
Rewrites the discovery util tests to use `TestBed`.

PR Close #30416
2019-05-14 09:55:17 -07:00
Kristiyan Kostadinov 96baff3a85 test(ivy): move change detection tests into acceptance (#30425)
Moves most of the r3 change detection tests into `acceptance`. Notes:
* A handful of tests weren't migrated, because they were testing an API that isn't exposed publicly yet.
* The `should throw if bindings in children of current view have changed` and `should NOT throw if bindings in ancestors of current view have changed` tests were removed, because there's not nice way of hitting the same code path with `TestBed` and doing the same assertion as with the raw instructions. I'm open to ideas on how we could do them.
* There were a few tests that assert that the `innerHTML` looks in a particular way. I've switched them to use `textContent`, because Ivy and ViewEngine produce slightly different DOM. The tests were only checking whether the text has changed anyway.

PR Close #30425
2019-05-14 09:54:45 -07:00
Paul Gschwendtner 090eac068a test(ivy): move property render3 tests to acceptance (#30426)
Moves all manual render3 property binding tests to
TestBed acceptance tests. Unfortunately three property
binding tests could not be migrated as these rely on
manual Ivy template code that is not supported within
TestBed. These can be revisited as discussed in the
framework team meeting.

PR Close #30426
2019-05-14 09:39:22 -07:00
Paul Gschwendtner d09d8e0adf test(ivy): move render3 directive tests to acceptance (#30432)
Moves all manual render3 directive tests to TestBed acceptance
tests.

PR Close #30432
2019-05-14 09:37:01 -07:00
Paul Gschwendtner a57f3e7bbf test(ivy): move render3 renderer_factory tests to acceptance (#30435)
Moves all manual render3 tests which are located within the
`renderer_factory_spec.ts` file to acceptance tests. A few tests
that use Ivy-specific logic which is not replicable with `TestBed`
remain in the render3 folder (e.g. using `renderTemplate`)

Additionally migrated tests that assert the lifecycles of the
renderer_factory are set to *ivy only* as the lifecycle seems
to be different in Ivy. Tracked with: FW-1320

PR Close #30435
2019-05-14 09:36:24 -07:00
Kristiyan Kostadinov f74373f2dd fix(ivy): align NgModule registration timing with ViewEngine (#30244)
Currently in Ivy `NgModule` registration happens when the class is declared, however this is inconsistent with ViewEngine and requires extra generated code. These changes remove the generated code for `registerModuleFactory`, pass the id through to the `ngModuleDef` and do the module registration inside `NgModuleFactory.create`.

This PR resolves FW-1285.

PR Close #30244
2019-05-13 11:13:25 -07:00
Ben Lesh 7569a2e0d9 test(ivy): pure function acceptance tests (#30406)
- Moves tests related to the pureFunction instructions from render3 to acceptance tests
- Leaves behind one test for in-template javascript that is not supported syntax yet

PR Close #30406
2019-05-13 10:55:59 -07:00
Olivier Combe 0cf09fc981 test(ivy): use `TestBed` for render3 i18n tests (#30352)
PR Close #30352
2019-05-13 10:51:31 -07:00
Kristiyan Kostadinov cb6dea473f test(ivy): move pipe tests into acceptance (#30389)
Moves over the tests from `pipe_spec` into `acceptance`. Note that the two `WrappedValue` tests haven't been moved over, because impure pipes always throw "changed after checked" errors in `TestBed`. This seems to be consistent with ViewEngine.

PR Close #30389
2019-05-10 14:35:57 -07:00
JiaLiPassion 5ab809ddf9 build: upgrade zone.js to 0.9.1 (#30260)
Close 30203

resolves the issue that zone-legacy XHR issue

PR Close #30260
2019-05-10 14:25:56 -07:00
Kristiyan Kostadinov 5fd39283ec test(ivy): move output tests to acceptance (#30372)
Moves most of the tests in `output_spec` into `acceptance`. Note that one test is left in `render3`, because it's testing mixing in custom logic with instructions which we can't replicate using `TestBed`.

PR Close #30372
2019-05-10 09:27:57 -07:00
Paul Gschwendtner 1f2b39ad7d test(ivy): move content projection tests to acceptance (#30357)
Moves all manual `render3` content projection tests that use
the `ɵɵelementProperty` to acceptance tests. Additionally a
few other content projection tests were moved over to
acceptance. Eventually we'll be able to move all remaining
content projection tests to acceptance.

PR Close #30357
2019-05-10 09:18:37 -07:00
Olivier Combe 24e172d779 test(ivy): use `TestBed` for render3 component tests (#30282)
PR Close #30282
2019-05-10 09:18:19 -07:00
Pete Bacon Darwin b68850215a refactor(core): clean up support for ES2015 constructor delegation (#30368)
This commit moves the delegated constructor detection to a helper
function and also adds more test coverage.

The original code for this came from https://github.com/angular/angular/pull/24156
thanks to @ts2do.

Closes #24156
Closes #27267

// FW-1310

PR Close #30368
2019-05-10 09:17:20 -07:00
Paul Gschwendtner 8d3365e4fc fix(core): static-query usage migration strategy should detect ambiguous query usage (#30215)
Currently we always just set the timing to `false` if we aren't
able to analyze a given call expression or new expression. e.g.

```ts
ngOnInit() {
  thirdPartyCallSync(() => this.query.doSomething())
}
```

In that case the `thirdPartyCallSync` function comes from the `node_modules`
and is only defined through types while there is no code for the
actual function logic that can be analyzed. This makes it impossible
to tell whether the given call expression actually causes the specified
arrow function to be executed synchronously or not. In order to be able
to make this better, we now peek into the passed arrow function and
check for a synchronous query usage. If so, we set the query timing to
static and mark it as ambiguous. This ensures that the usage strategy is
less "magical" and more correct with third-party code.

Additionally since functions like `setTimeout` are not analyzable but known
to be asynchronous, there is a hard-coded list of known functions which
shouldn't be marked as ambiguous.

Resolves FW-1214. As planned within https://hackmd.io/hPiLWpPlQ4uynC1luIBdfQ

PR Close #30215
2019-05-09 14:39:06 -07:00
Paul Gschwendtner 8cec8f5584 test(core): update core_all size-tracking golden file (#30257)
Even though we don't run the size-tracking test on CI
right now, we update the golden size map as part of
the size-tracking tool update. The size-map difference
should generally be kept up-to-date to be able to
determine which PRs contribute size to a given file.

PR Close #30257
2019-05-09 12:55:17 -07:00
Paul Gschwendtner 741a5dc5f7 build: size-tracking test should support max-byte threshold (#30257)
Based on discussion that happened on the PR that introduced
the size-tracking tool, we want to have another threshold for
the raw byte difference. This allows us to better control for
which changes the size-tracking tool should report a difference.

See: https://github.com/angular/angular/pull/30070#discussion_r278332315

PR Close #30257
2019-05-09 12:55:16 -07:00