Commit Graph

3892 Commits

Author SHA1 Message Date
Alex Rickabaugh 49dccf4bfc fix(ivy): process separate declarations and exports for summaries (#29193)
ngsummary files were generated with an export for each class declaration.
However, some Angular code declares classes (class Foo) and exports them
(export {Foo}) separately, which was causing incomplete summary files.

This commit expands the set of symbol names for which summary exports will
be generated, fixing this issue.

PR Close #29193
2019-03-08 16:11:32 -08:00
Alex Rickabaugh 3a6ba00286 fix(ivy): escape all required characters in reexport aliases (#29194)
Previously, the compiler did not escape . or $, and this was causing issues
in google3. Now these characters are escaped.

PR Close #29194
2019-03-08 16:10:57 -08:00
Alex Rickabaugh c37ec8b255 fix(ivy): produce ts.Diagnostics for NgModule scope errors (#29191)
Previously, when the NgModule scope resolver discovered semantic errors
within a users NgModules, it would throw assertion errors. TODOs in the
codebase indicated these should become ts.Diagnostics eventually.

Besides producing better-looking errors, there is another reason to make
this change asap: these assertions were shadowing actual errors, via an
interesting mechanism:

1) a component would produce a ts.Diagnostic during its analyze() step
2) as a result, it wouldn't register component metadata with the scope
   resolver
3) the NgModule for the component references it in exports, which was
   detected as an invalid export (no metadata registering it as a
   component).
4) the resulting assertion error would crash the compiler, hiding the
   real cause of the problem (an invalid component).

This commit should mitigate this problem by converting scoping errors to
proper ts.Diagnostics. Additionally, we should consider registering some
marker indicating a class is a directive/component/pipe without actually
requiring full metadata to be produced for it, which would allow suppression
of errors like "invalid export" for such invalid types.

PR Close #29191
2019-03-08 14:21:48 -08:00
Renan Montebelo fc305305e1 docs(forms): adding `clear` method to FormArray documentation (#29180)
PR Close #29180
2019-03-08 12:39:18 -08:00
Alan b012ab210b test: add interm fix for test that rely on an index.d.ts file (#28884)
At the moment, certain tests relies on resolving the module with an index.d.ts, this root cause might be some implementations are missing from the mocks.

Similar to: 58b4045359

PR Close #28884
2019-03-08 12:36:55 -08:00
Alan 7b0e9eddd1 build: enable bundle_dts for core package (#28884)
`ng_module` will now include an `src/r3_symbol.d.ts` when compiling the core package under `ngc` togather with `dts bundling`, This is due that `ngcc` relies on this file to be present, but the `r3_symbols` file which is not part of our public api.

With this change, we can now ship an addition dts file which is flattened.

PR Close #28884
2019-03-08 12:36:55 -08:00
Kristiyan Kostadinov a746b5b1ea fix(ivy): inherited host listeners called twice (#29170)
Fixes host listeners being inherited twice when going through `setClassMetadata`.

This PR resolves FW-1142.

PR Close #29170
2019-03-08 11:57:58 -08:00
Alex Rickabaugh b6f6b1178f fix(ivy): generate type references to a default import (#29146)
This commit refactors and expands ngtsc's support for generating imports of
values from imports of types (this is used for example when importing a
class referenced in a type annotation in a constructor).

Previously, this logic handled "import {Foo} from" and "import * as foo
from" style imports, but failed on imports of default values ("import
Foo from"). This commit moves the type-to-value logic to a separate file and
expands it to cover the default import case. Doing this also required
augmenting the ImportManager to track default as well as non-default import
generation. The APIs were made a little cleaner at the same time.

PR Close #29146
2019-03-08 11:57:08 -08:00
Alex Rickabaugh 37c5a26421 perf(ivy): switch ngtsc to use single-file emit (#29147)
In the TypeScript compiler API, emit() can be performed either on a single
ts.SourceFile or on the entire ts.Program simultaneously.

ngtsc previously used whole-program emit, which was convenient to use while
spinning up the project but has a significant drawback: it causes a type
checking operation to occur for the whole program, including .d.ts files.
In large Bazel environments (such as Google's codebase), an ngtsc invocation
can have a few .ts files and thousands of .d.ts inputs. This unwanted type
checking is therefore a significant drain on performance.

This commit switches ngtsc to emit each .ts file individually, avoiding the
unwanted type checking.

PR Close #29147
2019-03-08 11:56:46 -08:00
Pete Bacon Darwin 142ac41cac fix(ivy): ngcc - handle prototype pseudo-member from typings file in ESM5 host (#29158)
When processing a JavaScript program, TS may come across a symbol that has
been imported from a TypeScript typings file.

In this case the compiler may pass the ReflectionHost a `prototype` symbol
as an export of the class.

This pseudo-member symbol has no declarations, which previously caused the
code in `Esm5ReflectionHost.reflectMembers()` to crash.

Now we just quietly ignore such a symbol and leave `Esm2015ReflectionHost`
to deal with it.

(As it happens `Esm2015ReflectionHost` also quietly ignores this symbol).

PR Close #29158
2019-03-08 09:34:20 -08:00
Renan Montebelo a68b1a1894 feat(forms): clear (remove all) components from a FormArray (#28918)
This method is a more convenient and efficient way of removing all
components from a FormArray. Before it, we needed to loop the FormArray
removing each component until empty.

Resolves #18531

PR Close #28918
2019-03-07 19:52:49 -08:00
Kara Erickson 014841dfef test(ivy): fix failing view ref test (#29178)
PR Close #29178
2019-03-07 18:56:22 -08:00
Andrew Kushnir fd5cd100a3 fix(ivy): move i18n instructions after listener ones (#29173)
Prior to this commit, i18n instructions (i18n, i18nStart) were generated before listener instructions. As a result, event listeners were attached to the wrong element (text node, not the parent element). This change updates the order of instructions and puts i18n ones after listeners, to make sure listeners are attached to the right elements.

PR Close #29173
2019-03-07 15:36:39 -08:00
Judy Bogart aa6db0d191 docs: clarify intro and examples (#29012)
PR Close #29012
2019-03-07 15:34:28 -08:00
Judy Bogart b14df413eb docs: add publicapi flag (#29012)
PR Close #29012
2019-03-07 15:34:28 -08:00
Judy Bogart 22c71b69ce docs: route interface and types doc example (#29012)
PR Close #29012
2019-03-07 15:34:28 -08:00
Keen Yee Liau f4f20daee3 refactor(bazel): Remove bazel-workspace schematics (#29148)
`bazel-workspace` schematics is no longer needed now that the Bazel
files are injected into the project by the Bazel builder.

PR Close #29148
2019-03-07 13:04:09 -08:00
Keen Yee Liau 36a1550e00 feat(bazel): Eject Bazel (#29167)
Add command line flag to expose Bazel files on disk.

`ng build --leaveBazelFilesOnDisk`

PR Close #29167
2019-03-07 13:03:44 -08:00
Pete Bacon Darwin 5ad2097be8 fix(ivy): teach template type checker about template attributes (#29041)
For the template type checking to work correctly, it needs to know
what attributes are bound to expressions or directives, which may
require expressions in the template to be evaluated in a different
scope.

In inline templates, there are attributes that are now marked as
"Template" attributes. We need to ensure that the template
type checking code looks at these "bound" attributes as well as the
"input" attributes.

PR Close #29041
2019-03-07 11:27:36 -08:00
Pete Bacon Darwin 809452b921 test(ivy): add tests for projection on inline-templates (#29041)
PR Close #29041
2019-03-07 11:27:36 -08:00
Pete Bacon Darwin f535f31d78 fix(ivy): match attribute selectors for content projection with inline-templates (#29041)
The content projection mechanism is static, in that it only looks at the static
template nodes before directives are matched and change detection is run.
When you have a selector-based content projection the selection is based
on nodes that are available in the template.

For example:

```
<ng-content selector="[some-attr]"></ng-content>
```

would match

```
<div some-attr="..."></div>
```

If you have an inline-template in your projected nodes. For example:

```
<div *ngIf="..." some-attr="..."></div>
```

This gets pre-parsed and converted to a canonical form.

For example:

```
<ng-template [ngIf]="...">
  <div some-attr=".."></div>
</ng-template>
```

Note that only structural attributes (e.g. `*ngIf`) stay with the `<ng-template>`
node. The other attributes move to the contained element inside the template.

When this happens in ivy, the ng-template content is removed
from the component template function and is compiled into its own
template function. But this means that the information about the
attributes that were on the content are lost and the projection
selection mechanism is unable to match the original
`<div *ngIf="..." some-attr>`.

This commit adds support for this in ivy. Attributes are separated into three
groups (Bindings, Templates and "other"). For inline-templates the Bindings
and "other" types are hoisted back from the contained node to the `template()`
instruction, so that they can be used in content projection matching.

PR Close #29041
2019-03-07 11:27:36 -08:00
Pete Bacon Darwin e3a401d20c refactor(ivy): define new `AttributeMarker.Template` marker (#29041)
This commit adds a new `AttributeMarker` type that will be used, in a
future commit, to mark attributes as coming from an inline-template
expansion, rather than the element that is being contained in the template.

PR Close #29041
2019-03-07 11:27:36 -08:00
Pete Bacon Darwin 423ac01dcf refactor: rename `AttributeMarker.ProjectOnly` to `AttributeMarker.Bindings` (#29041)
PR Close #29041
2019-03-07 11:27:35 -08:00
Pete Bacon Darwin c7e4931f32 fix(compiler): ensure template is updated if an output is transformed (#29041)
No idea where the tests for this code are, but it looks like this was an
oversight in the original commit 6a0f78.

PR Close #29041
2019-03-07 11:27:35 -08:00
Pete Bacon Darwin b73e02005b refactor: rename `matchingSelectorIndex` to `matchingProjectionSelectorIndex` (#29041)
The previous name was ambiguous as there are different strategies
for matching selectors depending upon the scenario.

PR Close #29041
2019-03-07 11:27:35 -08:00
Alan 9a1959269f build: remove now redundant `bundle_dts = True` attribute (#29128)
This is now turned on by default in the ng_module macro

PR Close #29128
2019-03-07 10:47:20 -08:00
Alan 941c99ad7f build: turn off dts bundling for packages that still are not supported (#29128)
PR Close #29128
2019-03-07 10:47:20 -08:00
Marc Laval eccbc785b3 fix(ivy): ViewRef.detachFromAppRef should clean the DOM (#29159)
PR Close #29159
2019-03-07 08:56:26 -08:00
Alan Agius 29f57e315e build: enable bundle_dts for router package (#28833)
This PR also changes the name of `EmptyOutletComponent` to `ɵEmptyOutletComponent`. This is because `ngcc` requires the node to retain the original name while dts bundler will rename the node is it's only exported using the aliases.

Example typings files:
```ts
declare class EmptyOutletComponent {
}
export {EmptyOutletComponent as ɵEmptyOutletComponent}
```

will be emitted as
```ts
export declare class ɵEmptyOutletComponent {
}
```

PR Close #28833
2019-03-07 07:30:44 -08:00
Keen Yee Liau 7060d9038b feat(bazel): Hide Bazel files in Bazel builder (#29110)
This commit modifies the Bazel builder to copy the Bazel WORKSPACE and
BUILD.bazel files to the project root directory before invoking Bazel.

This hides the Bazel files from users.

PR Close #29110
2019-03-06 17:35:06 -08:00
Keen Yee Liau 14ce8a9c31 fix(bazel): ng build should produce prod bundle (#29136)
`ng build` should produce a bundle that could be readily deployed to
a web server, similar to the behavior of current `ng build` with
webpack.

Note that in Bazel, there is no `ng build` for dev bundles. Instead,
users are expected to run `ts_devserver`.

Closes https://github.com/angular/angular/issues/28877

PR Close #29136
2019-03-06 16:41:25 -08:00
Alex Eagle 887faffa25 docs: cleanup contributors (#28930)
- remove individuals from @angular/* package.json, we don't keep them up-to-date
- switch keys in contributors.json to GitHub handles, seems like a better identifier and lets us grab avatar images from GitHub account
- move emeritus ppl to a new Alumni group (won't yet appear on the site)
- add "lead/mentor" keys so we know who is coordinating work
- add a script that generates an "org chart" graphic

PR Close #28930
2019-03-06 14:48:30 -08:00
Pawel Kozlowski 22ddbf4b02 fix(ivy): content projection should not corrupt TNode data structures (#29130)
PR Close #29130
2019-03-06 11:02:47 -08:00
Pawel Kozlowski 268c3fe816 test(ivy): failing test for FW-1064 (#29130)
PR Close #29130
2019-03-06 11:02:47 -08:00
Andrew Kushnir dc6192c8e5 fix(ivy): properly detect "inputs" and "outputs" field names that should be wrapped in quotes (#29126)
Prior to this change, the RegExp that was used to check for dashes in field names used "g" (global) flag that retains lastIndex, which might result in skipping some fields that should be wrapped in quotes (since lastIndex advanced beyond the next "-" location). This commit removes this flag and updates the test to make sure there are no regressions.

PR Close #29126
2019-03-06 11:01:53 -08:00
Adam Bradley 7102ea80a9 feat(platform-server): wait on returned BEFORE_APP_SERIALIZED promises (#29120)
This update gives external tooling the ability for async providers to
finish resolving before the document is serialized. This is not a
breaking change since render already returns a promise. All returned
promises from `BEFORE_APP_SERIALIZED` providers will wait to be
resolved or rejected. Any rejected promises will only console.warn().

PR Close #29120
2019-03-06 11:01:21 -08:00
Alan c5d9035bab test: fix dts path to the flattened file (#28834)
PR Close #28834
2019-03-06 10:59:18 -08:00
Alan d5a8be76f2 build: enable bundle_dts for common package (#28834)
PR Close #28834
2019-03-06 10:59:18 -08:00
Andrew Kushnir 84406e4d6d fix(ivy): avoid innerHTML usage in exports test (to make it work in IE11) (#29127)
Some tests in exports spec rely on the exact output of innerHTML. In IE11 the order of attributes might change, thus causing tests to fail (in case an element contains more than one attribute). This commit avoids innerHTML usage and performs the necessary checks via element properties.

PR Close #29127
2019-03-05 21:08:08 -08:00
Kara Erickson c29d2a4f16 test(ivy): fix export tests to work in IE (#29125)
Some of the export tests had assertions that relied on capitalization
of attributes in the DOM. IE treats capitalization somewhat differently,
so our SauceLabs tests were failing.

This commit tweaks the tests so that the assertions do not rely on
attributes to be capitalized or not.

PR Close #29125
2019-03-05 18:02:16 -08:00
Cyrille Tuzi 3bee0f684d feat(service-worker): add JSON schema for service worker config (#27859)
Fixes #19847

PR Close #27859
2019-03-05 16:48:26 -08:00
Alex Rickabaugh 881807dc36 fix(ivy): never use imported type references as values (#29111)
ngtsc occasionally converts a type reference (such as the type of a
parameter in a constructor) to a value reference (argument to a
directiveInject call). TypeScript has a bad habit of sometimes removing
the import statement associated with this type reference, because it's a
type only import when it initially looks at the file.

A solution to this is to always add an import to refer to a type position
value that's imported, and not rely on the existing import.

PR Close #29111
2019-03-05 16:47:41 -08:00
Paul Gschwendtner 20a9dbef8e ci: saucelabs-legacy job should not run schematic core tests (#29124)
With 6215799055 we introduced schematics
for `core`, but due to the fact the Saucelabs legacy job does not run
for PRs, we didn't realize that the legacy Saucelabs job ends up
running the schematic specs.

We don't want to run these schematic tests in the legacy-saucelabs job,
as these are node-only specs and the non-Bazel Karma setup is not set
up to provide the devkit schematic node modules.

We exclude the schematics folder in the `core` package in the
legacy-build tsconfig file (similar to how it is done for elements)

PR Close #29124
2019-03-05 16:10:08 -08:00
Marc Laval 25166d4f41 fix(ivy): support property values changed in ngOnChanges (forward rref case) (#29054)
PR Close #29054
2019-03-05 14:27:08 -08:00
Paul Gschwendtner 6215799055 feat(core): update schematic to migrate to explicit query timing (#28983)
Introduces an update schematic for the "@angular/core" package
that automatically migrates pre-V8 "ViewChild" and "ContentChild"
queries to the new explicit timing syntax. This is not required
yet, but with Ivy, queries will be "dynamic" by default. Therefore
specifying an explicit query timing ensures that developers can
smoothly migrate to Ivy (once it's the default).

Read more about the explicit timing API here:
https://github.com/angular/angular/pull/28810

PR Close #28983
2019-03-05 14:21:40 -08:00
Alan b446095c4d refactor: remove unused functions and classes in diagnostics (#28923)
PR Close #28923
2019-03-05 11:40:08 -08:00
Alan Agius 1efad3772e test: fix resolution to not depend on index.d.ts (#28854)
Implement `readFile` in `MockTypescriptHost` so TypeScript can resolve module based on it's resolution, since certain files are not on disk but in memory

PR Close #28854
2019-03-05 11:39:16 -08:00
Alan e8bb8f4912 build: enable bundle_dts for forms package (#28854)
This PR also changes the name of NgNoValidate` to `ɵNgNoValidate`. This is because `ngcc` requires the node to retain the original name while dts bundler will rename the node is it's only exported using the aliases.

Example typings files:
```ts
declare class NgNoValidate{
}
export {NgNoValidateas ɵNgNoValidate}
```

will be emitted as
```ts
export declare class ɵNgNoValidate {
}
```

PR Close #28854
2019-03-05 11:39:16 -08:00
WilliamKoza 7c57293bee refactor(language-service): clean up imports language-service and misspellings in public API (#29097)
PR Close #29097
2019-03-05 09:46:45 -08:00
José Toledo Navarro 3063547975 docs(router): align examples in interfaces docs (#29093)
* Use exclusively `TeamComponent` class for examples, as currently there are at least 3 different component classes being used, one of which is actually as a type argument for a `Resolve<T>` implementation.
PR Close #29093
2019-03-05 09:45:52 -08:00
Maxim Mazurok 72ecc45363 fix(router): removed obsolete TODO comment (#29085)
PR Close #29085
2019-03-05 09:44:40 -08:00
Charles Lyding 79e2ca0c0e fix(platform-server): update minimum domino version to latest released (#28893)
The version used to test and build from the root package.json is pinned to 2.1.2.  This change ensures that users will at a minimum be using the same version.

PR Close #28893
2019-03-05 09:42:32 -08:00
George Kalpakas 586234bb01 fix(service-worker): detect new version even if files are identical to an old one (#26006)
Previously, if an app version contained the same files as an older
version (e.g. making a change, then rolling it back), the SW would not
detect it as the latest version (and update clients).

This commit fixes it by adding a `timestamp` field in `ngsw.json`, which
makes each build unique (with sufficiently high probability).

Fixes #24338

PR Close #26006
2019-03-05 09:41:44 -08:00
Alex Rickabaugh 866d500324 fix(ivy): copy top-level comments into generated factory shims (#29065)
When ngtsc generates a .ngfactory shim, it does so based on the contents of
an original file in the program. Occasionally these original files have
comments at the top which are load-bearing (e.g. they contain jsdoc
annotations which are significant to downstream bundling tools). The
generated factory shims should preserve this comment.

This commit adds a step to the ngfactory generator to preserve the top-level
comment from the original source file.

FW-1006 #resolve
FW-1095 #resolve

PR Close #29065
2019-03-04 15:59:07 -08:00
Pawel Kozlowski 04cf4ef0c7 test(ivy): remove ngComponentOutlet example with a lazy-loaded NgModule (#29094)
PR Close #29094
2019-03-04 14:41:55 -08:00
Andrew Kushnir aa57bdbf90 fix(ivy): wrap "inputs" and "outputs" keys if they contain unsafe characters (#28919)
Prior to this change, keys in "inputs" and "outputs" objects generated by compiler were not checked against unsafe characters. As a result, in some cases the generated code was throwing JS error. Now we check whether a given key contains any unsafe chars and wrap it in quotes if needed.

PR Close #28919
2019-03-04 14:40:42 -08:00
Matias Niemelä 78adcfe0ee fix(ivy): ensure static styling is properly inherited into child components (#29015)
Angular supports having a component extend off of a parent component.
When this happens, all annotation-level data is inherited including styles
and classes. Up until now, Ivy only paid attention to static styling
values on the parent component and not the child component. This patch
ensures that both the parent's component and child component's styling
data is merged and rendered accordingly.

Jira Issue: FW-1081

PR Close #29015
2019-03-04 13:36:19 -08:00
George Kalpakas 48214e2a05 fix(service-worker): ignore passive mixed content requests (#25994)
Although [passive mixed content][1] requests (like images) only produce
a warning without a ServiceWorker, fetching it via a ServiceWorker
results in an error. See
https://github.com/angular/angular/issues/23012#issuecomment-376430187
for more details.

This commit makes the ServiceWorker ignore such requests and let them be
handled by the browser directly to avoid breaking apps that would work
without the ServiceWorker.

[1]: https://developers.google.com/web/fundamentals/security/prevent-mixed-content/what-is-mixed-content#passive_mixed_content

Fixes #23012

PR Close #25994
2019-03-04 11:51:05 -08:00
Judy Bogart 95989a12dd docs: fix and add decorator api doc (#28986)
PR Close #28986
2019-03-04 11:47:30 -08:00
Pawel Kozlowski c875851bb4 fix(ivy): remove query results from embedded views on view destroy (#29056)
PR Close #29056
2019-03-04 10:24:30 -08:00
Andrew Kushnir dcafddefb8 fix(ivy): change for-of to forEach for pipes represented with Map (#29068)
This commit fixes the problem with using for-of for pipes represented with Map (by replacing it with forEach operation).

PR Close #29068
2019-03-01 19:00:25 -08:00
Kristiyan Kostadinov c0757d1d44 fix(ivy): attached flag not being reset when view is destroyed (#29064)
Currently we only reset the `Attached` flag of a view if it is detached through its parent, however this means that if a root view is destroyed, its flag will never be reset. This manifested itself in one of the Material tests where we were destroying the root view.

This PR resolves FW-1130.

PR Close #29064
2019-03-01 16:56:03 -08:00
Alex Rickabaugh a06824aef6 fix(ivy): correctly evaluate enum references in template expressions (#29062)
The ngtsc partial evaluator previously would not handle an enum reference
inside a template string expression correctly. Enums are resolved to an
`EnumValue` type, which has a `resolved` property with the actual value.

When effectively toString-ing a `ResolvedValue` as part of visiting a
template expression, the partial evaluator needs to translate `EnumValue`s
to their fully resolved value, which this commit does.

PR Close #29062
2019-03-01 15:47:24 -08:00
Alex Eagle ba602dbaec build: update Bazel to 0.23 (#29058)
PR Close #29058
2019-03-01 15:24:05 -08:00
Alex Rickabaugh b1df9a30f4 fix(ivy): use the imported name of decorators for detection (#29061)
Currently, ngtsc has a bug where if you alias the name of a decorator when
importing it, it won't be detected properly. This is because the compiler
uses the aliased name and not the original, declared name of the decorator
for detection.

This commit fixes the compiler to compare against the declared name of
decorators when available, and adds a test to prevent regression.

PR Close #29061
2019-03-01 15:19:34 -08:00
Alex Rickabaugh 3e5c1bcb9f fix(ivy): track cyclic imports that are added (#29040)
ngtsc has cyclic import detection, to determine when adding an import to a
directive or pipe would create a cycle. However, this detection must also
account for already inserted imports, as it's possible for both directions
of a circular import to be inserted by Ivy (as opposed to at least one of
those edges existing in the user's program).

This commit fixes the circular import detection for components to take into
consideration already added edges. This is difficult for one critical
reason: only edges to files which will *actually* be imported should be
considered. However, that depends on which directives & pipes are used in
a given template, which is currently only known by running the
TemplateDefinitionBuilder during the 'compile' phase. This is too late; the
decision whether to use remote scoping (which consults the import graph) is
made during the 'resolve' phase, before any compilation has taken place.

Thus, the only way to correctly consider synthetic edges is for the compiler
to know exactly which directives & pipes are used in a template during
'resolve'. There are two ways to achieve this:

1) refactor `TemplateDefinitionBuilder` to do its work in two phases, with
directive matching occurring as a separate step which can be performed
earlier.

2) use the `R3TargetBinder` in the 'resolve' phase to independently bind the
template and get information about used directives.

Option 1 is ideal, but option 2 is currently used for practical reasons. The
cost of binding the template can be shared with template-typechecking.

PR Close #29040
2019-03-01 15:18:50 -08:00
Alex Rickabaugh b50283ed67 fix(ivy): support dynamic host attribute bindings (#29033)
In the @Component decorator, the 'host' field is an object which represents
host bindings. The type of this field is complex, but is generally of the
form {[key: string]: string}. Several different kinds of bindings can be
specified, depending on the structure of the key.

For example:

```
@Component({
  host: {'[prop]': 'someExpr'}
})
```

will bind an expression 'someExpr' to the property 'prop'. This is known to
be a property binding because of the square brackets in the binding key.

If the binding key is a plain string (no brackets or parentheses), then it
is known as an attribute binding. In this case, the right-hand side is not
interpreted as an expression, but is instead a constant string.

There is no actual requirement that at build time, these constant strings
are known to the compiler, but this was previously enforced as a side effect
of requiring the binding expressions for property and event bindings to be
statically known (as they need to be parsed). This commit breaks that
relationship and allows the attribute bindings to be dynamic. In the case
that they are dynamic, the references to the dynamic values are reflected
into the Ivy instructions for attribute bindings.

PR Close #29033
2019-03-01 15:18:13 -08:00
Alex Rickabaugh a23a0bc3a4 feat(ivy): support tracking the provenance of DynamicValue (#29033)
DynamicValues are generated whenever a partially evaluated expression is
unable to be resolved statically. They contain a reference to the ts.Node
which wasn't resolvable.

They can also be nested. For example, the expression 'a + b' is resolvable
only if 'a' and 'b' are themselves resolvable. If either 'a' or 'b' resolve
to a DynamicValue, the whole expression must also resolve to a DynamicValue.

Previously, if 'a' resolved to a DynamicValue, the entire expression might
have been resolved to the same DynamicValue. This correctly indicated that
the expression wasn't resolvable, but didn't return a reference to the
shallow node that couldn't be resolved (the expression 'a + b'), only a
reference to the deep node that couldn't be resolved ('a').

In certain situations, it's very useful to know the shallow unresolvable
node (for example, to use it verbatim in the output). To support this,
the partial evaluator is updated to always wrap DynamicValue to point to
each unresolvable expression as it's processed, ensuring the receiver can
determine exactly which expression node failed to resolve.

PR Close #29033
2019-03-01 15:18:13 -08:00
Kara Erickson 7ac58bec8a fix(ivy): move views that are already attached in insert() (#29047)
Currently if a user accidentally calls ViewContainerRef.insert() with
a view that has already been attached, we do not clean up the references
properly, so we create a view tree with a cycle. This causes an infinite
loop when the view is destroyed.

This PR ensures that we fall back to ViewContainerRef.move() behavior
if we try to insert a view that is already attached. This fixes the
cycle and honors the user intention.

PR Close #29047
2019-03-01 15:17:24 -08:00
Matias Niemelä ff8e4dddb2 test(animations): fix unit-based delays within the animation DSL (#28993)
Closes #24291

PR Close #28993
2019-03-01 15:16:48 -08:00
Misko Hevery f01d1c4c8d docs(ivy): add link to recursive benchmark (#29060)
PR Close #29060
2019-03-01 10:17:33 -08:00
Alan b5629d98d8 fix(bazel): api extractor don't generate tsdoc metadata (#29023)
tsdoc metadata is not needed for `ng_module` and with `@microsoft/api-extractor` version 7.0.21 there is a new flag to disable it's generation.

See: https://github.com/Microsoft/web-build-tools/issues/1051

PR Close #29023
2019-03-01 10:16:43 -08:00
Keen Yee Liau c532646f5b fix(bazel): ng serve should always watch (#29032)
PR Close #29032
2019-02-28 12:07:25 -08:00
Greg Magolan ea09430039 build: rules_nodejs 0.26.0 & use @npm instead of @ngdeps now that downstream angular build uses angular bundles (#28871)
PR Close #28871
2019-02-28 12:06:36 -08:00
Keen Yee Liau 5fdf24e843 fix(bazel): add favicon to web package (#29017)
This would fix the RESOURCE_NOT_FOUND error.

PR Close #29017
2019-02-28 10:38:00 -08:00
Rado Kirov 03d2e5cb1d refactor: Consistently use index access on index signature types. (#28937)
This change helps highlight certain misoptimizations with Closure
compiler. It is also stylistically preferable to consistently use index
access on index sig types.

Roughly, when one sees '.foo' they know it is always checked for typos
in the prop name by the type system (unless 'any'), while "['foo']" is
always not.

Once all angular repos are conforming this will become a tsetse.info
check, enforced by bazel.

PR Close #28937
2019-02-28 02:49:14 -08:00
Pete Bacon Darwin cb20b3b40a docs(compiler): correct lexer argument descriptions (#28978)
PR Close #28978
2019-02-28 02:44:19 -08:00
Pete Bacon Darwin f7c867ebc2 fix(ivy): correctly tokenize escaped characters in templates (#28978)
Previously the start of a character indicated by an escape sequence
was being incorrectly computed by the lexer, which caused tokens
to include the start of the escaped character sequence in the
preceding token. In particular this affected the name extracted
from opening tags if the name was terminated by an escape sequence.
For example, `<t\n>` would have the name `t\` rather than `t`.

This fix refactors the lexer to use a "cursor" object to iterate over
the characters in the template source. There are two cursor implementations,
one expects a simple string, the other expects a string that contains
JavaScript escape sequences that need to be unescaped.

PR Close #28978
2019-02-28 02:44:19 -08:00
Pete Bacon Darwin 76979e12c9 refactor(compiler): remove not-null operator hack from lexer (#28978)
The parts of a token are supposed to be an array of not-null strings,
but we were using `null` for tags that had no prefix. This has been
fixed to use the empty string in such cases, which allows the `null !`
hack to be removed.

PR Close #28978
2019-02-28 02:44:19 -08:00
Andrew Kushnir 772b24ccc3 fix(ivy): avoid missing imports for types that can be represented as values (#28941)
Prior to this change, TypeScript stripped out some imports in case we reference a type that can be represented as a value (for ex. classes). This fix ensures that we use correct symbol identifier, which makes TypeScript retain the necessary import statements.

PR Close #28941
2019-02-27 15:13:40 -08:00
Pawel Kozlowski 91a161aa13 refactor(ivy): simplify logic of projectable nodes insertion (#29008)
This commit removes code duplication around projectables nodes insertion.
It also simplfy the overall logic by using recursive function calls instead
of hand-unrolled stack (we can always optimise this part if needed).

PR Close #29008
2019-02-27 14:05:34 -08:00
Kristiyan Kostadinov efa10e33a9 fix(ivy): resolve forwardRef when analyzing NgModule (#28942)
Fixes forward refs not being resolved when an NgModule is being analyzed by ngtsc.

This PR resolves FW-1094.

PR Close #28942
2019-02-27 14:02:41 -08:00
Matias Niemelä a6ae759b46 fix(animations): ensure `position` and `display` styles are handled outside of keyframes/web-animations (#28911)
When web-animations and/or CSS keyframes are used for animations certain
CSS style values (such as `display` and `position`) may be ignored by a
keyframe-based animation. Angular should special-case these styles to
ensure that they get applied as inline styles throughout the duration of
the animation.

Closes #24923
Closes #25635

Jira Issue: FW-1091
Jira Issue: FW-1092

PR Close #28911
2019-02-27 11:57:31 -08:00
Alex Rickabaugh 827e89cfc4 feat(ivy): support inline <style> and <link> tags in components (#28997)
Angular supports using <style> and <link> tags inline in component
templates, but previously such tags were not implemented within the ngtsc
compiler. This commit introduces that support.

FW-1069 #resolve

PR Close #28997
2019-02-27 11:56:40 -08:00
Andrew Kushnir 40833ba54b fix(ivy): process property bindings in i18n blocks similar to non-i18n bindings (#28969)
Prior to this change i18n block bindings were converted to Expressions right away (once we first access them), when in non-i18n cases we processed them differently: the actual conversion happens at instructions generation. Because of this discrepancy, the output for bindings in i18n blocks was generated incorrectly (with invalid indicies in pipeBindN fns and invalid references to non-existent local variables). Now the bindings processing is unified and i18nExp instructions should contain right bind expressions.

PR Close #28969
2019-02-27 11:56:12 -08:00
Alan Agius 34bdebcdd2 feat(ivy): add support for windows concrete types for paths (#28752)
This commit introduces support for the windows paths in the new concrete types mechanism that was introduced in this PR https://github.com/angular/angular/pull/28523

Normalized posix paths that start with either a `/` or `C:/` are considered to be an absolute path.

Note: `C:/` is used as a reference, as other drive letters are also supported.

Fixes #28754

PR Close #28752
2019-02-27 11:27:04 -08:00
Andrew Kushnir 034de06ab1 fix(ivy): avoid duplicate i18n consts to be present in generated output (#28967)
Prior to this change, the logic that outputs i18n consts (like `const MSG_XXX = goog.getMsg(...)`) didn't have a check whether a given const that represent a certain i18n message was already included into the generated output. This commit adds the logic to mark corresponding i18n contexts after translation was generated, to avoid duplicate consts in the output.

PR Close #28967
2019-02-27 10:33:41 -08:00
George Kalpakas 2dd44d712d ci(core): fix `legacy-unit-tests-saucelabs` job (#29009)
Karma is not configured to retrieve the imported scripts using those
absolute deep paths. Using relative paths instead.
See [here][1] for an example failing job.

[1]: https://circleci.com/gh/angular/angular/220751

PR Close #29009
2019-02-27 10:32:40 -08:00
Alex Rickabaugh d127d05dc3 fix(ivy): correctly resolve shorthand property declarations (#28936)
The partial evaluator in ngtsc can handle a shorthand property declaration
in the middle evaluation, but fails if evaluation starts at the shorthand
property itself. This is because evaluation starts at the ts.Identifier
of the property (the ts.Expression representing it), not the ts.Declaration
for the property.

The fix for this is to detect in TypeScriptReflectionHost when a ts.Symbol
refers to a shorthand property, and to use the ts.TypeChecker method
getShorthandAssignmentValueSymbol() to resolve the value of the assignment
instead.

FW-1089 #resolve

PR Close #28936
2019-02-27 08:48:54 -08:00
Greg Magolan 7b944c46d3 style: format (#28995)
PR Close #28995
2019-02-27 08:47:26 -08:00
Greg Magolan c4c3c1231b build(bazel): allow a user to control a subset of angularCompilerOption in their tsconfig file when using ng_module (#28995)
PR Close #28995
2019-02-27 08:47:26 -08:00
Wassim Chegham dad5a258b8 style: enforce buildifier lint on CI (#28186)
PR Close #28186
2019-02-26 16:57:41 -08:00
Wassim Chegham ce68b4d839 style: enforce buildifier lint on CI (#28186)
PR Close #28186
2019-02-26 16:57:41 -08:00
Keen Yee Liau dc335194ab fix(bazel): Add SHA256 for rules_sass (#28994)
This will make the debugging output go away
DEBUG: Rule 'io_bazel_rules_sass' modified arguments {"sha256": "6caffb8277b3033d6b5117b77437faaa6cd3c6679d6d6c81284511225aa54711"}

PR Close #28994
2019-02-26 16:56:47 -08:00
George Kalpakas 262ba67525 fix(core): traverse and sanitize content of unsafe elements (#28804)
In the past, the sanitizer would remove unsafe elements, but still
traverse and sanitize (and potentially preserve) their content. This was
problematic in the case of `<style></style>` tags, whose content would
be converted to HTML text nodes.

In order to fix this, the sanitizer's behavior was changed in #25879 to
ignore the content of _all_ unsafe elements. While this fixed the
problem with `<style></style>` tags, it unnecessarily removed the
contents for _any_ unsafe element. This was an unneeded breaking change.

This commit partially restores the old sanitizer behavior (namely
traversing content of unsafe elements), but introduces a list of
elements whose content should not be traversed if the elements
themselves are considered unsafe. Currently, this list contains `style`,
`script` and `template`.

Related to #25879 and #26007.

Fixes #28427

PR Close #28804
2019-02-26 13:32:09 -08:00
Marc Laval dc9f0af080 fix(ivy): static host classes and styles should work on root component (#28926)
PR Close #28926
2019-02-26 13:29:36 -08:00
Marc Laval 8f8f9a6e61 fix(ivy): ngtsc should correctly bind to context in nested template with many bindings (#28982)
PR Close #28982
2019-02-26 11:54:13 -08:00
Kristiyan Kostadinov 25a2fef303 fix(ivy): ViewRef.rootNodes not including projected nodes (#28951)
Currently if an embedded view contains projected nodes, its `rootNodes` array will include `null` instead of the root nodes inside the projection slot. This manifested itself in one of the Material unit tests where we stamp out a template and then move its `rootNodes` into the overlay container.

This PR is related to FW-1087.

PR Close #28951
2019-02-26 10:49:01 -08:00
Adam Yi edb6c2d814 feat(bazel): add ts_config extending support for ng_module (#21883)
PR Close #21883
2019-02-26 02:01:37 +00:00
Misko Hevery 3cb497c6ac refactor(ivy): simplify differentiation of LView, `RNode`, `LView`, `LContainer`, `StylingContext` (#28947)
For efficiency reasons we often put several different data types (`RNode`, `LView`, `LContainer`,
`StylingContext`) in same location in `LView`. This is because we don't want to pre-allocate
space
for it because the storage is sparse. This file contains utilities for dealing with such data
types.
How do we know what is stored at a given location in `LView`.
- `Array.isArray(value) === false` => `RNode` (The normal storage value)
- `Array.isArray(value) === true` => than the `value[0]` represents the wrapped value.
  - `typeof value[TYPE] === 'object'` => `LView`
     - This happens when we have a component at a given location
  - `typeof value[TYPE] === 'number'` => `StylingContext`
     - This happens when we have style/class binding at a given location.
  - `typeof value[TYPE] === true` => `LContainer`
     - This happens when we have `LContainer` binding at a given location.
NOTE: it is assumed that `Array.isArray` and `typeof` operations are very efficient.

PR Close #28947
2019-02-26 02:01:07 +00:00
Misko Hevery bd65f58784 refactor(ivy): moved wrapped reference to 0 position in array (#28947)
`LView`, `LContainer`, `StylingContext` are all arrays which wrap either
an `HTMLElement`, `LView`, `LContainer`, `StylingContext`. It is often
necessary to retrieve the correct type of element from the location
which means that we often have to wrap the arrays. Logically it makes
more sense if the thing  which we are wrapping is at `0` location. Also
it may be more performant since data is more local which may result in
more L2 cache hits in CPU.
PR Close #28947
2019-02-26 02:01:07 +00:00
Misko Hevery 22880eae16 feat(ivy): add debug view of internal deta structures (#28945)
This change contains conditionally attached classes which provide human readable (debug) level
information for `LView`, `LContainer` and other internal data structures. These data structures
are stored internally as array which makes it very difficult during debugging to reason about the
current state of the system.

Patching the array with extra property does change the array's hidden class' but it does not
change the cost of access, therefore this patching should not have significant if any impact in
`ngDevMode` mode. (see: https://jsperf.com/array-vs-monkey-patch-array)

So instead of seeing:

```
Array(30) [Object, 659, null, …]
```

```
LViewDebug {
  views: [...],
  flags: {attached: true, ...}
  nodes: [
    {html: '<div id="123">', ..., nodes: [
      {html: '<span>', ..., nodes: null}
    ]}
  ]
}
```

PR Close #28945
2019-02-25 08:15:35 -08:00
Brandon f79cd5963e docs(core): export the `...Decorator` interfaces to ensure they are documented (#28836)
If an interface is not exported publicly from its package, then the doc-gen
does not see it, and so cannot include it in the generated documentation.

This was the case for a number of `...Decorator` interfaces, such as
`PipeDecorator` and `InputDecorator.

This commit adds these interfaces to the public export to fix this problem.

PR Close #28836
2019-02-24 12:40:02 -08:00
Alex Eagle 350802b207 build: update to latest bazel rules (#28931)
PR Close #28931
2019-02-22 17:27:09 -08:00
Filipe Silva f75acbd99b fix(compiler): use correct variable in invalid function (#28656)
Related to #26743 (but does not close it).

PR Close #28656
2019-02-22 15:06:05 -08:00
Sarun Intaralawan 395fb186a4 docs(router): reword relativeLinkResolution docs to not mention version numbers (#26991)
PR Close #26991
2019-02-22 14:35:54 -08:00
Ben Lesh c64b13e593 refactor(ivy): split util functions into different files (#28382)
Google3 detected circular references here, so splitting up this rather hodge-podge list of functions into slightly better organizational units.

PR Close #28382
2019-02-22 13:17:30 -08:00
Ben Lesh 7bae49b419 fix(ivy): assertDomNode will now work properly in a worker (#28382)
PR Close #28382
2019-02-22 13:17:30 -08:00
Ben Lesh 929fe029c2 refactor(ivy): LView is a proper linked list (#28382)
- TView no longer stores childIndex
- LView now as CHILD_HEAD and CHILD_TAIL

TView used to store the head of the list, therefor all LViews had to have the same head, which is incorrect.

PR Close #28382
2019-02-22 13:17:30 -08:00
Ben Lesh ba6aa93aa3 refactor(ivy): LContainer now stored in LView[PARENT] (#28382)
- Removes CONTAINER_INDEX
- LView[PARENT] now contains LContainer when necessary
- Removes now unused arguments to methods after refactor

PR Close #28382
2019-02-22 13:17:30 -08:00
Greg Magolan 75357ecb32 build(bazel): run a number of web tests with karma_web_test in saucelabs in CircleCI (#27721)
PR Close #27721
2019-02-22 13:07:08 -08:00
Alex Rickabaugh c1392ce618 feat(ivy): produce and consume ES2015 re-exports for NgModule re-exports (#28852)
In certain configurations (such as the g3 repository) which have lots of
small compilation units as well as strict dependency checking on generated
code, ngtsc's default strategy of directly importing directives/pipes into
components will not work. To handle these cases, an additional mode is
introduced, and is enabled when using the FileToModuleHost provided by such
compilation environments.

In this mode, when ngtsc encounters an NgModule which re-exports another
from a different file, it will re-export all the directives it contains at
the ES2015 level. The exports will have a predictable name based on the
FileToModuleHost. For example, if the host says that a directive Foo is
from the 'root/external/foo' module, ngtsc will add:

```
export {Foo as ɵng$root$external$foo$$Foo} from 'root/external/foo';
```

Consumers of the re-exported directive will then import it via this path
instead of directly from root/external/foo, preserving strict dependency
semantics.

PR Close #28852
2019-02-22 12:15:58 -08:00
Alex Rickabaugh 15c065f9a0 refactor(ivy): extract selector scope logic to a new ngtsc package (#28852)
This commit splits apart selector_scope.ts in ngtsc and extracts the logic
into two separate classes, the LocalModuleScopeRegistry and the
DtsModuleScopeResolver. The logic is cleaned up significantly and new tests
are added to verify behavior.

LocalModuleScopeRegistry implements the NgModule semantics for compilation
scopes, and handles NgModules declared in the current compilation unit.
DtsModuleScopeResolver implements simpler logic for export scopes and
handles NgModules declared in .d.ts files.

This is done in preparation for the addition of re-export logic to solve
StrictDeps issues.

PR Close #28852
2019-02-22 12:15:58 -08:00
Greg Magolan fafabc0b92 build(bazel): use http_server rule from rules_nodejs (#28905)
PR Close #28905
2019-02-22 12:14:55 -08:00
Keen Yee Liau ad4a9bf03f fix(language-service): Fix completions for input/output with alias (#28904)
This PR fixes a bug in autocompletion for @Input/@Output decorator with
an alias. The current implementation ignores the alias.

Credit for this work is attributed to @edgardmessias
The original work fixed the bug, but was lacking test.

PR Close #27959

PR Close #28904
2019-02-22 12:02:18 -08:00
Kristiyan Kostadinov 43181ea568 fix(ivy): host listeners being inherited twice (#28902)
Fixes inherited host event listeners being registered twice.

This PR resolves FW-1071.

PR Close #28902
2019-02-22 12:00:56 -08:00
Marc Laval 9dac04ff50 fix(ivy): ngOnChanges hooks should be inherited from grand-superclasses (#28888)
PR Close #28888
2019-02-22 12:00:15 -08:00
Keen Yee Liau 7f3e3a8c45 docs(bazel): Use CLI 8 for Bazel schematics (#28908)
CLI 8 (beta) is needed so that the projects pull in Angular version 8.
It will no longer build Angular from source.

PR Close #28908
2019-02-22 10:51:35 -08:00
Ben Lesh 230a941c3f refactor(ivy): remove superfluous isComponentDef function (#28880)
PR Close #28880
2019-02-22 10:04:24 -08:00
Alan c7fe3a92de build: enable bundle_dts for a upgrade package (#28642)
PR Close #28642
2019-02-21 23:56:31 -08:00
Alan 7c1b9ff5ec refactor: replace local namespaced imports with named (#28642)
At the moment, the API extractor doesn't support local namespaced imports, this will break the generation of flat dts files. When we turn on dts bundling for this package it will break. Hence this is the ground work needed for making this package compatable with the API extractor.

See: https://github.com/Microsoft/web-build-tools/issues/1029

Relates to #28588

PR Close #28642
2019-02-21 23:56:28 -08:00
Vani 65d839da03 docs(common): update docs for HttpClient methods (#26143)
PR Close #26143
2019-02-21 20:56:11 -08:00
Kristiyan Kostadinov 32ae84da28 fixup! fix(ivy): incorrectly remapping certain properties that refer to inputs (#28765)
PR Close #28765
2019-02-21 17:59:50 -08:00
Kristiyan Kostadinov 93a7836f7a fix(ivy): incorrectly remapping certain properties that refer inputs (#28765)
During build time we remap particular property bindings, because their names don't match their attribute equivalents (e.g. the property for the `for` attribute is called `htmlFor`). This breaks down if the particular element has an input that has the same name, because the property gets mapped to something invalid.

The following changes address the issue by mapping the name during runtime, because that's when directives are resolved and we know all of the inputs that are associated with a particular element.

PR Close #28765
2019-02-21 17:59:50 -08:00
Keen Yee Liau 1145bdb478 fix(bazel): Pin browsers for schematics (#28913)
PR closes https://github.com/angular/angular/issues/28724

PR Close #28913
2019-02-21 17:55:36 -08:00
Kristiyan Kostadinov e1aaa7ec48 fix(ivy): component destroy hook called twice when configured as provider (#28470)
Fixes the `ngOnDestroy` hook on a component or directive being called twice, if the type is also registered as a provider.

This PR resolves FW-1010.

PR Close #28470
2019-02-21 09:34:26 -08:00
Greg Magolan ebffde7143 build: update to rules_typescript 0.25.1 (#28625)
Updated a spot in the compiler which assumed es5 downlevelling get ready for es2015 devmode in the future.

PR Close #28625
2019-02-21 07:46:21 -08:00
Keen Yee Liau 9ae14db343 fix(bazel): rxjs_umd_modules should always be present (#28881)
This commit fixes the bug whereby `rxjs_umd_modules` would only be generated
when Sass files are used.

PR closes https://github.com/angular/angular/issues/28878

PR Close #28881
2019-02-21 00:14:14 -08:00
Andrew Kushnir 95d9aa22ef fix(ivy): allow HTML comments to be present inside <ng-content> (#28849)
Prior to this change presence of HTML comments inside <ng-content> caused compiler to throw an error that <ng-content> is not empty. Now HTML comments are not considered as a meaningful content, thus no error is thrown. This behavior is now aligned in Ivy/VE.

PR Close #28849
2019-02-21 00:13:40 -08:00
Andrew Kushnir df627e65df fix(ivy): correct absolute path processing for templateUrl and styleUrls (#28789)
Prior to this change absolute file paths (like `/a/b/c/style.css`) were calculated taking current component file location into account. As a result, absolute file paths were calculated using current file as a root. This change updates this logic to ignore current file path in case of absolute paths.

PR Close #28789
2019-02-21 00:13:12 -08:00
Andrew Kushnir 72d043f669 fix(ivy): check the presence of .css resource for styleUrls (#28770)
Prior to this change, Ivy and VE CSS resource resolution was different: in addition to specified styleUrl (with .scss, .less and .styl extensions), VE also makes an attempt to resolve resource with .css extension. This change introduces similar logic for Ivy to make sure Ivy behavior is backwards compatible.

PR Close #28770
2019-02-21 00:12:43 -08:00
Andrew Kushnir be121bba85 fix(ivy): restore @fileoverview annotations for Closure (#28723)
Prior to this change, the @fileoverview annotations added by users in source files or by tsickle during compilation might have change a location due to the fact that Ngtsc may prepend extra imports or constants. As a result, the output file is considered invalid by Closure (misplaced @fileoverview annotation). In order to resolve the problem we relocate @fileoverview annotation if we detect that its host node shifted.

PR Close #28723
2019-02-21 00:12:14 -08:00
Paul Gschwendtner 58436fd81a fix(ivy): unable to import shim factory files on case-insensitive platforms (#28831)
This change is kind of similar to #27466, but instead of ensuring that
these shims can be generated, we also need to make sure that developers
are able to also use the factory shims like with `ngc`.

This issue is now surfacing because we have various old examples which
are now also built with `ngtsc`  (due to the bazel migration). On case insensitive
platforms (e.g. windows) these examples cannot be built because ngtsc fails
the app imports a generated shim file (such as the factory shim files).

This is because the `GeneratedShimsHostWrapper` TypeScript host uses
the `getCanonicalFileName` method in order to check whether a given
file/module exists in the generator file maps. e.g.

```
// Generator Map:
'C:/users/paul/_bazel_paul/lm3s4mgv/execroot/angular/packages/core/index.ngfactory.ts' =>
'C:/users/paul/_bazel_paul/lm3s4mgv/execroot/angular/packages/core/index.ts',

// Path passed into `fileExists`
C:/users/paul/_bazel_paul/lm3s4mgv/execroot/angular/packages/core/index.ngfactory.ts

// After getCanonicalFileName (notice the **lower-case drive name**)
c:/users/paul/_bazel_paul/lm3s4mgv/execroot/angular/packages/core/index.ngfactory.ts
```

As seen above, the generator map does not use the canonical file names, as well as
TypeScript internally does not pass around canonical file names. We can fix this by removing
the manual call to `getCanonicalFileName` and just following TypeScript internal-semantics.

PR Close #28831
2019-02-20 18:26:05 -08:00
Paul Gschwendtner 3336de0970 refactor(ivy): fix typo in ngtsc "listLazyRoutes" method (#28831)
Fixes a minor typo in the `listLazyRoutes` method for `ngtsc`. Also in
addition fixes that a newly introduced test for `listLazyRoutes` broke the
tests in Windows. It's clear that we still don't run tests against
Windows, but we also made all other tests pass (without CI verification),
and it's not a big deal fixing this while being at it.

PR Close #28831
2019-02-20 18:26:05 -08:00
Paul Gschwendtner bcdd4b5729 build: run example unit tests with bazel (#28703)
With #28402 we updated the `examples` package to be
built and tested with Bazel. This PR was only intended
for the e2e integration tests, and there still seem to be
a few unit tests that need to be migrated to Bazel until
we can remove the legacy local unit tests job.

PR Close #28703
2019-02-20 16:31:48 -08:00
Matias Niemelä cfb2d176f8 feat(ivy): convert [ngStyle] and [ngClass] to use ivy styling bindings (#28711)
Prior to this fix, both the `NgStyle` and `NgClass` directives made use
of `Renderer2` and this dependency raised issues for future versions of
Angular that cannot inject it. This patch ensures that there are two
versions of both directives: one for the VE and another for Ivy.

Jira Issue: FW-882

PR Close #28711
2019-02-20 13:46:15 -08:00
Matias Niemelä d0e81eb593 feat(ivy): open up ivy_switch_mode to non-core packages (#28711)
Prior to this fix, using the compiler's ivy_switch mechanism was
only available to core packages. This patch allows for this variable
switching mechanism to work across all other angular packages.

PR Close #28711
2019-02-20 13:46:14 -08:00
Keen Yee Liau e5e4e63e71 refactor(bazel): Schematics should fetch angular from distro (#28851)
PR Close #28851
2019-02-20 09:01:44 -08:00
Keen Yee Liau 96b597cfd0 fix(bazel): Add postinstall step to generate summaries (#28850)
This commit adds a postinstall step to the package.json generated by the
schematics to generate ng summary files needed for AOT. Summary files
are not published in npm packages.

PR Close #28850
2019-02-19 22:29:27 -08:00
Alex Eagle 1eccf64b15 build: Add .bzl/BUILD files to @angular/bazel package (#28769)
It's now possible to use it as a hybrid package in latest rules_nodejs, so no WORKSPACE dep is needed

PR Close #28769
2019-02-19 17:55:57 -08:00
Keen Yee Liau 2d804198d5 fix(bazel): Schematics should upgrade rxjs to 6.4.0 (#28841)
Since rxjs is no longer built from source in Bazel schematics, the
minimum version ought to be at least 6.4.0.

This commit adds function to bump the version in package.json.

PR Close #28841
2019-02-19 16:32:15 -08:00
Alan Agius fd4e1d69ee build: enable bundle_dts for a number of packages (#28726)
This change enables dts bundling for the following packages and their secondary entry points:

- @angular/animations
- @angular/elements
- @angular/http
- @angular/platform-browser
- @angular/platform-browser-dynamic
- @angular/platform-server
- @angular/platform-webworker
- @angular/platform-webworker-dynamic
- @angular/servce-worker

Dts bundling happens in `ng_module` bazel definition, hence packages such as `@angular/compiler`, `@angular/compiler-cli` and `@angular/langauge service` cannot be flattened as they use `ts_library`.

`@angular/core`, `@angular/common`, `@angular/upgrade` and `@angular/forms` will be done seperatly as it requires some changes either to their source or specs.

PR Close #28726
2019-02-19 16:30:38 -08:00
Greg Magolan 67ad8a2632 build: move rxjs type reference to event emitter (#28720)
PR Close #28720
2019-02-19 16:28:14 -08:00
Greg Magolan 25aae64274 build(bazel): do not build rxjs from source under Bazel (#28720)
PR Close #28720
2019-02-19 16:28:14 -08:00
Kara Erickson eb39633823 test(ivy): re-enable ngIf protractor test (#28845)
We previously disabled this test because we did not yet have
static query support in Ivy and the planned API would be
slightly different. Now that a static query flag is available
that works in both View Engine and Ivy, the test has been
updated to use that flag and has been turned on to run in CI.

Since the test was always unrelated to queries and was intended
to test *ngIf behavior, updating the test in this instance
seems reasonable.

PR Close #28845
2019-02-19 16:23:57 -08:00
Jason Aden 71d0eeb966 feat(router): add hash-based navigation option to setUpLocationSync (#28609)
The `setUpLocationSync` function in @angular/router/upgrade didn't previously let you sync hash-based navigations. With this change, you can now pass an option to `setUpLocationSync` that will make sure location changes run in Angular in hash-based apps.

Fixes #24429 #21995

PR Close #28609
2019-02-19 16:20:35 -08:00
Olivier Combe ad6475ffac fix(ivy): re-create node links after creating/moving/removing nodes with i18n (#28827)
I18n can change the order of the nodes, or insert new dynamic nodes. When that happens it can break the existing links (`TNode.next`) or even create loops:
```
div1 → div2 → div3 → div4 → div5
```

Can become:
```
div1 → div4 → div2 → div3  div5
         🡑             │
         └─────────────┘
```

This PR fixes this issue by recreating the broken links between those nodes.
PR Close #28827
2019-02-19 15:54:33 -08:00
Kara Erickson 3c1a1620e3 fix(ivy): support static ContentChild queries (#28811)
This commit adds support for the `static: true` flag in `ContentChild`
queries. Prior to this commit, all `ContentChild` queries were resolved
after change detection ran. This is a problem for backwards
compatibility because View Engine also supported "static" queries which
would resolve before change detection.

Now if users add a `static: true` option, the query will be resolved in
creation mode (before change detection runs). For example:

```ts
@ContentChild(TemplateRef, {static: true}) template !: TemplateRef;
```

This feature will come in handy for components that need
to create components dynamically.

PR Close #28811
2019-02-19 15:29:01 -08:00
Kara Erickson a4638d5a81 fix(ivy): support static ViewChild queries (#28811)
This commit adds support for the `static: true` flag in
`ViewChild` queries. Prior to this commit, all `ViewChild`
queries were resolved after change detection ran. This is
a problem for backwards compatibility because View Engine
also supported "static" queries which would resolve before
change detection.

Now if users add a `static: true` option, the query will be
resolved in creation mode (before change detection runs).
For example:

```ts
@ViewChild(TemplateRef, {static: true}) template !: TemplateRef;
```

This feature will come in handy for components that need
to create components dynamically.

PR Close #28811
2019-02-19 15:29:00 -08:00
Kara Erickson 19afb791b4 feat(core): allow users to define timing of ViewChild/ContentChild queries (#28810)
Prior to this commit, the timing of `ViewChild`/`ContentChild` query
resolution depended on the results of each query. If any results
for a particular query were nested inside embedded views (e.g.
*ngIfs), that query would be resolved after change detection ran.
Otherwise, the query would be resolved as soon as nodes were created.

This inconsistency in resolution timing had the potential to cause
confusion because query results would sometimes be available in
ngOnInit, but sometimes wouldn't be available until ngAfterContentInit
or ngAfterViewInit. Code depending on a query result could suddenly
stop working as soon as an *ngIf or an *ngFor was added to the template.

With this commit, users can dictate when they want a particular
`ViewChild` or `ContentChild` query to be resolved with the `static`
flag. For example, one can mark a particular query as `static: false`
to ensure change detection always runs before its results are set:

```ts
@ContentChild('foo', {static: false}) foo !: ElementRef;
```

This means that even if there isn't a query result wrapped in an
*ngIf or an *ngFor now, adding one to the template later won't change
the timing of the query resolution and potentially break your component.

Similarly, if you know that your query needs to be resolved earlier
(e.g. you need results in an ngOnInit hook), you can mark it as
`static: true`.

```ts
@ViewChild(TemplateRef, {static: true}) foo !: TemplateRef;
```

Note: this means that your component will not support *ngIf results.

If you do not supply a `static` option when creating your `ViewChild` or
`ContentChild` query, the default query resolution timing will kick in.

Note: This new option only applies to `ViewChild` and `ContentChild`
queries, not `ViewChildren` or `ContentChildren` queries, as those types
already resolve after CD runs.

PR Close #28810
2019-02-19 12:56:25 -08:00
Trevor Karjanis 5e68e35112 docs(platform-browser): fix a grammatical error in the BrowserModule documentation (#28808)
The browser module is not included by defaults, it is included by default. Default should be singular.

There is no associated issue.
PR Close #28808
2019-02-19 12:54:52 -08:00
George Kalpakas 745c9c5ca7 build(compiler-cli): upgrade chokidar to latest version (#28797)
Fixes #28771

PR Close #28797
2019-02-19 12:54:11 -08:00
Paul Gschwendtner 4131715df5 fix(compiler-cli): incorrect bundled metadata for static class member call expressions (#28762)
Currently if developers use call expressions in their static
class members ([like we do in Angular](https://github.com/angular/angular/blob/master/packages/core/src/change_detection/differs/keyvalue_differs.ts#L121)),
the metadata that is generated for flat modules is invalid. This
is because the metadata bundler logic currently does not handle
call expressions in static class members and the symbol references
are not rewritten to avoid relative paths in the bundle.

Static class members using a call expression are not relevant for
the ViewEngine AOT compilation, but it is problematic that the
bundled metadata references modules using their original relative
path. This means that the bundled metadata is no longer encapsulated
and depends on other emitted files to be emitted in the proper place.

These incorrect relative paths can now cause issues where NGC
looks for the referenced symbols in the incorrect path. e.g.

```
src/
 | lib/
    | index.ts -> References the call expression using `../../di`
```

Now the metadata looks like that:

```
node_modules/
  | @angular/
  -- | core/
  -- -- | core.metadata.json -> Says that the call expr. is in `../../di`.
  | di/
```

Now if NGC tries to use the metadata files and create the summary files,
NGC resolves the call expression to the `node_modules/di` module. Since
the "unexpected" module does not contain the desired symbol, NGC will
error out.

We should fix this by ensuring that we don't ship corrupted metadata
to NPM which contains relative references that can cause such
failures (other imports can be affected as well; it depends on what
modules the developer has installed and how we import our call
expressions).

Fixes #28741.

PR Close #28762
2019-02-19 12:53:18 -08:00
Pawel Kozlowski 692ddfcbb5 fix(ivy): allign DebugNode.componentInstance semantics with view engine (#28756)
PR Close #28756
2019-02-19 12:51:47 -08:00
Filipe Silva 1923c2f99c feat(compiler-cli): make enableIvy ngtsc/true equivalent (#28616)
Currently setting `enableIvy` to true runs a hybrid mode of `ngc` and `ngtsc`. This is counterintuitive given the name of the flag itself.

This PR makes the `true` value equivalent to the previous `ngtsc`, and `ngtsc` becomes an alias for `true`. Effectively this removes the hybrid mode as well since there's no other way to enable it.

PR Close #28616
2019-02-19 12:28:44 -08:00
George Kalpakas 6b511a33f6 fix(ivy): fix class inheritance detection for ES5 code in `ngtsc` (#28773)
Previously, `ngtsc` detected class inheritance in a way that only worked
in TS or ES2015 code. As a result, inheritance would not be detected for
code in ES5 format, such as when running `ngtsc` through `ngcc` to
transform old-style Angular code to ivy format.

This commit fixes it by delegating class inheritance detection to the
current `ReflectionHost`, which is able to correctly interpret the used
code format.

PR Close #28773
2019-02-16 21:00:50 -08:00
Kara Erickson 911599d9a3 test(ivy): mark unknown binding test modifiedInIvy (#28740)
This commit turns off an unknown binding test that is specific
to the View Engine implementation. In Ivy, we do property validation
at runtime for jit, so this test does not apply.

PR Close #28740
2019-02-16 20:58:25 -08:00
Pawel Kozlowski c1094cf46f refactor(ivy): remove duplicated getRootView function (#28732)
PR Close #28732
2019-02-16 20:58:01 -08:00
Cody Schroeder 2e3cc45c74 build(bazel): specify tsconfig-test dependency (#28696)
PR Close #28696
2019-02-16 20:57:34 -08:00
Vani 8accc98d28 docs: incorporate review feedback (#26827)
PR Close #26827
2019-02-14 19:33:14 +00:00
Vani aa8d0809d3 docs: update HttpInterceptor API docs (#26827)
PR Close #26827
2019-02-14 19:33:14 +00:00
Kristiyan Kostadinov 80a5934af6 fix(ivy): support schemas at runtime (#28637)
Accounts for schemas in when validating properties in Ivy.

This PR resolves FW-819.

A couple of notes:
* I had to rework the test slightly, in order to have it fail when we expect it to. The one in master is passing since Ivy's validation runs during the update phase, rather than creation.
* I had to deviate from the design in FW-819 and not add an `enableSchema` instruction, because the schema is part of the `NgModule` scope, however the scope is only assigned to a component once all of the module's declarations have been resolved and some of them can be async. Instead, I opted to have the `schemas` on the component definition.

PR Close #28637
2019-02-14 19:31:51 +00:00
Paul Gschwendtner 7cbc36fdac build: remove unused rollup.config.js files (#28646)
Since we build and publish the individual packages
using Bazel and `build.sh` has been removed, we can
safely remove the `rollup.config.js` files which are no
longer needed because the `ng_package` bazel rule
automatically handles the rollup settings and globals.

PR Close #28646
2019-02-14 19:28:08 +00:00
Kristiyan Kostadinov 63e5d2787b fix(ivy): rethrow event handler errors in tests (#28707)
Currently errors thrown inside event handler in Ivy are caught and forwarded to the `ErrorHandler`, however this means that if they happen during a unit test, the test won't fail. These changes add a test-specific `ErrorHandler` that throws the error rather than logging it out.

PR Close #28707
2019-02-14 19:26:56 +00:00
Jeremy Elbourn 83fd66d1d0 fix(ivy): DebugNode should read styles from StylingContext (#28709)
Previously `DebugNode.classes` and `DebugNode.styles` mistakenly used an
object that is only *sometimes* a `StylingContext`. Also fixes a mistake
in `debug_node_spec.ts` where a test component was not declared in the
testing module.

There is still a bug here where `DebugNode` is not exposing *static*
values. This will need to be fixed in a follow up.

PR Close #28709
2019-02-14 19:24:17 +00:00
Matias Niemelä 627cecdfe2 fix(ivy): ensure host bindings and host styling works on a root component (#28664)
Prior to this fix if a root component was instantiated it create host
bindings, but never render them once update mode ran unless one or more
slot-allocated bindings were issued. Since styling in Ivy does not make
use of LView slots, the host bindings function never ran on the root
component.

This fix ensures that the `hostBindings` function does run for a root
component and also renders the schedlued styling instructions when
executed.

Jira Issue: FW-1062

PR Close #28664
2019-02-14 19:23:25 +00:00
Keen Yee Liau 65c2deacbb refactor(bazel): Fix warning about overridden tsconfig options (#28674)
Under Bazel, some compilerOptions in tsconfig.json are controlled by
downstream rules. The default tsconfig.json causes Bazel to print out
warnings about overriden settings.

This commit makes a backup of the original tsconfig.json and removes
tsconfig settings that are controlled by Bazel.

As part of this fix, JsonAst utils are refactored into separate package
and unit tests are added.

PR closes https://github.com/angular/angular/issues/28034

PR Close #28674
2019-02-13 21:24:19 -08:00
Pawel Kozlowski b0afc4c638 refactor(ivy): remove unused constructor argument (#28677)
PR Close #28677
2019-02-13 19:18:02 -08:00
Artem Lanovyy 1df3aefb81 fix(forms): mark form as pristine before emitting value and status change events (#28395)
BREAKING CHANGE

Previous to this change, when a control was reset, value and status change
events would be emitted before the control was reset to pristine. As a
result, if one were to check a control's pristine state in a valueChange
listener, it would appear that the control was still dirty after reset.

This change delays emission of value and status change events until after
controls have been marked pristine. This means the pristine state will be
reset as expected if one checks in a listener.

Theoretically, there could be applications depending on checking whether a
control *used to be dirty*, so this is marked as breaking. In these cases,
apps should cache the state on the app side before calling reset.

Fixes #28130

PR Close #28395
2019-02-13 19:17:35 -08:00
Alex Eagle 8cec4b3ff7 build: make api-extractor work in google3 (#28588)
PR Close #28588
2019-02-13 19:16:29 -08:00
Alan Agius 9e5d1357fe build: update `@microsoft/api-extractor` to `7.0.17` (#28588)
This fixes one of the problems that we reported https://github.com/Microsoft/web-build-tools/issues/1048

PR Close #28588
2019-02-13 19:16:29 -08:00
Alan Agius 3bb3d6d3e6 test: update ng_package tests to use bundle_dts (#28588)
PR Close #28588
2019-02-13 19:16:29 -08:00
Alan Agius 3d39100c85 feat(bazel): add dts bundler as action to ng_module (#28588)
This enabled dts flattening in the final distrubutable package.

Notes:
 - For the time being this is an opt-in feature via the `ng_module` attribute  `bundle_dts`, however in the near future this will be turned on by default.
 - This only supports the legacy compiler `ngc`, as `ngtsc` emits namespaced imports `import * as __` from local modules which is not supported for the time being by API Extractor. See: https://github.com/Microsoft/web-build-tools/issues/1029

Ref: TOOL-611

PR Close #28588
2019-02-13 19:16:29 -08:00
Marc Laval 3842dd6a6d fix(ivy): OnChanges should support updating one Input among many (#28693)
PR Close #28693
2019-02-13 19:15:44 -08:00
Alberto Garza 36df9056af docs(animations): fixed some grammar (#28708)
PR Close #28708
2019-02-13 19:14:57 -08:00
Alex Rickabaugh 423b39e216 feat(ivy): use fileNameToModuleName to emit imports when it's available (#28523)
The ultimate goal of this commit is to make use of fileNameToModuleName to
get the module specifier to use when generating an import, when that API is
available in the CompilerHost that ngtsc is created with.

As part of getting there, the way in which ngtsc tracks references and
generates import module specifiers is refactored considerably. References
are tracked with the Reference class, and previously ngtsc had several
different kinds of Reference. An AbsoluteReference represented a declaration
which needed to be imported via an absolute module specifier tracked in the
AbsoluteReference, and a RelativeReference represented a declaration from
the local program, imported via relative path or referred to directly by
identifier if possible. Thus, how to refer to a particular declaration was
encoded into the Reference type _at the time of creation of the Reference_.

This commit refactors that logic and reduces Reference to a single class
with no subclasses. A Reference represents a node being referenced, plus
context about how the node was located. This context includes a
"bestGuessOwningModule", the compiler's best guess at which absolute
module specifier has defined this reference. For example, if the compiler
arrives at the declaration of CommonModule via an import to @angular/common,
then any references obtained from CommonModule (e.g. NgIf) will also be
considered to be owned by @angular/common.

A ReferenceEmitter class and accompanying ReferenceEmitStrategy interface
are introduced. To produce an Expression referring to a given Reference'd
node, the ReferenceEmitter consults a sequence of ReferenceEmitStrategy
implementations.

Several different strategies are defined:

- LocalIdentifierStrategy: use local ts.Identifiers if available.
- AbsoluteModuleStrategy: if the Reference has a bestGuessOwningModule,
  import the node via an absolute import from that module specifier.
- LogicalProjectStrategy: if the Reference is in the logical project
  (is under the project rootDirs), import the node via a relative import.
- FileToModuleStrategy: use a FileToModuleHost to generate the module
  specifier by which to import the node.

Depending on the availability of fileNameToModuleName in the CompilerHost,
then, a different collection of these strategies is used for compilation.

PR Close #28523
2019-02-13 19:13:11 -08:00
Alex Rickabaugh a529f53031 feat(ivy): introduce concrete types for paths in ngtsc (#28523)
This commit introduces a new ngtsc sub-library, 'path', which contains
branded string types for the different kind of paths that ngtsc manipulates.
Having static types for these paths will reduce the number of path-related
bugs (especially on Windows) and will eliminate unnecessary defensive
normalizing.

See the README.md file for more detail.

PR Close #28523
2019-02-13 19:13:11 -08:00
Alex Rickabaugh 99d8582882 feat(ivy): support @Injectable on already decorated classes (#28523)
Previously, ngtsc would throw an error if two decorators were matched on
the same class simultaneously. However, @Injectable is a special case, and
it appears frequently on component, directive, and pipe classes. For pipes
in particular, it's a common pattern to treat the pipe class also as an
injectable service.

ngtsc actually lacked the capability to compile multiple matching
decorators on a class, so this commit adds support for that. Decorator
handlers (and thus the decorators they match) are classified into three
categories: PRIMARY, SHARED, and WEAK.

PRIMARY handlers compile decorators that cannot coexist with other primary
decorators. The handlers for Component, Directive, Pipe, and NgModule are
marked as PRIMARY. A class may only have one decorator from this group.

SHARED handlers compile decorators that can coexist with others. Injectable
is the only decorator in this category, meaning it's valid to put an
@Injectable decorator on a previously decorated class.

WEAK handlers behave like SHARED, but are dropped if any non-WEAK handler
matches a class. The handler which compiles ngBaseDef is WEAK, since
ngBaseDef is only needed if a class doesn't otherwise have a decorator.

Tests are added to validate that @Injectable can coexist with the other
decorators and that an error is generated when mixing the primaries.

PR Close #28523
2019-02-13 19:13:10 -08:00
Alex Rickabaugh d2742cf473 feat(ivy): compile @Injectable on classes not meant for DI (#28523)
In the past, @Injectable had no side effects and existing Angular code is
therefore littered with @Injectable usage on classes which are not intended
to be injected.

A common example is:

@Injectable()
class Foo {
  constructor(private notInjectable: string) {}
}

and somewhere else:

providers: [{provide: Foo, useFactory: ...})

Here, there is no need for Foo to be injectable - indeed, it's impossible
for the DI system to create an instance of it, as it has a non-injectable
constructor. The provider configures a factory for the DI system to be
able to create instances of Foo.

Adding @Injectable in Ivy signifies that the class's own constructor, and
not a provider, determines how the class will be created.

This commit adds logic to compile classes which are marked with @Injectable
but are otherwise not injectable, and create an ngInjectableDef field with
a factory function that throws an error. This way, existing code in the wild
continues to compile, but if someone attempts to use the injectable it will
fail with a useful error message.

In the case where strictInjectionParameters is set to true, a compile-time
error is thrown instead of the runtime error, as ngtsc has enough
information to determine when injection couldn't possibly be valid.

PR Close #28523
2019-02-13 19:13:10 -08:00
Alex Rickabaugh f8b67712bc fix(ivy): translate WriteKeyExpr expressions properly (#28523)
Translation of WriteKeyExpr expressions was not implemented in the ngtsc
expression translator. This resulted in binding expressions like
"target[key] = $event" not compiling.

This commit fixes the bug by implementing WriteKeyExpr translation.

PR Close #28523
2019-02-13 19:13:10 -08:00
Alex Rickabaugh 3477610f6d fix(ivy): resolve enum values in host bindings (#28523)
Some applications use enum values in their host bindings:

@Component({
  host: {
    '[prop]': EnumType.Key,
  }, ...
})

This commit changes the resolution of host properties to follow the enum
declaration and extract the correct value for the binding.

PR Close #28523
2019-02-13 19:13:10 -08:00
Alex Rickabaugh 09af7ea4f5 fix(compiler): fix two existing expression transformer issues (#28523)
Testing of Ivy revealed two bugs in the AstMemoryEfficientTransformer
class, a part of existing View Engine compiler infrastructure that's
reused in Ivy. These bugs cause AST expressions not to be transformed
under certain circumstances.

The fix is simple, and tests are added to ensure the specific expression
forms that trigger the issue compile properly under Ivy.

PR Close #28523
2019-02-13 19:13:10 -08:00
Greg Magolan 28bdeeef3e build(bazel): update to rules_nodejs 0.18.6 (#28699)
PR Close #28699
2019-02-13 12:13:08 -08:00
Pawel Kozlowski 6d057cc05d fix(ivy): should mark OnPush ancestor of dynamically created views as dirty (#28687)
While marking a given views tree as dirty we should go all the way to the
root of the views tree and cross boundaries of dynamically inserted views.
In other words the markForCheck functionality should consider parents of
dynamically inserted views.

PR Close #28687
2019-02-13 12:12:45 -08:00
Pawel Kozlowski 2f27a8051b test(ivy): ivy change detection doesn't descend into CD-detached view trees (#28680)
PR Close #28680
2019-02-13 12:12:26 -08:00
Trotyl Yu 77eee42963 fix(core): improve global variable detection (#28679)
Closes #16545

PR Close #28679
2019-02-13 12:05:41 -08:00
Andrew Kushnir 553f80ff46 fix(ivy): set proper implementation for module injector (#28667)
Prior to this change we used current injector implementation for module injector, which was causing problems and produces circular dependencies in case the same token is referenced (with @SkipSelf flag) in the `deps` array. The origin of the problem was that once `directiveInject` implementation becomes active, it was used for module injector as well, thus searching deps in Component/Directive DI scope. This fix sets `injectInjectorOnly` implementation for module injector to resolve the problem.

PR Close #28667
2019-02-13 12:05:13 -08:00
Andrew Kushnir 39d0311e4e refactor(ivy): combine contentQueries and contentQueriesRefresh functions (#28503)
Prior to this update we had separate contentQueries and contentQueriesRefresh functions to handle creation and update phases. This approach was inconsistent with View Queries, Host Bindings and Template functions that we generate for Component/Directive defs. Now the mentioned 2 functions are combines into one (contentQueries), creation and update logic is separated with RenderFlags (similar to what we have in other generated functions).

PR Close #28503
2019-02-13 12:01:32 -08:00
Judy Bogart 644e7a28d8 docs: add di-related api doc (#27731)
PR Close #27731
2019-02-13 11:57:37 -08:00
Keen Yee Liau 2ea030c2c5 fix(bazel): Turn on strict action env (#28675)
This commit fixes a bug whereby recompilation occurs every time `yarn ng build`
or `yarn bazel build ...` is invoked.

This is a temporary solution until # https://github.com/bazelbuild/bazel/issues/7026
is fixed.

PR Close #28675
2019-02-13 09:52:51 -08:00
Keen Yee Liau 49fb8c3cb0 fix(bazel): Install angular repo before yarn_install (#28670)
PR closes https://github.com/angular/angular/issues/28636

PR Close #28670
2019-02-13 09:52:30 -08:00
Keen Yee Liau 0c7581da89 refactor(bazel): use multi_sass_binary rule (#28669)
`multi_sass_binary` rules is reinstated in rules_sass v1.17.0
and it is a better solution than list comprehension currently used
because it handles imports correctly.

PR Close #28669
2019-02-13 09:52:10 -08:00
JoostK 06ec95f2ef fix(ivy): allow directive inheritance in strict mode (#28634)
For TypeScript compilation units that have the "strictFunctionTypes"
option enabled, an error would be produced for Ivy's definition fields
in declaration files in the case of inheritance across directives or
pipes.

This change loosens the definition types to allow for subtypes of the
defined type where necessary.

A test package that has the "strict" option enabled verifies that we
won't regress in environments where strict type checking is enabled.

Fixes #28079

PR Close #28634
2019-02-13 09:50:15 -08:00
Paul Gschwendtner 91b7152852 feat(compiler-cli): no longer re-export external symbols by default (#28633)
With #28594 we refactored the `@angular/compiler` slightly to
allow opting out from external symbol re-exports which are
enabled by default.

Since symbol re-exports only benefit projects which have a
very strict dependency enforcement, external symbols should
not be re-exported by default as this could grow the size of
factory files and cause unexpected behavior with Angular's
AOT symbol resolving (e.g. see: #25644).

Note that the common strict dependency enforcement for source
files does still work with external symbol re-exports disabled,
but there are also strict dependency checks that enforce strict
module dependencies also for _generated files_ (such as the
ngfactory files). This is how Google3 manages it's dependencies
and therefore external symbol re-exports need to be enabled within
Google3.

Also "ngtsc" also does not provide any way of using external symbol
re-exports, so this means that with this change, NGC can partially
match the behavior of "ngtsc" then (unless explicitly opted-out).

As mentioned before, internally at Google symbol re-exports need to
be still enabled, so the `ng_module` Bazel rule will enable the symbol
re-exports by default when running within Blaze.

Fixes #25644.

PR Close #28633
2019-02-13 09:49:51 -08:00
cexbrayat fc8f4f8029 refactor(ivy): remove unused parameter in postProcessBaseDirective (#28631)
https://github.com/angular/angular/pull/28089/files#diff-ce885db4223480bd4f7b78bd22b6f058L1650 removed the use of `def` in `postProcessBaseDirective`, making the parameter now useless.

PR Close #28631
2019-02-13 09:49:28 -08:00
JoostK 2afc40608d fix(ivy): support injecting ChangeDetectorRef on templates (#27565)
Previously, using a pipe in an input binding on an ng-template would
evaluate the pipe in the context of node that was processed before the
template. This caused the retrieval of e.g. ChangeDetectorRef to be
incorrect, resulting in one of the following bugs depending on the
template's structure:

1. If the template was at the root of a view, the previously processed
node would be the component's host node outside of the current view.
Accessing that node in the context of the current view results in a crash.
2. For templates not at the root, the ChangeDetectorRef injected into the
pipe would correspond with the previously processed node. If that node
hosts a component, the ChangeDetectorRef would not correspond with the
view that the ng-template is part of.

The solution to the above problem is two-fold:

1. Template compilation is adjusted such that the template instruction
is emitted before any instructions produced by input bindings, such as
pipes. This ensures that pipes are evaluated in the context of the
template's container node.
2. A ChangeDetectorRef can be requested for container nodes.

Fixes #28587

PR Close #27565
2019-02-13 09:46:53 -08:00
cexbrayat ac58d01a8e refactor(ivy): remove unused notImplement function (#28630)
It has not been used since #27387 implemented the last missing methods in DebugNode

PR Close #28630
2019-02-12 21:56:09 -08:00
Pete Bacon Darwin d68a98f0cd test(ivy): add template source mapping tests (#28055)
PR Close #28055
2019-02-12 20:58:28 -08:00
Pete Bacon Darwin 08de52b9f0 feat(ivy): add source mappings to compiled Angular templates (#28055)
During analysis, the `ComponentDecoratorHandler` passes the component
template to the `parseTemplate()` function. Previously, there was little or
no information about the original source file, where the template is found,
passed when calling this function.

Now, we correctly compute the URL of the source of the template, both
for external `templateUrl` and in-line `template` cases. Further in the
in-line template case we compute the character range of the template
in its containing source file; *but only in the case that the template is
a simple string literal*. If the template is actually a dynamic value like
an interpolated string or a function call, then we do not try to add the
originating source file information.

The translator that converts Ivy AST nodes to TypeScript now adds these
template specific source mappings, which account for the file where
the template was found, to the templates to support stepping through the
template creation and update code when debugging an Angular application.

Note that some versions of TypeScript have a bug which means they cannot
support external template source-maps. We check for this via the
`canSourceMapExternalTemplates()` helper function and avoid trying to
add template mappings to external templates if not supported.

PR Close #28055
2019-02-12 20:58:28 -08:00
Pete Bacon Darwin cffd86260a fix(compiler): ensure that event handlers have the correct source spans (#28055)
When template bindings are being parsed the event handlers
were receiving a source span that included the whole attribute.

Now they get a span that is focussed on the handler itself.

PR Close #28055
2019-02-12 20:58:28 -08:00
Pete Bacon Darwin 497619f25d refactor(compiler): capture `sourceSpan` when converting action bindings to output AST (#28055)
The `convertActionBinding()` now accepts an optional `baseSourceSpan`,
which is the start point of the action expression being converted in the
original source code.  This is used to compute the original position of
the output AST nodes.

PR Close #28055
2019-02-12 20:58:28 -08:00
Pete Bacon Darwin c0dac184cd fix(compiler): markup lexer should not capture quotes in attribute value (#28055)
When tokenizing markup (e.g. HTML) element attributes
can have quoted or unquoted values (e.g. `a=b` or `a="b"`).
The `ATTR_VALUE` tokens were capturing the quotes, which
was inconsistent and also affected source-mapping.

Now the tokenizer captures additional `ATTR_QUOTE` tokens,
which the HTML related parsers understand and factor into their
token parsing.

PR Close #28055
2019-02-12 20:58:27 -08:00
Pete Bacon Darwin e6a00be014 test(core): update JIT source mapping tests for ivy (#28055)
There are some differences in how ivy maps template source
compared to View Engine.  In this commit we recreate the View Engine
tests for ivy.

PR Close #28055
2019-02-12 20:58:27 -08:00
Pete Bacon Darwin 4f46bfb779 fix(core): use the correct generated URL for JIT compiled components (#28055)
Previously the generated code was being mapped to the `templateUrl`
value.

PR Close #28055
2019-02-12 20:58:27 -08:00
Pete Bacon Darwin a5ea55a636 fix(core): use the correct template URL in render3 JIT compilation (#28055)
Previously JIT compiled components did not use the correct URL if
the template was resolved from a `templateUrl`.

PR Close #28055
2019-02-12 20:58:27 -08:00
Pete Bacon Darwin 0d6fdec4bd fix(compiler): support `sourceMappingURL` comments that have trailing lines (#28055)
Previously the call to `extractSourceMap()` would only work if the
`//#sourceMappingURL ...` was the last line of the file. This doesn't
work if the code is JIT evaluated as the comment is actually the last
line in the body of a function, wrapped by curly-braces.

PR Close #28055
2019-02-12 20:58:27 -08:00
Pete Bacon Darwin 54ca24b47d refactor(compiler): wrap the jit evaluation in an injectable class (#28055)
When testing JIT code, it is useful to be able to access the
generated JIT source. Previously this is done by spying on the
global `Function` object, to capture the code when it is being
evaluated. This is problematic because you can only capture
the body of the function, and not the arguments, which messes
up line and column positions for source mapping for instance.

Now the code that generates and then evaluates JIT code is
wrapped in a `JitEvaluator` class, making it possible to provide
a mock implementation that can capture the generated source of
the function passed to `executeFunction(fn: Function, args: any[])`.

PR Close #28055
2019-02-12 20:58:27 -08:00
Pete Bacon Darwin 8c3f1717a8 refactor(core): do not remove `templateUrl` when resolving (#28055)
When we resolve a component `templateUrl` we copy the contents of the
resolved template file into the `template` property.

Previously we would then remove the `templateUrl` to indicate that
the component has been resolved. But this meant that we no longer had
access to the URL of the original template file. This is essential for
diagnostics messages about the template compilation.

Now the existence of the `template` property overrides the existence of
`templateUrl`, which allows us to keep the `templateUrl` property.

PR Close #28055
2019-02-12 20:58:27 -08:00
Pete Bacon Darwin 8d15dd8b70 docs(core): tidy up the description of `resolveComponentResources()` (#28055)
There were a number of typos and some of the sentences did not
read well.

PR Close #28055
2019-02-12 20:58:27 -08:00
Pete Bacon Darwin 2424184d42 feat(compiler): support tokenizing escaped strings (#28055)
In order to support source mapping of templates, we need
to be able to tokenize the template in its original context.
When the template is defined inline as a JavaScript string
in a TS/JS source file, the tokenizer must be able to handle
string escape sequences, such as `\n` and `\"` as they
appear in the original source file.

This commit teaches the lexer how to unescape these
sequences, but only when the `escapedString` option is
set to true.  Otherwise there is no change to the tokenizing
behaviour.

PR Close #28055
2019-02-12 20:58:27 -08:00
Pete Bacon Darwin eeb560ac88 feat(compiler): support tokenizing a sub-section of an input string (#28055)
The lexer that does the tokenizing can now process only a part the source
string, by passing a `range` property in the `options` argument. The
locations of the nodes that are tokenized will now take into account the
position of the span in the context of the original source string.

This `range` option is, in turn, exposed from the template parser as well.

Being able to process parts of files helps to enable SourceMap support
when compiling inline component templates.

PR Close #28055
2019-02-12 20:58:27 -08:00
Pete Bacon Darwin 1b0580a9ec refactor(compiler): remove unnecessary `!` operators from lexer (#28055)
When we added the strict null checks, the lexer had some `!`
operators added to prevent the compilation from failing.

This commit resolves this problem correctly and removes the
hacks.

Also the comment

```
// Note: this is always lowercase!
```

has been removed as it is no longer true.

See #24571

PR Close #28055
2019-02-12 20:58:27 -08:00
Pete Bacon Darwin 673ac2945c refactor(compiler): use `options` argument for parsers (#28055)
This commit consolidates the options that can modify the
parsing of text (e.g. HTML, Angular templates, CSS, i18n)
into an AST for further processing into a single `options`
hash.

This makes the code cleaner and more readable, but also
enables us to support further options to parsing without
triggering wide ranging changes to code that should not
be affected by these new options.  Specifically, it will let
us pass information about the placement of a template
that is being parsed in its containing file, which is essential
for accurate SourceMap processing.

PR Close #28055
2019-02-12 20:58:27 -08:00
Andrew Kushnir 0cb02d906e fix(ivy): mark query test as modified in Ivy (#28660)
Due to the fact that host nodes no longer match in ContentChild queries in Ivy, we disable test that was enabled previously in other commit.

PR Close #28660
2019-02-12 10:34:53 -08:00
George Kalpakas cdabda1fc0 test(ivy): test listing lazy routes to different root directories (#28542)
PR Close #28542
2019-02-11 16:23:30 -08:00
George Kalpakas 188f20fb16 fix(ivy): support listing lazy route for project-root-relative entry point in `ngtsc` (#28542)
I don't know of any use of this API with a project-root-relative path
(i.e. the cli will always call it with an absolute path), but keeping
the API backwards compatible just in case.

PR Close #28542
2019-02-11 16:23:30 -08:00
George Kalpakas 3eec314ba9 test(ivy): fix `ngtools_api` test under ivy (#28542)
PR Close #28542
2019-02-11 16:23:29 -08:00
George Kalpakas e6c51b3e06 feat(ivy): implement listing lazy routes for specific entry point in `ngtsc` (#28542)
Related: angular/angular-cli#13532

Jira issue: FW-860

PR Close #28542
2019-02-11 16:23:29 -08:00
George Kalpakas f358188ec1 refactor(ivy): create lazy route keys that are similar to ngtools lazy routes (#28542)
This will make it easier to retrieve routes for specific entry points in
`listLazyRoutes()` (which is necessary for CLI integration but not yet
implemented).

PR Close #28542
2019-02-11 16:23:29 -08:00
George Kalpakas 5db3a6b198 refactor(ivy): remove unnecessary method from ngtsc's `RouterEntryPoint` (#28542)
PR Close #28542
2019-02-11 16:23:29 -08:00
Marc Laval 94b8aaeba8 fix(ivy): ngOnChanges should be inherited from super class (#28563)
PR Close #28563
2019-02-11 16:22:31 -08:00
Matias Niemelä fe8301c462 feat(ivy): provide support for map-based host bindings for [style] and [class] (#28246)
Up until now, `[style]` and `[class]` bindings (the map-based ones) have only
worked as template bindings and have not been supported at all inside of host
bindings. This patch ensures that multiple host binding sources (components and
directives) all properly assign style values and merge them correctly in terms
of priority.

Jira: FW-882

PR Close #28246
2019-02-11 16:21:19 -08:00
Pawel Kozlowski e5861e1c79 fix(ivy): support checkNoChanges on embedded views (#28644)
Before this fix our ViewRef implementation assumed that checkNoChanges can be
only called on component views. In reality checkNoChanges can be also called on
embedded views (ex.: when an embedded view is attached to ApplicationRef).

PR Close #28644
2019-02-11 14:52:32 -08:00
Alexey Zuev 2bf0d1a56f fix(ivy): compile pipe in context of ternary operator (#28635)
Previously, it wasn't possible to compile template that contains pipe in context of ternary operator `{{ 1 ? 2 : 0 | myPipe }}` due to the error `Error: Illegal state: Pipes should have been converted into functions. Pipe: async`.

This PR fixes a typo in expression parser so that pipes are correctly converted into functions.

PR Close #28635
2019-02-11 14:52:13 -08:00
Andrew Kushnir a9afe629c7 feat(ivy): allow non-unique #localRefs to be defined in a template (#28627)
Prior to this change in Ivy we had strict check that disabled non-unique #localRefs usage within a given template. While this limitation was technically present in View Engine, in many cases View Engine neglected this restriction and as a result, some apps relied on a fact that multiple non-unique #localRefs can be defined and utilized to query elements via @ViewChild(ren) and @ContentChild(ren). In order to provide better compatibility with View Engine, this commit removes existing restriction.

As a part of this commit, are few tests were added to verify VE and Ivy compatibility in most common use-cases where multiple non-unique #localRefs were used.

PR Close #28627
2019-02-11 14:51:31 -08:00
Paul Gschwendtner 872a3656fe refactor(compiler): allow disabling external symbol factory reexports (#28594)
Currently external static symbols which are referenced by AOT
compiler generated code, will be re-exported in the corresponding
`.ngfactory` files.

This way of handling the symbol resolution has been introduced in
favor of avoding dynamically generated module dependencies. This
behavior therefore avoids any strict dependency failures.

Read more about a particular scenario here: https://github.com/angular/angular/issues/25644#issuecomment-458354439

Now with `ngtsc`, this behavior has changed since `ngtsc` just
introduces these module dependencies in order to properly reference
the external symbol from its original location (also eliminating the need
for factories). Similarly we should provide a way to use the same
behavior with `ngc` because the downside of using the re-exported symbol
resolution is that user-code transformations (e.g. the `ngInjectableDef`
metadata which is added to the user source code), can resolve external
symbols to previous factory symbol re-exports. This is a critical issue
because it means that the actual JIT code references factory files in order
to access external symbols. This means that the generated output cannot
shipped to NPM without shipping the referenced factory files.

A specific example has been reported here: https://github.com/angular/angular/issues/25644#issue-353554070

PR Close #28594
2019-02-11 17:12:50 +00:00
Pawel Kozlowski fcd1f61476 refactor(router): change RouterLinkActive impl to account for upcoming ivy breaking change (#28560)
PR Close #28560
2019-02-08 16:42:45 -08:00
Pawel Kozlowski e9bedc63bb fix(ivy): properly query root nodes of embedded views(shallow queries) (#28560)
PR Close #28560
2019-02-08 16:42:45 -08:00
Kara Erickson fb9a4a668c fix(ivy): support web worker nodes in unknown property checks (#28610)
We need to support rendering in contexts like web workers where
nodes are emulated and properties may not be set directly. This
commit gates property validation checks to environments that have
real Node objects.

FW-1043 #resolve

PR Close #28610
2019-02-08 13:35:29 -08:00
Marc Laval f7591f1302 test(ivy): add root cause for failing forms e2e tests (#28620)
PR Close #28620
2019-02-08 13:34:24 -08:00
George Kalpakas 1ff3699d99 test(upgrade): change flaky test to not be affected by other tests (#28617)
It seems that in some cases (especially on CI), global state is not
cleaned up properly causing a specific test to fail.
See #28045 and #28181 for more context.

This PR restores the global state for the affected test. This partly
defeat the purpose of the test, but is better than having flakes on CI.

Fixes #28614

PR Close #28617
2019-02-08 09:27:02 -08:00
Pawel Kozlowski 0e4705aec3 test(ivy): run view_injector_integration tests on node (#28593)
There is nothing browser specific in those tests and fakeAsync is supported on node.
Testing / debugging on node is often faster than on Karma.

PR Close #28593
2019-02-08 09:25:50 -08:00
Olivier Combe 94f042beba refactor(ivy): remove unneeded detach property (#28595)
PR Close #28595
2019-02-07 16:56:37 -08:00
Olivier Combe 9d109929be fix(ivy): remove nested placeholders with i18n (#28595)
PR Close #28595
2019-02-07 16:56:36 -08:00
Kara Erickson e0d2ca261b test(ivy): turn on passing test in platform-browser (#28604)
The behavior tested here was fixed by #28537, but I missed updating
the test in the original PR. This commit turns on the test to run
in Ivy mode, using "onlyInIvy" because the timing of the error message
is slightly different and requires CD to run.

PR Close #28604
2019-02-07 16:46:34 -08:00
Vladimir Moskva 6f9dd1bf28 refactor(common): Remove deprecated FileType (#28583)
FileType objects are deprecated. They are not required for specifying valid file types for rule attributes, a list of strings can be used instead.

PR Close #28583
2019-02-07 16:45:22 -08:00
Vani c3fadadaa9 docs: update HttpHeader documentation (#26233)
PR Close #26233
2019-02-07 16:42:13 -08:00
Kara Erickson 1950e2d9ba fix(ivy): throw on bindings to unknown properties (#28537)
This commit adds a devMode-only check which will throw if a user
attempts to bind a property that does not match a directive
input or a known HTML property.

Example:
```
<div [unknownProp]="someValue"></div>
```

The above will throw because "unknownProp" is not a known
property of HTMLDivElement.

This check is similar to the check executed in View Engine during
template parsing, but occurs at runtime instead of compile-time.

Note: This change uncovered an existing bug with host binding
inheritance, so some Material tests had to be turned off. They
will be fixed in an upcoming PR.

PR Close #28537
2019-02-07 12:37:32 -08:00
Andrew Kushnir 7660d0d74a fix(ivy): extended next pointer lookup while traversing tNode tree (#28533)
Prior to this change we only checked whether current lView has a next pointer while traversing tNode tree. However in some cases this pointer can be undefined and we need to look up parents chain to find suitable next pointer. This commit adds the logic of searching for the next pointer taking parents chain into account.

PR Close #28533
2019-02-07 12:37:13 -08:00
Filipe Silva 2caa419990 fix(compiler-cli): don't throw when listing lazy routes for an entry route (#28372)
In https://github.com/angular/angular/pull/27697 the listLazyRoutes was fixed to work with ivy.

Since the entryRoute argument is not supported, it was made to also error.

But by erroring it breaks existing usage with Angular CLI where the entry route is sent in as an argument.

This commit changes listLazyRoutes to not error out, but instead ignore the argument.

PR Close #28372
2019-02-07 12:36:51 -08:00
stoneLeaf 50732e1564 fix(router): redirect to root url when returned as UrlTree from guard (#28271)
When a UrlTree of root url was returned by a guard as a redirection, the
navigation was not processed. The issue came from the error handler which
incorrectly marked the router as already navigated.

Fixes #27845

PR Close #28271
2019-02-06 21:23:32 -08:00
Kristiyan Kostadinov 8d90142a0f build: disable sandbox when running protractor through bazel (#28557)
Adds `--no-sandbox` in order to disable the sandbox when running Protractor through Bazel. Enabling the sandbox causes Chrome to crash under certain environments.

PR Close #28557
2019-02-06 21:22:37 -08:00
cexbrayat 353362f5a4 docs(core): document isStable traps (#28102)
PR Close #28102
2019-02-06 15:13:19 -05:00
Alex Eagle 6709db9677 build: switch to typescript's es2015 typings (#28570)
Note that this allows Angular to depend on the entirety of the ES2015 API, not just our restricted subset.
This change is needed because our copy of the subset was out-of-date, and prevents us using ES2015 target in dev mode.

This is a subset of #27738

PR Close #28570
2019-02-06 14:17:55 -05:00
Marc Laval 43081a01d8 fix(ivy): WorkerAppModule should be an APP_ROOT (#28544)
PR Close #28544
2019-02-06 14:05:53 -05:00
Miško Hevery 62a13e795a refactor(ivy): pass host into createLView explicitly (#28461)
`LView` `HOST` was set in most cases right after creating `LView`.
This makes the API cleaner by explicitly passing it ont `createLView`.

PR Close #28461
2019-02-06 00:24:24 -05:00
Matias Niemelä 22d3226491 revert: fix(ivy): remove query results from destroyed embedded views (#28445)
This reverts commit 5ebc0da640.
2019-02-05 21:22:58 -08:00
Pawel Kozlowski 5ebc0da640 fix(ivy): remove query results from destroyed embedded views (#28445)
PR Close #28445
2019-02-05 23:48:39 -05:00
Omar Griffin d42f32cc61 feat: optionally save complete performance log in chrome benchpress tests (#27551)
If RAW_PERFLOG_PATH is passed in as an option, benchpress saves chrome's
performance log to a json file. This allows developers to download the
json file and upload it to their browser to get a breakdown of chrome-side
resource usage during a test.

PR Close #27551
2019-02-05 23:35:32 -05:00
Kristiyan Kostadinov d4add5428b test(ivy): root cause analysis for e2e tests in common (#28506)
Adds root causes to the e2e test failures in `common`.

This PR resolves FW-1011.

PR Close #28506
2019-02-05 23:31:51 -05:00
Kara Erickson 8f15cdbc7c test(ivy): move some local ref tests to use TestBed infrastructure. (#28534)
When we first started writing tests for Ivy, we did not yet have a
compatible compiler. For this reason, we set up the Ivy runtime tests
to run with generated code that we wrote by hand (instead of real code
generated by the compiler).

Now that we have a working Ivy compiler and TestBed infrastructure
that is compatible with Ivy, we should start writing integration
tests that leverage them (no more handwritten generated code!). This
will prevent bugs where the compiler code and runtime code become
out of sync (which is easy if they are tested separately). And
eventually, we should migrate all the existing runtime tests in
"core/test/render3" to TestBed and ngtsc.

To kick off this effort, this commit migrates some existing tests
from "core/test/render3/exports_spec.ts" and saves them in a new file
with the same name in the "core/test/acceptance" folder.

PR Close #28534
2019-02-05 23:31:08 -05:00
Olivier Combe baf103c98f fix(ivy): don't increment `expandoStartIndex` after directives are matched (#28424)
i18n instructions create text nodes dynamically and save them between bindings and the expando block in `LView`. e.g., they try to create the following order in `LView`.

```
| -- elements -- | -- bindings -- | -- dynamic i18n text -- | -- expando (dirs, injectors) -- |
```

Each time a new text node is created, it is pushed to the end of the array and the `expandoStartIndex` marker is incremented, so the section begins slightly later. This happens in `allocExpando`.

This is fine if no directives have been created yet. The end of the array will be in the "dynamic text node" section.

| -- elements -- | -- bindings -- | -- dynamic i18n text -- |

However, this approach doesn't work if dynamic text nodes are created after directives are matched (for example when the directive uses host bindings). In that case, there are already directives and injectors saved in the "expando" section. So pushing to the end of `LView` actually pushes after the expando section. What we get is this:

```
| -- elements -- | -- bindings -- | -- dynamic i18n text -- | -- expando -- | -- dynamic i18n text-- |
```

In this case, the `expandoStartIndex` shouldn't be incremented because we are not inserting anything before the expando section (it's now after the expando section). But because it is incremented in the code right now, it's now pointing to an index in the middle of the expando section.

This PR fixes that so that we only increment the `expandoStartIndex` if nothing was pushed into the expando section.

FW-978 #resolve

PR Close #28424
2019-02-05 23:30:37 -05:00
Andrew Kushnir 3f73dfa151 fix(ivy): sanitize external i18n ids before generating const names (#28522)
Prior to this change there was no i18n id sanitization before we output goog.getMsg calls. Due to the fact that message ids are used as a part of const names, some characters were bcausing issues while executing generated code. This commit adds sanitization to i18n ids used to generate i18n-related consts.

PR Close #28522
2019-02-05 23:29:44 -05:00
Pawel Kozlowski 7c5c1fae62 refactor(ivy): move around logic of getting render parent (#28455)
PR Close #28455
2019-02-05 23:29:24 -05:00
Jeremy Elbourn 89eac702b5 fix(ivy): remove DOM nodes from their real parent vs saved parent (#28455)
Currently, DOM node removal called `removeChild` on the saved parent
node when destroying a component. However, this will fail if the
component has been manually moved in the DOM. This change makes the
removal always use the node's real `parentNode` and ignore the provided
`parent`.

PR Close #28455
2019-02-05 23:29:24 -05:00
Andrew Kushnir 5a2c3ff8b5 fix(ivy): proper component resolution in case of inheritance (#28439)
Ivy allows Components to extend Directives (but not the other way around) and as a result we may have Component and Directive annotations present at the same time. The logic that resolves annotations to pick the necessary one didn't take this into account and as a result Components were recognized as Directives (and vice versa) in case of inheritance. This change updates the resolution logic by picking known annotation that is the nearest one (in inheritance tree) and compares it with expected type. That should help avoid mis-classification of Components/Directives during resolution.

PR Close #28439
2019-02-05 23:29:04 -05:00
kevinphelps ed0cf7e2cb fix(router): set href when routerLink is used on an 'area' element (#28441)
closes #28401

PR Close #28441
2019-02-05 23:28:40 -05:00
Matias Niemelä fe4d811086 revert: build: switch to typescript's es2015 typings (#28134)
This reverts commit dde7e2f253.
2019-02-05 18:07:10 -05:00
Greg Magolan 4142db0828 style: run format (#28532)
PR Close #28532
2019-02-05 16:55:43 -05:00
Greg Magolan 7a6237bc50 build: update lock files (#28532)
PR Close #28532
2019-02-05 16:55:43 -05:00
Greg Magolan 62c0deac42 build: fix for integration test bazel-schematics (#28532)
PR Close #28532
2019-02-05 16:55:43 -05:00
Greg Magolan cec1fa04c2 build: remove all deps on io_bazel_rules_go (#28532)
PR Close #28532
2019-02-05 16:55:43 -05:00
Greg Magolan 0d1e065a1c build: update to rules_typescript 0.23.2 and rules_nodejs 0.16.8 (#28532)
PR Close #28532
2019-02-05 16:55:43 -05:00
Keen Yee Liau 4a92fa9471 refactor(bazel): Create `ng-add` schematic for Bazel (#28436)
The logic to create additional files needed for Bazel are currently
hosted in `ng new`. Such files include the main.*.ts files needed
for AOT and a different angular.json to use Bazel builder, among others.

This commit refactors the logic into `ng add` so that it can be used to
perform the same modifications in an existing project. Users could do so
by running `ng add @angular/bazel`.

With this change, `ng new` effectively becomes an orchestrator that runs
the original `ng new` followed by `ng add @angular/bazel`.

PR Close #28436
2019-02-05 14:40:46 -05:00
Paul Gschwendtner 744b0205e2 build: fix failing compiler-cli tests on windows (#28352)
Note that this fixes `compiler-cli` tests within `compiler-cli/test`,
but there seem to be remaining `ngcc` tests within `compiler-cli/src`
which aren't working on Windows. This is out-of-scope for this commit.

PR Close #28352
2019-02-05 14:31:10 -05:00
Paul Gschwendtner 40da1be1e1 build: support running ngtsc tests on windows (#28352)
Currently the "ngtsc` testing helpers resolve the `fake_core` NPM
package using the `TEST_SRCDIR` variable. This is problematic on Windows
where Bazel runfiles are not symlinked into the runfiles directory.
In order to properly resolve the NPM Bazel tree artifact, we use the
`resolveTreeNpmArtifact` runfile helper that properly resolves the artifact
properly on all platforms.

PR Close #28352
2019-02-05 14:31:10 -05:00
Paul Gschwendtner c10d86cbc0 build: support running compiler-cli tests on windows (#28352)
In order to support running "compiler-cli" tests that use the "test_support.ts"
utilities on Windows with Bazel, we need to imporve the logic that resolves NPM
packages and symlinks them into a temporary directory.

A more Bazel idiomatic and windows compatible way of resolving Bazel runfiles
is to use the "RUNFILES_MANIFEST" if present. This ensures that the NPM
packages can be also symlinked on Windows, and tests can execute properly
on Windows. Read more about why this is needed here:

* https://github.com/bazelbuild/bazel/issues/3726#issue-257062364

PR Close #28352
2019-02-05 14:31:10 -05:00
Paul Gschwendtner b91a25bfb2 build: remove unused "test.sh" leftover code in compiler-cli (#28352)
Since we recently removed the `test.sh` script, and now run
all tests with Bazel, we can remove the unused logic that makes
compiler-cli tests pass in non-Bazel.

This cleans up the tests, and also makes it easier to write tests
without worrying about two ways of the Angular package output
(Bazel `ng_package` rules vs. old `build.sh` logic of building)

PR Close #28352
2019-02-05 14:31:10 -05:00
Paul Gschwendtner e11ac7f24b build: remove unused "test.sh" leftover code in language-service (#28352)
Since we recently removed the `test.sh` script, and now run all
tests with Bazel, we can remove the unused logic that makes language-service
tests pass in non-Bazel.

This cleans up the tests, and also makes it easier to write tests
without worrying about two ways of the Angular package output
(Bazel `ng_package` rules vs. old `build.sh` logic of building)

PR Close #28352
2019-02-05 14:31:10 -05:00
Paul Gschwendtner 4aa189da67 fix(compiler-cli): diagnostics should respect "newLine" compiler option (#28352)
PR Close #28352
2019-02-05 14:31:10 -05:00
Alex Eagle dde7e2f253 build: switch to typescript's es2015 typings (#28134)
Note that this allows Angular to depend on the entirety of the ES2015 API, not just our restricted subset.
This change is needed because our copy of the subset was out-of-date, and prevents us using ES2015 target in dev mode.

This is a subset of https://github.com/angular/angular/pull/27738

PR Close #28134
2019-02-05 14:25:10 -05:00
Matias Niemelä 76a6eacb4e refactor(ivy): rename "blacklist" to "blocklist" (#28536)
PR Close #28536
2019-02-05 14:06:15 -05:00
Olivier Combe 728fe69625 feat(ivy): improve stacktrace for `R3Injector` errors (#28207)
Improve the stacktrace for `R3Injector` errors by adding the source component (or module) that tried to inject the missing provider, as well as the name of the injector which triggered the error (`R3Injector`).

e.g.:
```
R3InjectorError(SomeModule)[car -> SportsCar]:
    NullInjectorError: No provider for SportsCar!
```

FW-807 #resolve
FW-875 #resolve

PR Close #28207
2019-02-05 01:53:20 -05:00
Alex Eagle 7219639ff3 fix(compiler-cli): base synthetic filepaths on input filepath (#28453)
This change is needed to work in google3, where file paths in the
ts.Program must always be absolute.

PR Close #28453
2019-02-04 17:27:35 -05:00
Kara Erickson f2621dbb37 fix(core): remove createInjector() from public API (#28509)
createInjector() is an Ivy-only API that should not have
been exported as part of the public API. This commit removes
the export. It will be re-exported when Ivy is released.

PR Close #28509
2019-02-04 16:54:26 -05:00
Paul Gschwendtner ee74835619 build: run playground e2e examples with bazel (#28490)
PR Close #28490
2019-02-04 16:51:11 -05:00
Paul Gschwendtner b7738ef9e4 build: fix bazel protractor tests not capturing console output (#28490)
Currently we depend on the "rules_webtesting" version that is
installed by "rules_typescript//:package.bzl". This version of
the webtesting rules comes with a very old version of Chromium
and the `chromedriver` that does not support capturing console
errors properly (with stack traces). Since we have a few e2e
tests that depend on console output (e.g. playground/src/source-map),
we need to make sure that these tests can pass upon Bazel
migration.

PR Close #28490
2019-02-04 16:51:11 -05:00
Kristiyan Kostadinov fc88a79b32 fix(ivy): errors not being logged to ErrorHandler (#28447)
Fixes Ivy not passing thrown errors along to the `ErrorHandler`.

**Note:** the failing test had to be reworked a little bit, because it has some assertions that depend on an error context being logged, however Ivy doesn't keep track of the error context.

This PR resolves FW-840.

PR Close #28447
2019-02-04 16:48:14 -05:00
Keen Yee Liau a98d66078d docs(bazel): Explain explicit version requirement (#28482)
PR Close #28482
2019-02-04 14:56:46 -05:00
Matias Niemelä 52d3795336 revert: fix(ivy): remove query results from destroyed embedded views (#28445)
This reverts commit 71b9d5539b.
2019-02-04 12:52:37 -05:00
Pawel Kozlowski 71b9d5539b fix(ivy): remove query results from destroyed embedded views (#28445)
PR Close #28445
2019-02-04 10:51:15 -05:00
Kara Erickson 5c4d95541e fix(ivy): mark views dirty by default when events fire (#28474)
In Ivy, we support a new manual mode that allows for stricter control
over change detection in OnPush components. Specifically, in this mode,
events do not automatically mark OnPush views as dirty. Only changed
inputs and manual calls to `markDirty()` actually mark a view dirty.

However, this mode cannot be the default for OnPush components if we
want to be backwards compatible with View Engine. This commit re-adds
the legacy logic for OnPush components where events always mark views
dirty and makes it the default behavior.

Note: It is still TODO to add a public API for manual change detection.

PR Close #28474
2019-02-01 15:48:06 -05:00
Andrew Kushnir 8930f60a4b refactor(ivy): create an Ivy version of tree-shakable providers test (#28477)
Due to the fact that the test in 'ng_module_integration_spec.ts' relied on internal VE data structures (the '_def' field) to verify the state and the structure has changed in Ivy, this commit adds an Ivy version of the same test.

PR Close #28477
2019-02-01 14:00:41 -05:00
Keen Yee Liau 36902e2f0e fix(bazel): Bazel builder resolves with require.resolve() (#28478)
This commit fixes a bug in the Bazel builder in which the path to Bazel
executable is constructed using the project path. For non-default
project, the node_modules directory is actually one level above the
project path.

This PR fixes the bug by resolving node_modules with require.resolve().
It requires @bazel/bazel v0.22.1 because previous versions do not have
index.js or main field in package.json and would cause node module
resolution to fail.

This has been tested with both bazel and ibazel.

PR Close #28478
2019-02-01 13:56:53 -05:00
Jeremy Elbourn ec6e7303dd perf: pngcrush all pngs (#28479)
This is the result of running
```sh
find ./ -iname "*.png" -exec pngcrush -brute -ow --  {} \;
```

[Summary of size reductions](https://docs.google.com/spreadsheets/d/12Qgx7DfKabWw0PJza6ozC1kCHTofi6wyBLWGtwLW7G4/preview)

Last done in July, 2017 in #18243

PR Close #28479
2019-02-01 13:56:02 -05:00
Pawel Kozlowski 1b6d8a78b0 fix(ivy): queries should match container node itself before matching its views (#28473)
PR Close #28473
2019-01-31 17:14:05 -05:00
Pawel Kozlowski 6656328538 refactor(ivy): adjust types, limit usage of global state (#28473)
PR Close #28473
2019-01-31 17:14:05 -05:00
Marc Laval 9efb39c8a2 test(ivy): ComponentFactoryResolver can resolve any component factory in Ivy (#28465)
PR Close #28465
2019-01-31 15:55:31 -05:00
Matias Niemelä f640941e1d docs(ivy): update global utils documentation references to window.ng 2019-01-31 12:52:24 -08:00
Jeremy Elbourn 35e45dc894 fix(ivy): prevent errors from views being destroyed twice (#28413)
Previously, attempting to destroy a view with listeners more than once
throws an error during event listener cleanup. This happens because
`cleanup` field on the `TView` has already been cleared out by the time
the second destruction runs.

The `destroyed` flag on LView was previously being set in the `destroyLView` function,
but this flag was never _checked_ anywhere in the codebase. This commit
moves _setting_ this flag to the `cleanupView` function, just before
destroy hooks are called. This is necessary because the destroy hooks
can contain arbitrary user code, such as (surprise!) attempting to
destroy the view (again). We also add a check to `destroyLView` to skip
already-destroyed views. This prevents the cleanup code path from running twice.

PR Close #28413
2019-01-30 20:39:55 -05:00
Pawel Kozlowski b35ef184a7 refactor(ivy): remove firstTemplatePass as global state (#28450)
PR Close #28450
2019-01-30 20:39:35 -05:00
Alex Eagle a227c528ca feat(compiler-cli): expose ngtsc as a TscPlugin (#28435)
This lets us run ngtsc under the tsc_wrapped custom compiler (Used in Bazel)
It also allows others to simply wire ngtsc into an existing typescript compilation binary

PR Close #28435
2019-01-29 16:41:59 -08:00
Pawel Kozlowski 51a592cdfc fix(ivy): mark query as dirty upon view insertion (#28429)
PR Close #28429
2019-01-29 16:40:47 -08:00
Kara Erickson fdc6e159b4 fix(ivy): throw if @Input and @ContentChild share a property (#28415)
In View Engine, we supported @Input and @ContentChild annotations
on the same property. This feature was somewhat brittle because
it would only work for static queries, so it would break if a
content child was passed in wrapped in an *ngIf. Due to the
inconsistent behavior and low usage both internally and externally,
we will likely be deprecating it in the next version, and it does
not make sense to perpetuate it in Ivy.

This commit ensures that we now throw in Ivy if we encounter the
two annotations on the same property.

PR Close #28415
2019-01-29 16:40:22 -08:00
Andrew Kushnir 7d9aa67d8c fix(ivy): verify bootstrapped types are Components (#28386)
Prior to this change we didn't verify types passed to bootstrap as a part of NgModule semantics verification. Now we check whether all types passed to bootstrap are actually Components.

PR Close #28386
2019-01-29 16:39:41 -08:00
Andrew Kushnir 495a9dd445 fix(ivy): update token used for fakeAsync test (#28383)
This commit updates the token used in fakeAsync test to the one available in both VE and R3 TestBeds. The goal of the test is to verify that fakeAsync works with inject function, so the actual token that is used for a test is irrelevant in that case. The logic to retrieve tokens from compiler injector (that the comment in "fixmeIvy" refers to) was implemented in PR #28196.

PR Close #28383
2019-01-29 16:39:14 -08:00
Andrew Kushnir 778d5739e2 refactor(ivy): minor refactoring of Host Bindings function generation (#28379)
Prior to this change, generation of host bindings and host styles was guarded by the "if" statement, which always returned true. Enforcing more strict check for bindings length broke some tests, since host styling instructions generation were inside the same "if" block. This update decouples bindings instruction generation from styling instructions, which makes it less error prone.

PR Close #28379
2019-01-29 16:38:25 -08:00
cexbrayat 66ce3b2f2f fix(ivy): scan simple children routes with no infinite recursion (#28370)
PR Close #28370
2019-01-29 16:37:48 -08:00
Andrew Kushnir 76cedb8bf3 fix(ivy): verify Host Bindings and Host Listeners before compiling them (#28356)
Prior to this change we may encounter some errors (like pipes being used where they should not be used) while compiling Host Bindings and Listeners. With this update we move validation logic to the analyze phase and throw an error if something is wrong. This also aligns error messages between Ivy and VE.

PR Close #28356
2019-01-29 16:36:22 -08:00
Erick Xavier eeadb37b19 docs(core): add relative path information to component metadata (#27962)
Adds the information that the templateUrl and styleUrls options supports only relative Urls.

Adds more information about relative paths and absolute URLs in project metadata.

PR Close #27962
2019-01-29 16:31:11 -08:00
onlyflix 41e68f7a7a style: change to American English (#27266)
PR Close #27266
2019-01-29 16:30:25 -08:00
jithil-kore dabcb3e17b docs: fix Redundant "See also:" link in ContentChild (#28334)
PR Close #28334
2019-01-29 12:03:25 -08:00
Filipe Silva bcf17bc91c refactor(compiler-cli): return TS nodes from TypeTranslatorVisitor (#28342)
The TypeTranslatorVisitor visitor returned strings because before it wasn't possible to transform declaration files directly through the TypeScript custom transformer API.

Now that's possible though, so it should return nodes instead.

PR Close #28342
2019-01-29 12:00:55 -08:00
Filipe Silva d45d3a3ef9 refactor(compiler-cli): use a transformer for dts files (#28342)
The current DtsFileTransformer works by intercepting file writes and editing the source string directly.

This PR refactors it as a afterDeclaration transform in order to fit better in the TypeScript API.

This is part of a greater effort of converting ngtsc to be usable as a TS transform plugin.

PR Close #28342
2019-01-29 12:00:55 -08:00
Filipe Silva f99a668b04 refactor(compiler-cli): refactor import adding logic into helper (#28342)
This logic will be common to transforms that add imports. Using it as a helper helps reduce duplication

PR Close #28342
2019-01-29 12:00:55 -08:00
Filipe Silva 70e426ba1b fix(bazel): also pass afterDeclarations transformers to emitWithTsickle (#28342)
Tsickle supports afterDeclarations transformers, but these were not being passed in.

PR Close #28342
2019-01-29 12:00:55 -08:00
Benedikt Meurer 9af18c2fd0 perf(core): be more consistent about typeof checks (#28400)
When testing whether `value` is an object, use the ideal sequence of
strictly not equal to `null` followed by `typeof value === 'object'`
consistently. Specifically there's no point in using double equal with
`null` since `undefined` is ruled out by the `typeof` check.

Also avoid the unnecessary ToBoolean check on `value.ngOnDestroy` in
`hasOnDestroy()`, since the `typeof value.ngOnDestroy === 'function'`
will only let closures pass and all closures are truish (with the
notable exception of `document.all`, but that shouldn't be relevant
for the `ngOnDestroy` hook).

PR Close #28400
2019-01-29 11:50:47 -08:00
Jeremy Elbourn 2bb518c694 fix(ivy): add root components to the root view tree in renderComponent (#28409)
Previously, these components were not added to the view tree for the
(fake) root view in which they were bootstrapped. Without this,
root view destruction does not work as expected since the root view's
children are not present to be also destroyed.

PR Close #28409
2019-01-29 11:49:29 -08:00
Jason Aden 227f7e44d6 Revert "feat(compiler-cli): expose ngtsc as a TscPlugin" (#28433)
This reverts commit df2221c6476df1f2d2478b949702f3270c3a4565.

PR Close #28433
2019-01-29 11:29:48 -08:00
Alex Eagle 22f76df8f2 feat(compiler-cli): expose ngtsc as a TscPlugin (#28431)
This lets us run ngtsc under the tsc_wrapped custom compiler (Used in Bazel)
It also allows others to simply wire ngtsc into an existing typescript compilation binary

PR Close #28431
2019-01-29 09:44:58 -08:00
Jason Aden e18a52e24a Revert "feat(compiler-cli): expose ngtsc as a TscPlugin" (#28416)
This reverts commit cf4edbce40a3a65fdefe90760a93e43bc45b7d19.

PR Close #28416
2019-01-28 22:39:56 -08:00
Andrew Kushnir f38deb0f07 fix(ivy): update test after Content Queries inheritance fix (#28414)
This commit updates test that was added after Content Queries inheritance fix (that renames some instructions) was merged into master. The test used previous version of instructions, thus causing failures after merging Content Queries inheritance fix.

PR Close #28414
2019-01-28 22:07:32 -08:00
Alex Eagle 59cc724e3b feat(compiler-cli): expose ngtsc as a TscPlugin (#27806)
This lets us run ngtsc under the tsc_wrapped custom compiler (Used in Bazel)
It also allows others to simply wire ngtsc into an existing typescript compilation binary

PR Close #27806
2019-01-28 20:16:47 -08:00
Paul Gschwendtner 8ced999e47 build: improve compiler-cli codegen output test (#28191)
* Improves the `compiler-cli/integrationtest` codegen output test slightly by using a more clear test description and by adding an assertion that ensures that decorators are downleveled.

PR Close #28191
2019-01-28 20:07:22 -08:00
Paul Gschwendtner 4c8d17ffd4 build: fix outdated ngtools compiler-cli test logic (#28191)
* Fixes that the test logic for `ngtools` in the offline compiler test is no longer working due to being unmaintained for a long time
* Makes the path comparison logic platform agnostic, so that the tests can be also executed on Windows

PR Close #28191
2019-01-28 20:07:22 -08:00
Paul Gschwendtner 3e6a1f0bc4 build: fix outdated i18n compiler-cli test assertions (#28191)
PR Close #28191
2019-01-28 20:07:22 -08:00
Paul Gschwendtner 40d64b6b58 build: run offline_compiler_test using bazel (#28191)
PR Close #28191
2019-01-28 20:07:22 -08:00
Keen Yee Liau c84739dc55 test(bazel): Integration test for Sass support (#28297)
Add .sass files to the integration test for bazel-schematics.

Also addressed Alex's comment in
https://github.com/angular/angular/pull/28167/files#r248149866
about the unit tests being too brittle.

PR Close #28297
2019-01-28 20:01:18 -08:00
Andrew Kushnir bb94434d85 fix(ivy): Content Queries inheritance fix (#28324)
Prior to this change contentQueriesRefresh functions that represent refresh logic for @ContentQuery list were not composable, which caused problems in case one Directive inherits another one and both of them contain Content Queries. Due to the fact that we used indices to reference queries in refresh function, results were placed into wrong Queries. In order to avoid that we no longer use indices to reference queries and instead maintain current content query index while iterating through them. This allows us to compose contentQueriesRefresh functions and make inheritance feature work with Content Queries.

PR Close #28324
2019-01-28 19:59:00 -08:00
Kristiyan Kostadinov ebac5dba38 fix(ivy): don't generate code for blank NgModule fields (#28387)
Currently `compileNgModule` generates an empty array for optional fields that are omitted from an `NgModule` declaration (e.g. `bootstrap`, `exports`). This isn't necessary, because `defineNgModule` has some code to default these fields to empty arrays at runtime if they aren't defined. The following changes will only output code if there are values for the particular field.

PR Close #28387
2019-01-28 19:50:44 -08:00
Paul Gschwendtner 29513296fb test: disable failing ivy example e2e tests (#28402)
PR Close #28402
2019-01-28 19:21:09 -08:00
Paul Gschwendtner 98e5af1480 build: switch example e2e tests to bazel (#28402)
* No longer builds the example e2e tests using "tsc". The examples are now built with Bazel and can therefore be built with Ivy by using the `--define=compile=aot` switch.
* No longer runs the example e2e tests using the protractor CLI. example e2e tests are executed with the Bazel protractor rule and can therefore run incrementally.

NOTE: Unit tests found within the examples are still running within the legacy jobs.

PR Close #28402
2019-01-28 19:21:09 -08:00
Alex Rickabaugh 66335c36e6 fix(ivy): getSourceFile() of transformed nodes returns undefined (#28412)
In some cases, calling getSourceFile() on a node from within a TS
transform can return undefined (against the signature of the method).
In these cases, getting the original node first will work.

PR Close #28412
2019-01-28 16:42:48 -08:00
George Kalpakas 9d3dae42e9 fix(ivy): return correct declaration for class indentifiers for ES5 in ngcc (#26947)
PR Close #26947
2019-01-28 14:01:12 -08:00
George Kalpakas 1699c88655 fix(ivy): add missing private render3 exports (#26947)
PR Close #26947
2019-01-28 14:01:12 -08:00
George Kalpakas 074400da60 refactor(core): remove duplicate check in `defaultStyleSanitizer` (#26947)
PR Close #26947
2019-01-28 14:01:12 -08:00
Alex Rickabaugh 7d954dffd0 feat(ivy): detect cycles and use remote scoping of components if needed (#28169)
By its nature, Ivy alters the import graph of a TS program, adding imports
where template dependencies exist. For example, if ComponentA uses PipeB
in its template, Ivy will insert an import of PipeB into the file in which
ComponentA is declared.

Any insertion of an import into a program has the potential to introduce a
cycle into the import graph. If for some reason the file in which PipeB is
declared imports the file in which ComponentA is declared (maybe it makes
use of a service or utility function that happens to be in the same file as
ComponentA) then this could create an import cycle. This turns out to
happen quite regularly in larger Angular codebases.

TypeScript and the Ivy runtime have no issues with such cycles. However,
other tools are not so accepting. In particular the Closure Compiler is
very anti-cycle.

To mitigate this problem, it's necessary to detect when the insertion of
an import would create a cycle. ngtsc can then use a different strategy,
known as "remote scoping", instead of directly writing a reference from
one component to another. Under remote scoping, a function
'setComponentScope' is called after the declaration of the component's
module, which does not require the addition of new imports.

FW-647 #resolve

PR Close #28169
2019-01-28 12:10:25 -08:00
Alex Rickabaugh cac9199d7c feat(ivy): cycle detector for TypeScript programs (#28169)
This commit implements a cycle detector which looks at the import graph of
TypeScript programs and can determine whether the addition of an edge is
sufficient to create a cycle. As part of the implementation, module name
to source file resolution is implemented via a ModuleResolver, using TS
APIs.

PR Close #28169
2019-01-28 12:10:25 -08:00
Alex Rickabaugh a789a3f532 test(ivy): clean up two parameters in ngtsc_spec.ts inferred as 'any' (#28169)
PR Close #28169
2019-01-28 12:10:25 -08:00
Keen Yee Liau 5dbc7d9a63 fix(bazel): Builder should invoke local bazel/iblaze (#28303)
Builder for `@angular/bazel` schematics should not expect bazel/ibazel
to be on the PATH. It should instead invoke the local executable
installed by yarn/npm.

PR Close #28303
2019-01-28 12:01:35 -08:00
Pawel Kozlowski fd8dbd5e40 test(ivy): @Injectable is required on type providers (#28331)
PR Close #28331
2019-01-28 12:01:07 -08:00
Keen Yee Liau 7033f39c61 fix(bazel): Bazel-workspace schematics should run in ScopedTree (#28349)
Users should be able to add Bazel workspace to an existing project.
The current approach assumes that the schematics is working on the same
tree as that of ng-new, which includes the top-level directory. Instead,
the schematic should work on the tree rooted at `appRoot` to enable
Bazel files to be added to existing project.

This change uses the newly implemented ScopedTree
a0ac4b0e3d
to achieve this.

NOTE: The version of `@angular-devkit/schematics` that is installed is
used to run the `@angular/bazel` schematic. Even if a different version
is used in the schematic itself, it has no effect.
Therefore, the *latest* Angular CLI should be used to generate the
files. As of this commit, the latest version is @angular/cli@7.3.0-rc.0

PR Close #28349
2019-01-28 12:00:16 -08:00
Jeremy Elbourn 3deda898d0 fix(ivy): TestBed should tolerate synchronous use of `compileComponents` (#28350)
TestBed.compileComponents has always been an async API. However,
ViewEngine tolerated using this API in a synchronous manner if the
components declared in the testing module did not have any async
resources (templateUrl, styleUrls). This change makes the ivy TestBed
mirror this tolerance by configuring such components synchronously.

Ref: FW-992

PR Close #28350
2019-01-28 11:59:40 -08:00
JoostK f8c70011b1 fix(ivy): ngcc - handle accessor pairs in ES2015 (#28357)
ngcc's reflection host needs to be able to determine all members of a
class, which it does by using the `ts.Symbol` from TypeScript's
TypeChecker.  Such Symbol however may represent multiple class members
in the case of accessors; an equally named getter/setter accessor pair
is combined into a single `ts.Symbol`.

This commit introduces logic to recognize such accessors in order for
both the getter and setter to be considered as class member, similar to
ngtsc's behavior when operating on original TypeScript code.

One difference wrt the TypeScript host is that ngcc cannot see to which
accessor originally had any decorators applied to them, as decorators
are applied to the property descriptor in general, not a specific accessor.
If an accessor has both a setter and getter, any decorators are only
attached to the setter member.

PR Close #28357
2019-01-28 11:58:44 -08:00
JoostK adfc55e2c3 fix(ivy): ngcc - recognize accessor members in ES5 (#28357)
Prior to this change, accessor functions for getters and setters would
not be considered as class member, as their declaration is vastly
different from ES2015 syntax.

With this change, the ES5 reflection host has learned to recognize the
downleveled syntax for accessors, allowing for them to be considered as
class member once again.

Fixes #28226

PR Close #28357
2019-01-28 11:58:44 -08:00
Keen Yee Liau 3b48d13af8 fix(bazel): ng-new should run yarn install (#28381)
yarn install was disabled in ng-new for Bazel schematics because
Bazel manages its own node_modules dependencies and therefore
there is no need to install dependencies twice.

However, the first yarn install is needed for `ng` commands to work,
most notably `ng build`.

This commit restores the original behavior.

PR Close #28381
2019-01-28 11:54:37 -08:00
Marc Laval d83307adab fix(ivy): init hooks should be called once and only once (#28239)
PR Close #28239
2019-01-25 14:31:23 -08:00
Marc Laval 873750609f fix(ivy): calling ChangeDetectorRef.detectChanges() from onChanges should not go infinite loop (#28239)
PR Close #28239
2019-01-25 14:31:23 -08:00
Keen Yee Liau 664ea50b46 docs(bazel): Warn about version compatibility (#28353)
PR Close #28353
2019-01-25 14:23:36 -08:00
Pawel Kozlowski 99886bd159 fix(ivy): unify checkNoChanges logic with the view engine (#28366)
This commit unifies handling of the "check no changes" mode between
ngIvy and the view engine. More specifically:
- check no changes can be invoked before change detection in ivy;
- `undefined` values are considered equal `NO_CHANGES` for the "check no changes"
mode purposes.

Chanes in this commit enables several tests that were previously running only in ivy
or only in the view engine.

PR Close #28366
2019-01-25 14:22:57 -08:00
Miško Hevery 3d5a919ac5 refactor(ivy): clean up TNode not depending on LView (#28354)
PR Close #28354
2019-01-25 13:07:26 -08:00
Martin Sikora ef6728207b fix(forms): don't override form group's dirty state when disabling controls (#24591)
Update packages/forms/src/model.ts

Co-Authored-By: martinsik <martin.sikora.ahoj@gmail.com>

PR Close #24591
2019-01-25 12:59:07 -08:00
Andrew Kushnir 2da82db3bc fix(ivy): proper i18n postprocessing in case of nested templates (#28209)
Prior to this change the postprocess step relied on the order of placeholders combined in one group (e.g. [�#1�|�*1:1�]). The order is not guaranteed in case we have nested templates (since we use BFS to process templates) and some tags are represented using same placeholders. This change performs postprocessing more accurate by keeping track of currently active template and searching for matching placeholder.

PR Close #28209
2019-01-25 12:54:29 -08:00
Matias Niemelä 7421534873 test(ivy): move error-handling test to be handled at a later stage (#28212)
Due to the fast moving nature of the Ivy codebase, the timing isn't
right to make changes to how errors and reported and handled during the
runtime.

Once ivy is stable this test should be revisted because that stage there
will be a better and more robust understanding of how ivy should recover
from runtime errors.

Jira Issue: FW-952

PR Close #28212
2019-01-25 12:54:04 -08:00
Marc Laval fdc2b0bf77 fix(ivy): queries should register matches from top to bottom (#28319)
PR Close #28319
2019-01-25 12:51:09 -08:00
Kara Erickson bf97d3b73e feat(ivy): support property bindings and interpolations in DebugElement (#28355)
DebugElement.properties should contain a map of element
property names to element property values, with entries
for both normal property bindings and host bindings.

This commit adds support for property bindings in
DebugElement.properties (including interpolations).

PR Close #28355
2019-01-25 12:39:01 -08:00
Kara Erickson 46aec4a58f feat(ivy): support host properties in DebugElement.properties (#28355)
DebugElement.properties should contain a map of element
property names to element property values, with entries
for both normal property bindings and host bindings.
Many Angular core tests depend on this map being present.

This commit adds support for host property bindings in
DebugElement.properties, which fixes the Angular core tests.
There is still work to be done for normal property bindings.

PR Close #28355
2019-01-25 12:39:01 -08:00
Greg Magolan c522e03fe9 fix(bazel): add @npm//tslib dep to e2e ts_library target in bazel-workspace schematic (#28358)
PR Close #28358
2019-01-25 12:38:34 -08:00
Jason Aden b2811e50c5 refactor(router): initalize browserUrlTree to empty tree (#28376)
The value here is unimportant on initialization since it's not looked at until the second navigation. However, sometimes in testing  the `Location` service is mocked out, or the Router constructor manually called. Assuming `Location` exists in the constructor leads to test failures in `google3` therefore we initialize to a value that will not cause errors.

PR Close #28376
2019-01-25 12:37:56 -08:00
Felix Lemke 465abab213 docs(animations): fix group and sequence function usage examples (#28305)
animate functions now contain style functions instead of plain objects
e.g. animate(1s, { background: black }))
to   animate(1s, style({ background: black }))

PR Close #28305
2019-01-24 10:21:35 -08:00
Kara Erickson c1fb9c265c fix(ivy): save queries at the correct indices (#28327)
Previous to this change, we were storing view queries at the
wrong index. This is because we were passing a raw index to the
store() instruction instead of an adjusted index (i.e. an
index that does not include the HEADER_OFFSET). We had an
additional issue where TView.blueprint was not backfilled
when TView.data was backfilled, so new component instances
created from the blueprint would end up having a shorter LView.
Both of these problems together led to the Material demo app
failing with Ivy. This commit fixes those discrepancies.

PR Close #28327
2019-01-24 10:16:22 -08:00
Daniel Ruf d4ecffe475 refactor: remove obsolete font-smoothing property (#28174)
PR Close #28174
2019-01-23 15:44:35 -08:00
Jason Aden 736cfa4e09 refactor(ivy): correct cyclical dependency (#28326)
PR Close #28326
2019-01-23 15:42:13 -08:00
Olivier Combe cbd626413c fix(ivy): link correct ngModule's injector to the bootstrapped component (#28183)
Previously, bootstrapping a component with render3 would create a chained injector with the test bed ngModule instead of the ngModule that the component belongs to.
Now when a component belongs to an ngModule, we use that for the chained injector, ensuring the correct injection of any providers that this ngModule contains.

FW-776 #resolve

PR Close #28183
2019-01-23 15:06:59 -08:00
Kara Erickson 317cc922ac test(ivy): turn on passing tests in platform-browser-dynamic (#28307)
PR Close #28307
2019-01-23 15:05:45 -08:00
Kristiyan Kostadinov f9b103825a fix(ivy): content projection with Shadow DOM not working (#28261)
Fixes components with native content projection (using `<content>` or `<slot>`) not working under Ivy.

The issue comes from the fact that when creating elements inside a component, we sometimes don't append the element immediately, but we leave it to projection to move it into its final destination. This ends up breaking the native projection, because the slots have to be in place from the beginning. The following changes switch to appending the element immediately when inside a component with Shadow DOM encapsulation.

This PR resolves FW-841.

PR Close #28261
2019-01-23 15:05:12 -08:00
Pawel Kozlowski 32c61f434c fix(ivy): ngUpgrade should distinguish element and module injectors (#28313)
There are cases where we should check an element injector but don't go
into the associated module injector if a token is not found. In both the
view engine and ngIvy this is acheived by passing the
`NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR` as the `notFoundValue`.

Before this fix the view engine and ngIvy were using different objects to
represent `NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR`. This was causing problems
as ngUpgrade is using `NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR` const in its
`NgAdapterInjector` to prevent searching of module injectors.

This commit makes sure that ngIvy is using the same object to represent
`NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR` as the view engine.

PR Close #28313
2019-01-23 15:01:22 -08:00
Kristiyan Kostadinov 22a43cff4d fix(ivy): error when encountering an empty class attribute (#28321)
Fixes Ivy throwing an error if it encounters an empty class attribute in a template (`class=""`).

This PR resolves FW-972.

PR Close #28321
2019-01-23 14:58:42 -08:00
Andrew Kushnir 9098225ff0 fix(ivy): View Queries inheritance fix (#28309)
Prior to this change `viewQuery` functions that represent @ViewQuery list were not composable, which caused problems in case one Component/Directive inherits another one and both of them contain View Queries. Due to the fact that we used indices to reference queries, resulting query set was corrupted (child component queries were overridden by super class ones). In order to avoid that we no longer use indices assigned at compile time and instead maintain current view query index while iterating through them. This allows us to compose `viewQuery` functions and make inheritance feature work with View Queries.

PR Close #28309
2019-01-23 14:57:17 -08:00
Kristiyan Kostadinov 9f9024b7a1 fix(ivy): handle namespaces in attributes (#28242)
Adds handling for namespaced attributes when generating the template and in the `elementAttribute` instruction.

PR Close #28242
2019-01-23 11:58:41 -08:00
William Neely 03c8528fcb docs(router): removed additional to (#25989)
PR Close #25989
2019-01-23 11:00:20 -08:00
Ben Lesh 5430d2bc66 fix(ivy): NgOnChangesFeature no longer included in hello_world (#28187)
- Wraps the NgOnChangesFeature in a factory such that no side effects occur in the module root
- Adds comments to ngInherit property on feature definition interface to help guide others not to make the same mistake
- Updates compiler to generate the feature properly after the change to it being a factory
- Updates appropriate tests

PR Close #28187
2019-01-23 10:59:34 -08:00
Ben Lesh a95e81978b refactor(ivy): Add newer, smaller NgOnChangesFeature (#28187)
PR Close #28187
2019-01-23 10:59:34 -08:00
Ben Lesh 5552661fd7 refactor(ivy): revert onChanges change back to a feature (#28187)
- adds fixmeIvy annotation to tests that should remain updated so we can resolve those issues in the subsequent commits

PR Close #28187
2019-01-23 10:59:33 -08:00
Andrew Kushnir 030350f53e fix(ivy): TestBed.get should be able to retrieve tokens from Compiler's injector (#28196)
This changes restores parity between VE TestBed and R3TestBed logic related to retrieving tokens using TestBed.get function. Now R3TestBed also tries to retrieve tokens from Compiler Injector.

PR Close #28196
2019-01-23 10:59:02 -08:00
Daniel Ruf 0a564c3158 refactor: fix code style (#28203)
PR Close #28203
2019-01-23 10:58:38 -08:00
Daniel Ruf b9854e582f refactor: remove unused parameters (#28203)
PR Close #28203
2019-01-23 10:58:37 -08:00
Pawel Kozlowski cf8770f3cc fix(ivy): don't create TNodes for native projectable nodes (#28275)
Before this commit we were creating a "fake" TNode for each and every
projectable node passed during dynamic component creation. This approach
had several problems:
- the existing TView structure had to be mutated to accomodate new TNodes and
it was very easy to "corrupt" TView / TNode data structures;
- TNodes are not really needed to fully support projectable nodes so we were
creating objects and updating existing data structures for nothing.

This commit changes the approach so we don't create "fake" TNodes for projectable
nodes but instead we process projectable nodes directly in the projection instruction.
As a result we've got less code, less object allocation and - as a bonus - we fix few
bugs where TView / TNode data structures were corrupted when using projectable nodes.

PR Close #28275
2019-01-23 10:56:09 -08:00
Kristiyan Kostadinov d8f2318811 fix(ivy): generating incorrect tag name with namespace (#28298)
Fixes the template generation function generating an incorrect tag name when the element has a namespace (e.g. `:svg:circle` gets generated rather than `circle`).

PR Close #28298
2019-01-23 10:55:44 -08:00
Jason Aden 50df897fdc fix(router): `skipLocationChange` with named outlets (#28300)
With #27680, a bug was fixed where multiple redirects using `eager` URL update could cause navigation to fail. However, that fix introduced a problem where with `skipLocationChange` enabled, the URL tree rendered was not properly stored for reference. This specifically caused an issue with named router outlets and subsequent navigations not being recognized.

This PR stores the correct `UrlTree` for reference with later navigations. It fixes the regression introdued with #27680.

Fixes #28200

PR Close #28300
2019-01-22 15:15:02 -08:00
Jason Aden 33e49c2894 Revert "revert: fix(router): ensure URL is updated after second redirect with UrlUpdateStrategy="eager" (#27523)" (#28300)
This reverts commit eea2b0f288.

PR Close #28300
2019-01-22 15:15:02 -08:00
Kristiyan Kostadinov ea1b5c100f fix(ivy): not applying camelCased style properties (#28276)
Fixes Ivy not applying properties that are set in camelCase, because it goes through the `CSSStyleDeclaration` API via `setProperty` and `removeProperty` which requires for [the values to be in dash-case](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/setProperty).

**Note:** I opted to let the browser normalize the value, rather than convert it to dash-case during compile time, because there are some special cases like browser-prefixed properties where we might not normalize it in-line with the browser.

This PR fixes FW-579.

PR Close #28276
2019-01-22 12:29:14 -08:00
Sarun Intaralawan 18a9afc738 docs(core): deprecate ViewEncapsulation.Native (#26361)
PR Close #26361
2019-01-22 12:19:54 -08:00
Judy Bogart 589dd479e2 docs: add input docs (#27376)
PR Close #27376
2019-01-22 12:19:28 -08:00
Judy Bogart 661a98aeda docs: add api doc for ngif (#27376)
PR Close #27376
2019-01-22 12:19:28 -08:00
Judy Bogart 988243437a docs: add method doc (#27377)
PR Close #27377
2019-01-22 12:18:02 -08:00
Judy Bogart 3b9553bb17 docs: expand input descriptions (#27377)
PR Close #27377
2019-01-22 12:18:02 -08:00
Judy Bogart 522e4ea898 docs: add doc for TrackByFunction (#27377)
PR Close #27377
2019-01-22 12:18:02 -08:00
Judy Bogart b6819fe9bb docs: add inpur vars doc (#27377)
PR Close #27377
2019-01-22 12:18:02 -08:00
Judy Bogart 6c3b57a968 docs: add api doc for ngfor (#27377)
PR Close #27377
2019-01-22 12:18:02 -08:00
Judy Bogart 37f8263430 docs: correct array to map (#27379)
PR Close #27379
2019-01-22 12:16:45 -08:00
Judy Bogart a84a9ba705 docs: add input doc (#27379)
PR Close #27379
2019-01-22 12:16:45 -08:00
Judy Bogart d73734dcb7 docs: add api doc for ng_style directive (#27379)
PR Close #27379
2019-01-22 12:16:45 -08:00
Judy Bogart e0fbe8611e docs: add api doc to template_ref (#27380)
PR Close #27380
2019-01-22 12:13:50 -08:00
Alex Rickabaugh 1964be0b17 feat(ivy): implement listLazyRoutes() for ngtsc (#27697)
This commit uses the NgModuleRouteAnalyzer introduced previously to
implement listLazyRoutes() for NgtscProgram. Currently this implementation
is limited to listing routes globally and cannot list routes for a given lazy
module. Testing seems to indicate that the CLI uses the global form, but this
should be verified.

Jira issue: FW-629

PR Close #27697
2019-01-22 12:02:10 -08:00
Alex Rickabaugh 41b2499f17 test(ivy): introduce route testing mode for ngtsc tests (#27697)
This commit introduces a new mode for the NgtscTestEnvironment which
builds the NgtscProgram and then asks for the list of lazy routes,
instead of running the TS emit phase.

PR Close #27697
2019-01-22 12:02:10 -08:00
Alex Rickabaugh da85cee07c feat(ivy): implement ngtsc's route analysis (#27697)
This commit introduces the NgModuleRouteAnalyzer & friends, which given
metadata about the NgModules in a program can extract the list of lazy
routes in the same format that the ngtools API uses.

PR Close #27697
2019-01-22 12:02:10 -08:00
George Kalpakas 2fc5f002e0 refactor(ivy): re-use the `ForeignFunctionResolver` interface when appropriate (#27697)
This makes the types (and intentions) more explicit and clear.

PR Close #27697
2019-01-22 12:02:10 -08:00
Alex Rickabaugh 19a2b783cf feat(ivy): create a ModuleResolver to map module paths to files (#27697)
PR Close #27697
2019-01-22 12:02:10 -08:00
Alex Rickabaugh 9e5016c845 feat(ivy): DynamicValue now indicates why the value is dynamic (#27697)
This commit changes the partial evaluation mechanism to propagate
DynamicValue errors internally during evaluation, and not to "poison"
entire data structures when a single value is dynamic. For example,
previously if any entry in an array was dynamic, evaluating the entire
array would return DynamicValue. Now, the array is returned with only
the specific dynamic entry as DynamicValue.

Instances of DynamicValue also report the node that was determined to
be dynamic, as well as a potential reason for the dynamic-ness. These
can be nested, so an expression `a + b` may have a DynamicValue that
indicates the 'a' term was DynamicValue, which will itself contain a
reason for the dynamic-ness.

This work was undertaken for the implementation of listLazyRoutes(),
which needs to partially evaluate provider arrays, parts of which are
dynamic and parts of which contain useful information.

PR Close #27697
2019-01-22 12:02:09 -08:00
Paul Gschwendtner 070fca1591 fix(ivy): ngtsc fails building flat module out on windows (#27993)
`ngtsc` currently fails building a flat module out file on Windows because it generates an invalid flat module TypeScript source file. e.g:

```ts
5 export * from './C:\Users\Paul\Desktop\test\src\export';
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

This is because `path.posix.relative` does not properly with non-posix paths, and only expects posix paths in order to work.

PR Close #27993
2019-01-22 11:49:53 -08:00
Sander Elias d336bff200 fix(ivy): add missging getDirectives export (#28259)
fix(ivy): expose missing getDirectives from dicovery_utils

PR Close #28259
2019-01-22 11:43:52 -08:00
Kara Erickson 058aafcc0c fix(ivy): fix styling context resolution for host bindings on containers (#28221)
Previous to this change, the isStylingContext() function was improperly
returning true for LContainers because it used the presence of an array
at index 2 to determine whether it was a styling context. Unfortunately,
LContainers also contain arrays at index 2, so this would return a false
positive. This led to other errors down the line because we would treat
nodes with containers as if they already had styling contexts (even if
they did not), so the proper initialization logic for styling contexts
was not run.

This commit fixes the isStylingContext() function to use LCONTAINER_LENGTH
as a marker rather than the presence of an array, which in turn fixes
host bindings to styles on nodes with containers.

PR Close #28221
2019-01-22 09:45:16 -08:00
Daniel Ruf 7980f1d2ea refactor: remove unused case in switch statement (#28253)
PR Close #28253
2019-01-22 09:44:35 -08:00
Pete Bacon Darwin 73dcd72afb refactor(ivy): expose resolving URLs in the `ResourceLoader` (#28199)
Resources can be loaded in the context of another file, which
means that the path to the resource file must be resolved
before it can be loaded.

Previously the API of this interface did not allow the client
code to get access to the resolved URL which is used to load
the resource.

Now this API has been refactored so that you must do the
resource URL resolving first and the loading expects a
resolved URL.

PR Close #28199
2019-01-18 11:03:53 -08:00
Alex Eagle 38343a2388 build: set a default module_name for ts_library rules (#28051)
PR Close #28051
2019-01-18 10:16:39 -08:00
alsami 45bf911df8 feat(forms): add `markAllAsTouched()` to `AbstractControl` (#26812)
Add functionality to mark a control and its descendant controls as touched

Closes #19400

PR Close #26812
2019-01-18 10:12:21 -08:00
Kristiyan Kostadinov ab2bf83398 fix(ivy): destroy injector when module is destroyed (#27793)
Destroys the module's injector when an `NgModule` is destroyed which in turn calls the `ngOnDestroy` methods on the instantiated providers.

This PR resolves FW-739.

PR Close #27793
2019-01-18 10:10:32 -08:00
Ben Lesh 2b9cc8503d fix(ivy): Ensure proper namespace is used to create elements in JIT (#28144)
PR Close #28144
2019-01-18 09:56:41 -08:00
Alex Eagle a58fd210e9 feat(compiler-cli): resolve generated Sass/Less files to .css inputs (#28166)
Users might have run the CSS Preprocessor tool *before* the Angular
compiler. For example, we do it that way under Bazel. This means that
the design-time reference is different from the compile-time one - the
input to the Angular compiler is a plain .css file.

We assume that the preprocessor does a trivial 1:1 mapping using the same
basename with a different extension.

PR Close #28166
2019-01-18 09:49:19 -08:00
Matias Niemelä 6940992932 fix(ivy): ensure animation component host listeners are rendered in the sub component (#28210)
Due to the fact that animations in Angular are defined in the component metadata,
all animation trigger definitions are localized to the component and are
inaccessible outside of it. Animation host listeners in Ivy are
rendered in the context of the parent component, but the VE renders them
differently. This patch ensures that animation host listeners are
always registered in the sub component's renderer

Jira issue: FW-943
Jira issue: FW-958

PR Close #28210
2019-01-18 09:37:23 -08:00
Keen Yee Liau c1c87462fd build(bazel): Use local rollup & build-optimizer for ng_rollup_bundle (#28215)
The current build workflow depends on cross workspace dependency by
installing angular-cli as a Bazel repository. This is not ideal because
it introduces separate node_module directories other than the one
installed by Angular through the yarn_install rule (ngdeps).

This commit removes angular-cli from the Bazel workspace and installs
rollup and @angular-devkit/build-optimizer locally.

PR Close #28215
2019-01-18 09:07:52 -08:00
Igor Minar 73616ab237 fix(bazel): increase node memory limit for ng_module rule to prevent OOM for big modules (#28237)
This came up as a request from an internal Google team.

Context:
- http://cl/229881085
- https://groups.google.com/a/google.com/forum/#!topic/nodejs/GLqDEOW0MV4

PR Close #28237
2019-01-18 09:06:54 -08:00
Matias Niemelä 5a582a8afd fix(ivy): ensure element removal triggers host removal animations (#28162)
Prior to this fix Ivy would not execute any animation triggers
that exist as host bindings on an element if it is removed by
the parent template.

PR Close #28162
2019-01-17 09:58:50 -08:00
Matias Niemelä e172e97e13 fix(ivy): ensure animation @trigger ordering is correctly delivered to the renderer (#28165)
In Ivy when elements are created a series of static attribute names are provided
over to the construction instruction of that element. Static attribute names
include non-binding attribues (like `<div selected>`) as well as animation bindings
that do not have a RHS value (like `<div @foo>`). Because of this distinction,
value-less animation triggers are rendered first before value-full animation
bindings are and this improper ordering has caused various existing tests to fail.
This patch ensures that animation bindings are evaluated in the order that they
exist within the HTML template code (or host binding code).

PR Close #28165
2019-01-17 09:58:29 -08:00
Matias Niemelä 0d6913f037 fix(ivy): ensure interpolated style/classes do not cause tracking issues for bindings (#28190)
With the refactoring or how styles/classes are implmented in Ivy,
interpolation has caused the binding code to mess up since interpolation
itself takes up its own slot in Ivy's memory management code. This patch
makes sure that interpolation works as expected with class and style
bindings.

Jira issue: FW-944

PR Close #28190
2019-01-17 09:58:14 -08:00
Matias Niemelä 896cf35afb fix(ivy): ensure renderer begin/end methods are only called during change detection (#28192)
In VE the renderer.begin() and renderer.end() methods are only called
when CD is called on an element. This patch ensures that Ivy does the
same thing.

Jira issue: FW-945

PR Close #28192
2019-01-17 09:57:52 -08:00
Kara Erickson 1f7d3b9a57 fix(ivy): TestBed should use annotation for the last match rather than the first (#28195)
When we look for matching annotations in TestBed, we should always take the last
matching annotation. Otherwise, we will return superclass data for subclasses,
which would have unintended consequences like directives matching the wrong selectors.

PR Close #28195
2019-01-17 09:57:30 -08:00
Pawel Kozlowski 1a85de302d test(ivy): add root cause analysis for the remaining projection test (#28152)
Initial thinking was that the bug is in the content projection logic but
it turned out to be a wrong assumption - hence adding a test to illustrate
that basic content projection of view containers works correctly.

What fails in the marked test is the logic quering debug nodes - content
peojection is fine but we never create the 'B' text node since we call
show() method on the "wrong" directive instance.

PR Close #28152
2019-01-16 17:36:54 -08:00
Pawel Kozlowski 808898d015 fix(ivy): properly project individual nodes (#28152)
PR Close #28152
2019-01-16 17:36:54 -08:00
Keen Yee Liau f59f18c13e feat(bazel): Add support for SASS (#28167)
This commit adds the appropriate rules to the WORKSPACE for a project
that requires SASS support.

PR Close #28167
2019-01-16 17:35:54 -08:00
Kristiyan Kostadinov bac71ef419 fix(ivy): componentFactories not populated in ModuleWithComponentFactories (#28112)
Fixes the `ModuleWithComponentFactories.componentFactories` not being populated when calling `compileModuleAndAllComponentsSync` in Ivy.

These changes resolve FW-929.

PR Close #28112
2019-01-16 09:52:15 -08:00
Andrew Kushnir da1d19b40f test(ivy): add compiler.getModuleId support in R3TestBed (#28097)
This update brings `getModuleId` function support to R3TestBed-specific Compiler instance.

PR Close #28097
2019-01-16 09:51:26 -08:00
Andrew Kushnir 9a81f0d9a8 fix(ivy): update i18n/i18nStart and i18nAttributes instruction order (#28163)
Prior to this change element's i18n attributes like "i18n-title" were processed after "i18n" ones that placed "i18n" and "i18nAttributes" instructions in wrong order, thus "i18nAttributes" failed to target its host element at runtime. This change updates processing order and puts "i18nAttributes" instructions in front of "i18n" ones to resolve the problem.

PR Close #28163
2019-01-16 09:50:53 -08:00
Olivier Combe c61ea1d5bd fix(ivy): support for multiple ICU expressions in the same i18n block (#28083)
There were two issues with multiple ICU expressions in the same i18n block:
- the regexp that was used to parse the text wasn't able to handle multiple ICU expressions, I've replaced it with parsing the text and searching for brackets (which is what we ended up doing in the end anyway)
- we allocate node indexes for nodes generated by the ICU expressions which increases the expando value, but we would create the nodes for those cases during the update phase. In the mean time we would create some nodes during the creation phase (comment nodes for ICU expressions, text nodes, ...) with an auto increment index. This means that any node created after an ICU expression would get the following index value, but the ICU case nodes expected to use the same index as well... There was a mismatch between the auto generated index, and the expected index which was causing problems when we needed to select those nodes for updates later on. To fix it, I've added the expected node index to the list of mutate codes that we generate, and we do not use an auto increment value anymore.

FW-905 #resolve
PR Close #28083
2019-01-16 09:49:54 -08:00
George Kalpakas 3b7a571cc5 test(upgrade): clean up global state after test (#28181)
In ngUpgradeLite, when a downgraded component
[requests its downgraded module][1], the AngularJS injector is
[temporarily stored][2] with the intention of grabbing it
[once the module has been bootstrapped][3] (which also cleans up the
[temporary injector reference][4]).

In [some tests][5], bootstrapping a component might throw an error,
which causes the test to fail immediatelly and move on to the next
test. In slow browsers (e.g. on CI/Saucelabs), the (successful)
bootstrapping of another downgraded module might not have been
completed in time and thus the temporary injector reference not cleaned
up.

In such a case, if the following test (in our randomized test suite)
happens to rely on the temporary injector reference's being initially
unset (such as [this test][6]), it will fail. This might appear as a
flake on CI, because it depends on a race condition and specific order
of tests, so it usually goes away after a rerun.

This commit fixes it by ensuring the temporary injector reference is
manually cleaned up, when necessary.

Jira issue: FW-939

[1]: f983e99fb2/packages/upgrade/src/common/downgrade_component.ts (L120)
[2]: f983e99fb2/packages/upgrade/src/static/downgrade_module.ts (L165)
[3]: f983e99fb2/packages/upgrade/src/static/downgrade_module.ts (L169)
[4]: f983e99fb2/packages/upgrade/src/static/angular1_providers.ts (L25)
[5]: f983e99fb2/packages/upgrade/test/static/integration/downgrade_module_spec.ts (L1331-L1381)
[6]: f983e99fb2/packages/upgrade/test/static/angular1_providers_spec.ts (L31-L45)

PR Close #28181
2019-01-16 09:45:01 -08:00
Pawel Kozlowski f983e99fb2 test(ivy): enable passing animation test (#28156)
PR Close #28156
2019-01-15 14:09:52 -08:00
Pawel Kozlowski 4f009e7a03 refactor(ivy): minor code duplication cleanup (#28155)
PR Close #28155
2019-01-15 14:09:05 -08:00
Olivier Combe 29bff0f02e feat(ivy): implement `compileComponents` method for `TestBedRender3` (#27778)
The implementation of the `compileComponents` method for `TestBedRender3` was missing.
We now pass each component through `resolveComponentResources` when `TestBed.compileComponents` is called so that `templateUrl` and `styleUrls` can be resolved asynchronously and used once `TestBed.createComponent` is called.
The component's metadata are overriden in `TestBed` instead of mutating the original metadata like this is the case outside of TestBed. The reason for that is that we need to ensure that we didn't mutate anything so that the following tests can run with the same original metadata, otherwise we it could trigger or hide some errors.

FW-553 #resolve

PR Close #27778
2019-01-15 14:08:20 -08:00
Keen Yee Liau 3a31a2795e refactor(language-service): Cleanup ts_plugin (#28145)
This commit removes the unnecessary typescriptOnly() helper from
ts_plugin and all unused methods related to that.

PR Close #28145
2019-01-15 11:30:37 -08:00
Benedikt Meurer ce3a746644 perf(platform-server): use shared `DomElementSchemaRegistry` instance (#28150) (#28151)
Right now the `ServerRendererFactory2` creates a new instance of the
`DomElementSchemaRegistry` for each and every request, which is quite
costly (for the Tour of Heroes SSR this takes around **30%** of the
overall execution time). Since the schema is never modified, but only
used in a read-only fashion, it should be possible to re-use a single
instance instead.

Naive performance testing with 100 concurrent connections and 1000
requests in total shows an approximate **33%** improvement in Req/Sec
on the Tour of Heroes SSR example.

PR Close #28150

PR Close #28151
2019-01-15 11:27:54 -08:00
Alan bc02e31185 fix(ivy): normalize summary and factory shim files paths (#28006)
At the moment, paths stored in `maps` are not normalized and in Windows is causing files not to be found when enabling factory shimming.

For example, the map contents will be
```
Map {
  'C:\\git\\cli-repos\\ng-factory-shims\\index.ngfactory.ts' => 'C:\\git\\cli-repos\\ng-factory-shims\\index.ts' }
```

However, ts compiler normalized the paths and is causing;
```
error TS6053: File 'C:/git/cli-repos/ng-factory-shims/index.ngfactory.ts' not found.
error TS6053: File 'C:/git/cli-repos/ng-factory-shims/index.ngsummary.ts' not found.
```

The changes normalized the paths that are stored within the factory and summary maps.

PR Close #28006
2019-01-15 11:21:58 -08:00
cexbrayat 6072ca87e1 fix(ivy): deps are actually supported (#28076)
This code was throwing if the `deps` array of a provider has several elements, but at the next line it resolves them... With this check `ngtsc` couldn’t compile `ng-bootstrap` for example.

PR Close #28076
2019-01-15 11:01:00 -08:00
Jason Aden 9460218f36 docs(router): add clarification for Router config (#28159)
PR Close #28159
2019-01-15 10:54:49 -08:00
Judy Bogart 850b86749c docs: add api doc for switch directives (#27378)
PR Close #27378
2019-01-15 10:53:03 -08:00
Ernest Galbrun a24120011e docs(core): fix typo (#28042)
PR Close #28042
2019-01-15 09:52:48 -08:00
Serginho d49d1e7d73 fix(service-worker): navigation urls backwards compatibility (#27244)
PR Close #27244
2019-01-15 09:50:31 -08:00
crisbeto da8ee29e72 fix(ivy): throw meaningful error for uninitialized output (#28085)
Throws a similar error to ViewEngine when encountering an `@Output` that hasn't been initialized to an `Observable`.

These changes resolve FW-680.

PR Close #28085
2019-01-15 09:47:21 -08:00
Matias Niemelä 693045165c refactor(ivy): remove def.attributes in favor of the `elementHostAttrs` instruction (#28089)
Up until this point, all static attribute values (things like `title` and `id`)
defined within the `host` are of a Component/Directive definition were
generated into a `def.attributes` array and then processed at runtime.
This design decision does not lend itself well to tree-shaking and is
inconsistent with other static values such as styles and classes.

This fix ensures that all static attribute values (attributes, classes,
and styles) that exist within a host definition for components and
directives are all assigned via the `elementHostAttrs` instruction.

```
// before
defineDirective({
  ...
  attributes: ['title', 'my title']
  ...
})

//now
defineDirective({
  ...
  hostBindings: function() {
    if (create) {
      elementHostAttrs(..., ['title', 'my-title']);
    }
    ...
  }
  ...
})
```

PR Close #28089
2019-01-15 09:45:41 -08:00
Matias Niemelä e62eeed7d4 fix(ivy): ensure component/directive `class` selectors are properly understood (#27849)
Angular allows for `<ng-content>` elements to include a selector which
filters which content-projected entries are inserted into the container
depending on whether or not the selector is matched.

With Ivy this feature has not fully worked due to the massive changes
that took place inside of Ivy's styling algorithm code (which is
responsible for assigning classes and styles to an element). This
fix ensures that content-projection can correctly identify which slot
an element should be placed into when class-based selectors are used.

PR Close #27849
2019-01-15 09:44:50 -08:00
Keen Yee Liau 06e5bf1661 fix(bazel): Bazel schematics should add router package (#28141)
This commit fixes a bug whereby a Bazel project created by the
schematics would not compiled if project contains routing module.

It is missing a dependency on the router package.

PR Close #28141
2019-01-14 17:12:00 -08:00
Kristiyan Kostadinov 60fecc1284 fixup! refactor(ivy): simplify context discover based on feedback (#28101)
PR Close #28101
2019-01-14 17:11:11 -08:00
Kristiyan Kostadinov b6510a320b fix(ivy): debug node references not returning template ref (#28101)
Fixes the `DebugNode.references` returning a reference to the underlying comment node, rather than the `TemplateRef` that the reference is pointing to. The issue comes from the fact that `discoverLocalRefs` falls back directly to returning the native node, if the ref isn't pointing to a directive, rather than looking through the locals.

These changes resolve FW-870.

PR Close #28101
2019-01-14 17:11:11 -08:00
Marc Laval fa53150692 test(ivy): NodeInjector should know how to get itself (INJECTOR) (#28009)
PR Close #28009
2019-01-14 17:09:26 -08:00
JoostK b5c2ef2877 fix(ivy): clone queries correctly for multiple component instances (#27892)
When requesting a queries instance for a node, it was previously
decided whether it needs to be cloned if the node was not already marked
as hosting a query. This check is in place to have only a single queries
instance per node.

The issue with this approach is that no clone is created for subsequent
instantiations of a component, as the TNode is already marked as hosting
a query during first template pass, whereas the cloning of queries
should be independent of first template pass.

To overcome this issue, the queries are assigned an owner TNode such
that it can reliably be determined if a clone needs to be created.

PR Close #27892
2019-01-14 17:08:26 -08:00
赵正阳 ddd8cd0573 docs(ivy): remove duplicated words in architecture doc (#27471)
PR Close #27471
2019-01-14 17:06:42 -08:00
Andrew Kushnir f1fb62d1e5 fix(core): proper @internal and @nocollapse combined usage fix (#28138)
This update fixes the way the @internal and @nocollapse annotations are used together, which produced errors while running it with Closure compiler. Now two annotations are a part of the same comment block.

PR Close #28138
2019-01-14 14:33:09 -08:00
Paul Gschwendtner d12db4e114 fix(bazel): incorrectly always uses ngc-wrapped from "npm" workspace (#28137)
* This is a follow-up to cd0451305a which fixes that "ngc-wrapped" from the "npm" workspace is always used if "angular" is fetched as an external dependency.

PR Close #28137
2019-01-14 14:12:18 -08:00
Andrew Kushnir 68bdbf0520 fix(ivy): validate props and attrs with "on" prefix at runtime (#28054)
Prior to this change we performed prop and attr name validation at compile time, which failed in case a given prop/attr is an input to a Directive (thus should not be a subject to this check). Since Directive matching in Ivy happens at runtime, the corresponding checks are now moved to runtime as well.

PR Close #28054
2019-01-14 10:53:03 -08:00
Paul Gschwendtner cd0451305a fix(bazel): replay compilation uses wrong compiler for building esm5 (#28053)
With the update to TypeScript 3.2.x, a big issue seems to have appeared for downstream Bazel users. If the downstream user still uses a lower TypeScript version, normal Bazel targets using the `ng_module` rule are still compiled with the correct/old TypeScript version (assuming they set the `node_modules` attribute properly).

But, if they build the previous Bazel targets by specifying them within a `ng_package` rule, the TypeScript version from the Angular `workspace` is being used for the replayed ESM5 compilation. This is because we resolve the replay compiler to `ngc_wrapped` or `tsc_wrapped` Bazel executables which are defined as part of the `angular` workspace. This means that the compilers are different if the downstream user uses `ngc-wrapped` from the `@npm` repository because the replayed compilation would use the compiler with `@ngdeps//typescript`.

In order to fix this, we should just use the compiler that is defined in the `@angular//BUILD.bazel` file. This target by defaults to the "@npm" workspace which is working for downstream users. This is similar to how it is handled for `tsc-wrapped`. `tsc-wrapped` works as expected for downstream users.

**Note**: This is not the ideal solution because ideally we would
completely respect the `compiler` option from the base `ng_module`, but
this is not possible in a hermetic way, unless we somehow accept the
`compiler` as an attribute that builds all transitive deps. This is
something we should explore in the future. For now, we just fix this in
a reasonable way that is also used for `tsc_wrapped` from the TypeScript
rules.

PR Close #28053
2019-01-14 10:44:24 -08:00
Keen Yee Liau e8495b460f refactor(bazel): use web_package rule for index.html (#27995)
index.html needs to have the zone.js and the project bundle injected
using script tags. This used to be done explicitly by specifying a
new index.html but with `web_package` rule introduced in rules_nodejs,
it is now possible to perform the injection dynamically.

PR Close #27995
2019-01-14 10:42:13 -08:00
Keen Yee Liau fc881390d0 docs(bazel): Getting started with Bazel + CLI (#27784)
PR Close #27784
2019-01-14 10:40:38 -08:00
kwiateusz 657cf733a2 docs: ngComponentOutlet doc updated with new Injector creation (#27291)
PR Close #27291
2019-01-14 10:36:02 -08:00
Kara Erickson 6fff74e576 test(ivy): re-enable passing tests and misc cleanup (#28093)
PR Close #28093
2019-01-14 10:03:57 -08:00
Miško Hevery 978ffa9d32 refactor(ivy): refactor more files in DI to prepare it for bazel packages (#28098)
PR Close #28098
2019-01-14 09:55:30 -08:00
Misko Hevery 6a9a48b0ac test: improve symbol-extractor test by ignoring $1 suffix (#28098)
PR Close #28098
2019-01-14 09:55:30 -08:00
Miško Hevery da2880d7c4 fixup! fix(ivy): add missing @nocollapse annotation to __NG_ELEMENT_ID__ fields (#28050) (#28066)
PR Close #28066
2019-01-11 16:24:03 -08:00
Misko Hevery fca185e191 refactor(ivy): create Injector interface; remove dependency on Ivy (#28066)
This change is a prerequasity for a later change which will turn the
'di' into its own bazel package. In order to do that we have to:
- have `Injector` type be importable by Ivy. This means that we need
  to create `Injector` as a pure type in `interface` folder which is
  already a bazel package which Ivy can depend on.
- Remove the dependency of `class Injector` on Ivy so that it can be
  compiled in isolation. We do that by using `-1` as special value for
  `__NG_ELEMENT_ID__` which tells the Ivy `NodeInjector` than
  `Injector` is being requested.

PR Close #28066
2019-01-11 16:24:03 -08:00
Matias Niemelä 133fe5e561 test(ivy): update root causes for animation tests (#28091)
PR Close #28091
2019-01-11 16:21:27 -08:00
Keen Yee Liau 605f450251 fix(bazel): Add ibazel to deps of Bazel project (#28090)
Incremental rebuilds is a fundamental part of the development
workflow. `@bazel/ibazel` should be added to the dev dependencies
of a Bazel project.

PR Close #28090
2019-01-11 15:58:38 -08:00
Andrew Kushnir 9260b5e0b4 fix(ivy): ignore empty bindings (#28059)
This update aligns Ivy behavior with ViewEngine related to empty bindings (for example <div [someProp]></div>): empty bindings are ignored.

PR Close #28059
2019-01-11 15:17:54 -08:00
Pete Bacon Darwin 9a128a8068 docs(forms): fix up `@see` tags for `AbstractContol` (#28069)
PR Close #28069
2019-01-11 14:35:23 -08:00
Kara Erickson fe4d3a1619 test(ivy): re-enable passing upgrade tests (#28088)
PR Close #28088
2019-01-11 14:34:27 -08:00
Filipe Silva b73d6781da build: support external angular in ng_rollup_bundle (#28049)
PR Close #28049
2019-01-11 14:31:11 -08:00
Kara 0c6fa1df52 refactor(ivy): update parameter for executeInitHooks to be more accurate (#27965)
Co-Authored-By: benlesh <ben@benlesh.com>
PR Close #27965
2019-01-11 14:28:35 -08:00
Ben Lesh 8ebdb437dc fix(ivy): ngOnChanges only runs for binding updates (#27965)
PR Close #27965
2019-01-11 14:28:35 -08:00
Ben Lesh b0caf02d4f feat(ivy): properly handle inheriting lifecycle hooks from plain classes (#27965)
PR Close #27965
2019-01-11 14:28:35 -08:00
Alex Rickabaugh 091a8a6fd5 fix(ivy): add missing @nocollapse annotation to __NG_ELEMENT_ID__ fields (#28050)
__NG_ELEMENT_ID__ static fields are a part of how the Ivy node injector
works. In order to survive closure minification correctly, they need to
be annotated with @nocollapse.

PR Close #28050
2019-01-11 11:19:32 -08:00
Alex Rickabaugh 61bc61fc59 fix(ivy): ensure @nocollapse is added to static fields (#28050)
ngtsc has a hack to add @nocollapse jsdoc annotations to generated static
fields. This hack is currently broken (likely due to a TypeScript change
in the way writeFile() works).

This commit fixes the hack and introduces an ngtsc_spec test to ensure it
does not regress again.

PR Close #28050
2019-01-11 11:19:32 -08:00
Alex Rickabaugh df292c2ce0 fix(ivy): TestBed should not clobber compilation of global-scope modules (#28033)
When an @NgModule decorator executes, the module is added to a queue in
render3/jit/module.ts. Reading an ngComponentDef property causes this queue
to be flushed, ensuring that the component gets the correct module scope
applied.

In before_each.ts, a global beforeEach is added to all Angular tests which
calls TestBed.resetTestingModule() prior to running each test. This in turn
clears the module compilation queue (which is correct behavior, as modules
declared within the test should not leak outside of it via the queue).

So far this is okay. But before the first test runs, the module compilation
queue is full of modules declared in global scope. No definitions have been
read, so no flushes of the queue have been triggered. The global beforeEach
triggers a reset of the queue, aborting all of the in-progress global
compilation, breaking those classes when they're later used in tests.

This commit adds logic to TestBedRender3 to respect the state of the module
queue before the TestBed is first initialized or reset. The queue is flushed
prior to such an operation to ensure global compilation is allowed to finish
properly.

With this fix, a platform-server test now passes (previously the <my-child>
element was not detected as a component, because the encompassing module
never finished compilation.

FW-887 #resolve

PR Close #28033
2019-01-11 11:18:10 -08:00
Alex Rickabaugh 51e716b6f2 feat(ivy): implement a Compiler for use in TestBedRender3 (#28033)
Previously when testing code injected the Compiler, it received the
top-level Compiler implementation defined in linker/compiler.ts
(and governed by the __PRE_R3__ switch). Code running under the
TestBed, however, should always use a TestBed-aware Compiler
implementation.

This commit adds such an implementation to the TestBedRender3,
which passes compiled modules through the _compileNgModule()
function.

With this change, 3 formerly disabled router integration tests
now pass.

FW-855 #resolve

PR Close #28033
2019-01-11 11:18:10 -08:00
Alex Rickabaugh 94893accdb fix(ivy): fix invalid provider error messages under TestBed (#28033)
An @NgModule with invalid provider declarations produces errors under
normal circumstances. However, within the TestBed two small issues with
provider overrides interfered with the correct production of these errors:

1. a 'null' provider object caused a premature crash when the TestBed
   attempted to check for a 'provide' property on it with hasOwnProperty().
2. the array of providers would have an empty override array appended to it
   for each input provider, which would pollute the error messages produced
   down the line.

This commit fixes both of these issues, by 1) checking for null and 2)
filtering out the empty override arrays.

Testing strategy: future commits change the way the TestBed compiles
modules, causing tests to become sensitive to this bug if not fixed.

PR Close #28033
2019-01-11 11:18:10 -08:00
Alex Rickabaugh 6c6d43086f fix(ivy): make module registration by id idempotent (#28033)
An @NgModule with an 'id' property has its type registered in a global map
of modules by id. This happens during compilation of the module.

In Ivy, modules are first compiled when the @NgModule decorator executes.
In tests, they might be passed again through the TestBed's compiler,
resulting in a second compilation and registration.

Before this fix, this second registration would cause an error, as the id
was previously registered. This commit makes the registration idempotent,
so if the same module type is being registered for the same id then no
error is thrown.

Testing strategy: future commits change the way the TestBed compiles
modules, causing tests to become sensitive to this bug if not fixed.

PR Close #28033
2019-01-11 11:18:09 -08:00
Igor Minar 3ea9f0974a docs(router): remove obsolete sections in README.md (#27880)
PR Close #27880
2019-01-11 11:15:59 -08:00
Adam Plumer a100472b5d build: bump year (#27880)
PR Close #27880
2019-01-11 11:15:59 -08:00
Pete Bacon Darwin e31afb7118 fix(ivy): ngcc - identify all ESM5 decorated classes (#27848)
In ESM5 decorated classes can be indicated by calls to `__decorate()`.
Previously the `ReflectionHost.findDecoratedClasses()` call would identify
helper calls of the form:

```
SomeClass = tslib_1.__decorate(...);
```

But it was missing calls of the form:

```
SomeClass = SomeClass_1 = tslib_1.__decorate(...);
```

This form is common in `@NgModule()` decorations, where the class
being decorated is referenced inside the decorator or another
member.

This commit now ensures that a chain of assignments, of any length,
is now identified as a class decoration if it results in a call to
`__decorate()`.

Fixes #27841

PR Close #27848
2019-01-11 11:14:01 -08:00
Pawel Kozlowski f854eb7dec test(ivy): mark tests where checkNoChanges results are different in the view engine and ivy (#28073)
PR Close #28073
2019-01-11 10:18:03 -08:00
Matias Niemelä b0f3c20a4c test(ivy): resolve root cause for core animation tests (#28062)
PR Close #28062
2019-01-10 17:13:31 -08:00
Karanveer Plaha 26a8c095d0 docs(router): fixed a typo in CanLoad title text (#27894)
* Interface that a class can implement to be a guard deciding if a children can be loaded.
'...if a children...' changed to '...if children...'
 * Interface that a class can implement to be a guard deciding if children can be loaded.

PR Close #27894
2019-01-10 17:06:55 -08:00
Teamop aebec4b156 refactor(core): improve type for EventEmitter (#27228)
PR Close #27228
2019-01-10 17:02:52 -08:00
Kristiyan Kostadinov 9277142d54 fix(ivy): support multiple exportAs (#27996)
Allows for multiple, comma-separated `exportAs` names, similarly to `ViewEngine`.

These changes fix FW-708.

PR Close #27996
2019-01-10 16:53:26 -08:00
Keen Yee Liau b78351cc7e build(bazel): Bump @bazel/typescript & @bazel/karma to 0.22.1 (#28031)
PR Close #28031
2019-01-10 16:49:56 -08:00
Misko Hevery 885f1af509 build: extract interface and util sub compilation from core (#28028)
PR Close #28028
2019-01-10 16:31:44 -08:00
Suguru Inatomi b05baa59e0 fix(bazel): Add /bazel-out to .gitignore (#27874)
PR Close #27874
2019-01-10 13:40:28 -08:00
Kara Erickson ad6569c744 fix(ivy): markForCheck() should not schedule change detection (#28048)
Previously, we had the logic to schedule a change detection tick
inside markViewDirty(). This is fine when used in markDirty(),
the user-facing API, because it should always schedule change
detection. However, this doesn't work when used in markForCheck()
because historically markForCheck() does not trigger change
detection.

To be backwards compatible, this commit moves the scheduling
logic out of markViewDirty() and into markDirty(), so
markForCheck no longer triggers a tick.

PR Close #28048
2019-01-10 13:37:40 -08:00
Pete Bacon Darwin feebe03523 fix(ivy): pass ngContentSelectors through to `defineComponent()` calls (#27867)
Libraries that create components dynamically using component factories,
such as `@angular/upgrade` need to pass blocks of projected content
through to the `ComponentFactory.create()` method. These blocks
are extracted from the content by matching CSS selectors defined in
`<ng-content select="..">` tags found in the component's template.

The Angular compiler collects these CSS selectors when compiling a component's
template, and exposes them via the `ComponentFactory.ngContentSelectors`
property.

This change ensures that this property is filled correctly when the
component factory is created by compiling a component with the Ivy engine.

PR Close #27867
2019-01-10 13:36:37 -08:00
George Kalpakas e8a57f0ee6 test(upgrade): log more info to help debug CI flakes (#28045)
Related Jira issue: FW-939

PR Close #28045
2019-01-10 11:03:26 -08:00
Kristiyan Kostadinov a6ba789599 fix(ivy): init hooks being re-run if an exception is throw (#28024)
Fixes Ivy running the init hooks if an exception is thrown in one of them.

These changes fix FW-830.

PR Close #28024
2019-01-10 11:01:37 -08:00
Pawel Kozlowski 3bafc002ae test(ivy): update root cause for @angular/core (#28046)
FW-822 is a delibrate breaking change so changing the status of the
corresponding test from fixmeIvy to modifiedInIvy.

PR Close #28046
2019-01-10 10:57:51 -08:00
Pawel Kozlowski afaea110c7 fix(ivy): pipe returning WrappedValue should invalidate correct binding (#28044)
When a pipe returns an instance of WrappedValue we should "invalidate" value
of a binding where the pipe in question is used.

Before this change we've always wrtten the invalidation value (NO_CHANGE) to
the binding root this invalidating the first binding in a LView. This commit
corrects the binding index calculation so the binding with a pipe is invalidated.

PR Close #28044
2019-01-10 10:57:01 -08:00
Kara Erickson dffcb9cda3 ci: onlyInIvy tests should not be triggered for FIND_PASSING_TESTS mode (#28036)
Previous to this change, there was a lot of noise when
trying to find tests in FIND_PASSING_TESTS mode because
tests marked "onlyInIvy" were also listed as "already
passing". Since these tests are not "fixmes" that need
to be enabled, it is not useful to have them listed.

This commit removes "onlyInIvy" tests from consideration
when running in this manual mode. The tests should still
run on CI by default (since FIND_PASSING_TESTS mode will
be false).

PR Close #28036
2019-01-10 10:55:58 -08:00
Kara Erickson ee60c7679a test(ivy): turn on passing i18n test in CI (#28035)
PR Close #28035
2019-01-10 10:54:38 -08:00
Kara Erickson e0e92cfef6 test(ivy): diagnose root causes of remaining failing router tests (#28035)
PR Close #28035
2019-01-10 10:54:37 -08:00
Paul Gschwendtner 65e72e958e fix(bazel): protractor rule does not run spec files with underscore (#28022)
There are various e2e tests with the `_spec.ts` suffix in the Angular project. Currently the protractor Bazel rule does not pick up these files and just ignores them. Since underscore is commonly used, we should support this.

Needed for the conversion fo the `examples` to Bazel.

PR Close #28022
2019-01-10 10:53:25 -08:00
Marc Laval 76ed13bffe fix(ivy): directives without selector should not be supported (#28021)
PR Close #28021
2019-01-10 10:51:30 -08:00
Andrew Kushnir c5ab3e8fd2 fix(ivy): proper resolution of Enums in Component decorator (#27971)
Prior to this change Component decorator was resolving `encapsulation` value a bit incorrectly, which resulted in `encapsulation: NaN` in compiled code. Now we resolve the value as Enum memeber and throw if it's not the case. As a part of this update, the `changeDetection` field handling is also added, the resolution logic is the same as the one used for `encapsulation` field.

PR Close #27971
2019-01-10 10:49:03 -08:00
Alex Rickabaugh 142553abc6 feat(ivy): accept multiple values for exportAs in the compiler (#28001)
exportAs in @Directive metadata supports multiple values, separated by
commas. Previously it was treated as a single value string.

This commit modifies the compiler to understand that exportAs is a
string[]. It stops short of carrying the multiple values through to the
runtime. Instead, it only emits the first one. A future commit will modify
the runtime to accept all the values.

PR Close #28001
2019-01-10 10:47:49 -08:00
Alex Rickabaugh 6003145422 fix(ivy): properly rewrite imports in generated factory shims (#27998)
Generated factory shims can import from @angular/core. However, we have
special logic in place to rewrite self-imports when generating code for
@angular/core.

This commit leverages the new standalone ImportRewriter interface to
properly rewrite imports in generated factory shims. Before this fix,
a generated factory file for core would look like:

```typescript
import * as i0 from './r3_symbols';

export var ApplicationModuleNgFactory = new ɵNgModuleFactory(...);
```

This is invalid, as ɵNgModuleFactory is just NgModuleFactory when imported
via r3_symbols.

FW-881 #resolve

PR Close #27998
2019-01-10 10:46:32 -08:00
Alex Rickabaugh 3cf1b62722 refactor(ivy): extract import rewriting into a separate interface (#27998)
Currently the ImportManager class handles various rewriting actions of
imports when compiling @angular/core. This is required as code compiled
within @angular/core cannot import from '@angular/core'. To work around
this, imports are rewritten to get core symbols from a particular file,
r3_symbols.ts.

In this refactoring, this rewriting logic is moved out of the ImportManager
and put behind an interface, ImportRewriter. There are three implementers
of the interface:

* NoopImportRewriter, used for compiling all non-core packages.
* R3SymbolsImportRewriter, used when ngtsc compiles @angular/core.
* NgccFlatImportRewriter, used when ngcc compiles @angular/core (special
  logic is needed because ngcc has to rewrite imports in flat bundles
  differently than in non-flat bundles).

This is a precursor to using this rewriting logic in other contexts besides
the ImportManager.

PR Close #27998
2019-01-10 10:46:32 -08:00
Keen Yee Liau 5a0deb8d69 fix(bazel): Add @bazel/bazel to dev deps (#28032)
Project created by @angular/cli depends on Bazel at build time and
we should not assume that Bazel is available globally.
Instead, the project should specify an explicit dev dependency on
`@bazel/bazel`.

PR Close #28032
2019-01-09 17:45:16 -08:00
Andrew Kushnir 4694c93315 refactor(ivy): avoid `transitiveScopesFor` function duplication in TestBed (#27860)
TestBed used to have its own implementation of the `transitiveScopesFor` function, customized for TestBed needs (to compile NgModules). This change unifies the `transitiveScopesFor` function usage by importing it from the `jit/module.ts` script and adding extra argument to configure its behavior (how to compile NgModule), so that TestBed can leverage it.

PR Close #27860
2019-01-09 17:13:11 -08:00
Matias Niemelä 94c0b7a362 fix(ivy): ensure animation @bindings work for {key:value} and empty bindings (#28026)
PR Close #28026
2019-01-09 16:12:17 -08:00
Matias Niemelä 0136274f33 test(ivy): update root causes for animation tests (#28026)
PR Close #28026
2019-01-09 16:12:17 -08:00
Kara Erickson 8934b736c8 test(ivy): re-enable passing upgrade tests (#28030)
PR Close #28030
2019-01-09 16:03:02 -08:00
Alex Rickabaugh 11325bad4a test(ivy): mark jit_summaries_integration_spec as obsolete in Ivy (#28027)
These tests validate the ability of the View Engine TestBed to consume
summary metadata, a mechanism which allows the TestBed to use
AOT-compiled components & directives in tests. It achieves this through
two operations which are independently obsolete in Ivy:

1. It injects CompileMetadataResolver, a View Engine specific compiler
   internal class which extracts global analysis metadata from classes,
   and uses it to construct summary metadata. This happens in a
   beforeEach() block which calls createSummaries().

2. It uses TestBed.initTestEnvironment to pass summary metadata to the
   TestBed itself. Any such metadata is ignored in Ivy.

Operation #1 makes it impossible to run these tests under Ivy, as the
CompileMetadataResolver is not available with an Ivy compiler.

Ivy itself does not rely on summary data, and the R3TestBed can depend
directly on AOT compiled components without it. Thus, the spirit of thes
tests is obsolete in an Ivy world.

FW-838 #resolve

PR Close #28027
2019-01-09 15:38:48 -08:00
Pawel Kozlowski e1e4887feb refactor(ivy): merge canInsertNativeNode and getParentNative (#28011)
Previously the canInsertNativeNode and getRenderParent functions had almost
_exaclty_ the same logic. What was worse that getRenderParent was calling
canInsertNativeNode thus executing the same, non-trivial logic twice.

This commit merges canInsertNativeNode and getRenderParent into one function.
Now getRenderParent will return a native parent or null if a node can't be
inserted (content projection, root of a view that is not inserted etc.).

PR Close #28011
2019-01-09 15:35:57 -08:00
Pawel Kozlowski 6f9881f85f refactor(ivy): remove concept of RENDER_PARENT from LContainer (#28011)
PR Close #28011
2019-01-09 15:35:57 -08:00
Pawel Kozlowski 6beeb76ac0 fix(ivy): don't cache render parent on LContainer to support ngUpgrade (#28011)
PR Close #28011
2019-01-09 15:35:57 -08:00
Pawel Kozlowski 1f904bffbc refactor(ivy): simplify logic around canInsertNativeNode (#28011)
Previously presence and type of a parent tNode was split among
canInsertNativeNode, canInsertNativeChildOfView and canInsertNativeChildOfElement.
This commit centralises the logic in canInsertNativeNode thus simplifying
the overall logic and making canInsertNativeChildOfElement trivial.

PR Close #28011
2019-01-09 15:35:57 -08:00
Meknassih 9b2b9b3bef docs(core): add missing closing backtick (`) (#27908)
PR Close #27908
2019-01-09 12:44:13 -08:00
Ivan Tham 91a8a4fb28 docs(forms): remove duplicated link (#27884)
PR Close #27884
2019-01-09 12:43:29 -08:00
Marc Laval 5609764886 test(ivy): add root causes for router TestBed failures (#28014)
PR Close #28014
2019-01-09 11:49:45 -08:00
Keen Yee Liau 29e3144269 build(bazel): List explicit dependencies in WORKSPACE (#28000)
Instead of relying on implicit dependencies through Angular, the WORKSPACE
of the project should explicitly add rules_nodejs and rules_typescript so
it can better control the versions.

PR Close #28000
2019-01-09 11:49:08 -08:00
JoostK d68ad3e617 fix(ivy): ngcc - recognize synthesized constructors (#27897)
A constructor function may have been "synthesized" by TypeScript during
JavaScript emit, in the case no user-defined constructor exists and e.g.
property initializers are used. Those initializers need to be emitted
into a constructor in JavaScript, so the TypeScript compiler generates a
synthetic constructor.

This commit adds identification of such constructors as ngcc needs to be
able to tell if a class did originally have a constructor in the
TypeScript source. When a class has a superclass, a synthesized
constructor must not be considered as a user-defined constructor as that
prevents a base factory call from being created by ngtsc, resulting in a
factory function that does not inject the dependencies of the superclass.
Hence, we identify a default synthesized super call in the constructor
body, according to the structure that TypeScript emits.

PR Close #27897
2019-01-09 11:48:10 -08:00
Paul Gschwendtner 935ce63b73 fix(bazel): flat module misses AMD module name on windows (#27839)
* Fixes that the flat module out files do not have a proper AMD module name on Windows. This is currently blocking serving a `ng_module` using the Bazel TypeScript `devserver` on Windows.

PR Close #27839
2019-01-09 10:42:37 -08:00
Dario Braun d2b2d813d5 docs(core): fix characters that corrupt link (#27982)
PR Close #27982
2019-01-09 10:38:22 -08:00
Andrew Kushnir 72fc0a747d test(ivy): updating root causes for tests within @angular/core (#28003)
The problem that `fixmeIvy`s refer to is resolved, but the tests are still broken due to other issue (not possible to retrieve host property bindings for DebugElement).

PR Close #28003
2019-01-09 10:34:50 -08:00
Kara Erickson cea3b8f885 test(ivy): update root cause of linker test (#28004)
PR Close #28004
2019-01-09 10:33:54 -08:00
George Kalpakas 4e17212d44 test(upgrade): properly clean up after tests to avoid errors in unrelated tests (#28013)
Many `ngUpgrade` tests need to manually [bootstrap modules][1] (instead
of using `TestBed` which automatically cleans up) and thus need to also
manually clean up afterwards (e.g. by calling [destroyPlatform()][2]
after each test).

Failing to destroy the platform is usually not a problem, unless the
next test tries to manually destroy it (as a precaution), as happens
[here][3] (among other places).

More specifically, the problem happens, because (as part of the clean-up
happening on platform destruction) upgraded components will try to
[call a method][4] on `angular.element` after `angular` has been
[set to `undefined`][5] (assuming the last test was using the
[withEachNg1Version()][6] helper).

Because the test order is pseudo-random and thus different on each run,
these errors did not always come up and - when they did- they would go
away after a couple of reruns, making them appear as flakes on CI.

(For reference, the issue was introduced in 43c33d566.)

This commit eliminates the issue by always destroying the platform after
each `ngUpgrade` test.

Jira issue: FW-924

[1]: c3aa24c3f9/packages/upgrade/test/static/test_helpers.ts (L21)
[2]: c3aa24c3f9/packages/upgrade/test/static/integration/upgrade_component_spec.ts (L24)
[3]: c3aa24c3f9/packages/elements/test/create-custom-element_spec.ts (L31)
[4]: c3aa24c3f9/packages/upgrade/src/common/upgrade_helper.ts (L134-L135)
[5]: c3aa24c3f9/packages/upgrade/test/common/test_helpers.ts (L115)
[6]: c3aa24c3f9/packages/upgrade/test/common/test_helpers.ts (L31)

PR Close #28013
2019-01-09 10:27:46 -08:00
Andrew Kushnir c3aa24c3f9 fix(ivy): sanitization for Host Bindings (#27939)
This commit adds sanitization for `elementProperty` and `elementAttribute` instructions used in `hostBindings` function, similar to what we already have in the `template` function. Main difference is the fact that for some attributes (like "href" and "src") we can't define which SecurityContext they belong to (URL vs RESOURCE_URL) in Compiler, since information in Directive selector may not be enough to calculate it. In order to resolve the problem, Compiler injects slightly different sanitization function which detects proper Security Context at runtime.

PR Close #27939
2019-01-08 17:17:04 -08:00
Alex Rickabaugh 1c39ad38d3 feat(ivy): reference external classes by their exported name (#27743)
Previously, ngtsc would assume that a given directive/pipe being imported
from an external package was importable using the same name by which it
was declared. This isn't always true; sometimes a package will export a
directive under a different name. For example, Angular frequently prefixes
directive names with the 'ɵ' character to indicate that they're part of
the package's private API, and not for public consumption.

This commit introduces the TsReferenceResolver class which, given a
declaration to import and a module name to import it from, can determine
the exported name of the declared class within the module. This allows
ngtsc to pick the correct name by which to import the class instead of
making assumptions about how it was exported.

This resolver is used to select a correct symbol name when creating an
AbsoluteReference.

FW-517 #resolve
FW-536 #resolve

PR Close #27743
2019-01-08 16:36:18 -08:00
Alex Rickabaugh 0b9094ec63 feat(ivy): produce diagnostics for missing exports, incorrect entrypoint (#27743)
This commit adds tracking of modules, directives, and pipes which are made
visible to consumers through NgModules exported from the package entrypoint.
ngtsc will now produce a diagnostic if such classes are not themselves
exported via the entrypoint (as this is a requirement for downstream
consumers to use them with Ivy).

To accomplish this, a graph of references is created and populated via the
ReferencesRegistry. Symbols exported via the package entrypoint are compared
against the graph to determine if any publicly visible symbols are not
properly exported. Diagnostics are produced for each one which also show the
path by which they become visible.

This commit also introduces a diagnostic (instead of a hard compiler crash)
if an entrypoint file cannot be correctly determined.

PR Close #27743
2019-01-08 16:36:18 -08:00
Alex Rickabaugh ac157170c8 feat(forms): export NumberValueAccessor & RangeValueAccessor directives (#27743)
@angular/forms declares several directives and a module which are not
exported from the package via the entrypoint, either intentionally or as a
historical accident.

Ivy's locality principle necessitates that directives used in user code be
importable from the package which defines them. This requires these forms
directives to be exported.

Several directives which define ControlValueAccessors are exported:

* NumberValueAccessor
* RangeValueAccessor

A few more directives and a module are exported privately (with a ɵ prefix):

* NgNoValidate
* NgSelectMultipleOption
* InternalFormsSharedModule

PR Close #27743
2019-01-08 16:36:18 -08:00
Alex Rickabaugh f4a9f5dae8 refactor(ivy): prep ngtsc and ngcc for upcoming import resolution work (#27743)
Upcoming work to implement import resolution will change the dependencies
of some higher-level classes in ngtsc & ngcc. This necessitates changes in
how these classes are created and the lifecycle of the ts.Program in ngtsc
& ngcc.

To avoid complicating the implementation work with refactoring as a result
of the new dependencies, the refactoring is performed in this commit as a
separate prepatory step.

In ngtsc, the testing harness is modified to allow easier access to some
aspects of the ts.Program.

In ngcc, the main change is that the DecorationAnalyzer is created with the
ts.Program as a constructor parameter. This is not a lifecycle change, as
it was previously created with the ts.TypeChecker which is derived from the
ts.Program anyways. This change requires some reorganization in ngcc to
accommodate, especially in testing harnesses where DecorationAnalyzer is
created manually in a number of specs.

PR Close #27743
2019-01-08 16:36:18 -08:00
Alex Rickabaugh 2a6108af97 refactor(ivy): split apart the 'metadata' package in the ngtsc compiler (#27743)
This refactoring moves code around between a few of the ngtsc subpackages,
with the goal of having a more logical package structure. Additional
interfaces are also introduced where they make sense.

The 'metadata' package formerly contained both the partial evaluator,
the TypeScriptReflectionHost as well as some other reflection functions,
and the Reference interface and various implementations. This package
was split into 3 parts.

The partial evaluator now has its own package 'partial_evaluator', and
exists behind an interface PartialEvaluator instead of a top-level
function. In the future this will be useful for reducing churn as the
partial evaluator becomes more complicated.

The TypeScriptReflectionHost and other miscellaneous functions have moved
into a new 'reflection' package. The former 'host' package which contained
the ReflectionHost interface and associated types was also merged into this
new 'reflection' package.

Finally, the Reference APIs were moved to the 'imports' package, which will
consolidate all import-related logic in ngtsc.

PR Close #27743
2019-01-08 16:36:18 -08:00
Alex Rickabaugh 37b716b298 refactor(ivy): move the flat module index generator to its own package (#27743)
This commit moves the FlatIndexGenerator to its own package, in preparation
to expand its capabilities and support re-exporting of private declarations
from NgModules.

PR Close #27743
2019-01-08 16:36:18 -08:00
Miško Hevery b9c6df6da7 fix(ivy): use NgZone.onStable when bootstraped using PlatformRef (#27898)
PR Close #27898
2019-01-08 14:10:53 -08:00
Kara Erickson 1a7f92c423 test(ivy): re-enable passing animation tests (#27997)
PR Close #27997
2019-01-08 14:07:31 -08:00
Pawel Kozlowski 090801532e test(ivy): update root cause analysis for the remaining query-related test (#27985)
PR Close #27985
2019-01-08 11:54:16 -08:00
Pawel Kozlowski b432eb1cae refactor(ivy): simplify signature of appendChild / removeChild (#27987)
Previously the appendChild / removeChild could take null as an argument for
a child to be added / removed. This is difficult to understand since the
mentioned methods are noop if a child is null.

This commit clarifies the appendChild / removeChild signature to systematically
require a child node to be added removed. It turns out that null could be passed
only for a very specific i18n cases so now we guard a call to removeChild with
an explicit check on the i18n side.

PR Close #27987
2019-01-08 11:26:07 -08:00
Pawel Kozlowski aaa97f11d7 test(ivy): mark changed behaviour for queries and ng-container (#27977)
PR Close #27977
2019-01-08 10:37:39 -08:00
Olivier Combe 4b5b1f6d16 test(ivy): enable i18n test for nested templates (#27984)
The bug that was causing this test to fail has been resolved (see FW-903). The test now runs correctly.
PR Close #27984
2019-01-08 10:36:55 -08:00
Marc Laval c2f19515d6 test(ivy): enable last test in view injector integration spec (#27989)
PR Close #27989
2019-01-08 10:35:24 -08:00
Andrew Kushnir 6e7c46af1b fix(ivy): adding event listeners for global objects (window, document, body) (#27772)
This update introduces support for global object (window, document, body) listeners, that can be defined via host listeners on Components and Directives.

PR Close #27772
2019-01-08 10:33:17 -08:00
Andrew Kushnir f5471107d9 test(ivy): root causes update for 'platform-browser-dynamic' and i18n tests (#27972)
PR Close #27972
2019-01-07 20:27:50 -08:00
Olivier Combe e6ab55daa0 fix(ivy): don't throw in `i18nAttributes` when a component is re-rendered (#27911)
`i18nAttributes` was throwing an error when it was called multiple times in the create part of the template function with the same index, for example when we create multiple components with the same template. It shouldn't throw in this case, and just use the cache when available.

FW-903 #resolve
PR Close #27911
2019-01-07 20:21:49 -08:00
Paul Gschwendtner 98472da03f build: remove "build.sh" script (#27937)
this script is now obsolete and not needed any more. yay!!!

PR Close #27937
2019-01-07 15:35:09 -08:00
Paul Gschwendtner 7ac8b02ec5 build: remove "test.sh" script (#27937)
test.sh is no longer needed... all the tests should now be executed via bazel.

if for whatever reason we need to run the legacy unit test setup, we should should follow the commands that we use to execute those tests in .circle/config.yaml

PR Close #27937
2019-01-07 15:35:09 -08:00
Paul Gschwendtner 7de7b7a16a ci: move e2e tests from travis to circleci (#27937)
PR Close #27937
2019-01-07 15:35:09 -08:00
Igor Minar 04ca3bcf10 ci: move local and saucelabs unit tests to circle (#27937)
Moving the tests over to CircleCI in pretty much "as-is" state just so that we can drop the dependency on Travis.

In the followup changes we plan to migrate these tests to run on sauce under bazel. @gregmagolan is working on that.

I've previously verified that all the tests executed in legacy-unit-tests-local already under bazel.
Therefore the legacy-unit-tests-local job is strictly not necessary any more, but given how flaky legacy-unit-tests-saucelabs is,
it is good to have the -local job just so that we can quickly determine if any failure is a flake or legit issue
(the bazel version of these tests could theoretically run in a slightly different way and fail or not fail in a different way, so having -lcoal job is just an extra safety check).

This change was coauthored with @devversion

PR Close #27937
2019-01-07 15:35:09 -08:00
Kristiyan Kostadinov c1dacdd890 fix(ivy): QueryList not instance of exported QueryList (#27942)
Fixes Ivy's `QueryList` not being an instance of the exported ViewEnginer `QueryList`.

Also reworks `first`, `last` and `length` to be regular properties, rather than setters. Reworking `length` was required to be able to extend the ViewEngine `QueryList`, but I reworked `first` and `last` as well since getters generate a lot more code when transpiled to ES5.

These changes fix FW-706.

PR Close #27942
2019-01-07 15:26:47 -08:00
Paul Gschwendtner 9de9c8ad03 fix(bazel): protractor utils cannot start server on windows (#27915)
* Currently the protractor utils assume that the specified Bazel server runfile can be resolved by just using the real file system. This is not the case on Windows because the runfiles are not symlinked into the working directory and need to be resolved through the runfile manifest.

PR Close #27915
2019-01-07 14:49:44 -08:00
Andrew Kushnir 4613864fc8 test(ivy): add i18n integration tests via TestBed (#27852)
PR Close #27852
2019-01-07 14:47:24 -08:00
Paul Gschwendtner ac5f5ed0a6 test(bazel): re-enable ng_package golden testing on ci (#27829)
* Enables the ng_package golden testing on the CI
* Fixes the ng_package golden testing for Windows

PR Close #27829
2019-01-07 14:46:47 -08:00
Paul Gschwendtner 8122970f63 test(bazel): fix all ng_package tests not working on windows (#27829)
PR Close #27829
2019-01-07 14:46:47 -08:00
Paul Gschwendtner 8473d68ea8 fix(bazel): packager not properly removing amd directives on windows (#27829)
PR Close #27829
2019-01-07 14:46:46 -08:00
Paul Gschwendtner 4caf6540d1 fix(bazel): ng_package creates invalid typings reexport on windows (#27829)
Currently when building a package on Windows, the typings re-export for secondary entry-points is not valid TypeScript. Similarly the metadata and the "package.json" files use non-posix paths and cause inconsistency within the NPM package.

For example:

_package.json_
```
  "esm5": "./esm5\\core.js",
  "esm2015": "./esm2015\\core.js",
```

_testing.d.t.s_ (of the `core` package)
```
export * from './testing\testing';
```

PR Close #27829
2019-01-07 14:46:46 -08:00
Andrew Kushnir a75c734471 fix(ivy): restore NG defs after running tests in TestBed (#27786)
`R3TestBed` allows consumers to configure a "testing module", declare components, override various metadata, etc. To do this, it implements its own JIT compilation, where components/directives/modules have Ivy definition fields generated based on testing metadata. It results in tests interfering with each other. One test might override something in a component that another test tries to use normally, causing failures.

In order to resolve this problem, we store current components/directives/modules defs before applying overrides and re-compiling. Once the test is complete, we restore initial defs, so the next tests interact with "clean" components.

PR Close #27786
2019-01-07 14:44:14 -08:00
Marc Laval e775313188 fix(ivy): ngOnDestroy hooks should be called on providers (#27955)
PR Close #27955
2019-01-07 14:43:33 -08:00
Marc Laval 996435b79a refactor(ivy): remove TView.pipeDestroyHooks (#27955)
PR Close #27955
2019-01-07 14:43:33 -08:00
Pawel Kozlowski 45880532bf test(ivy): update root causes for @angular/core tests (#27961)
PR Close #27961
2019-01-07 08:44:57 -08:00
Pawel Kozlowski e08feb7e54 refactor(ivy): unify native node handling around render parent and element / ICU containers (#27925)
PR Close #27925
2019-01-07 08:36:51 -08:00
Pawel Kozlowski 8a3cebde8b fix(ivy): support ICU messages inside <ng-container> (#27925)
PR Close #27925
2019-01-07 08:36:51 -08:00
Pawel Kozlowski d80c32310a refactor(ivy): remove code duplication in native nodes manipulation (#27925)
PR Close #27925
2019-01-07 08:36:51 -08:00
Pawel Kozlowski 3ac249b2ab refactor(ivy): renames and documentation updates (#27925)
PR Close #27925
2019-01-07 08:36:50 -08:00
Kara Erickson 6b0c1a71fa test(ivy): turn on platform-browser-dynamic tests on CI (#27940)
We missed removing the `fixme-ivy-aot` bazel tag from the BUILD file
of platform-browser-dynamic, so we weren't running the
`//packages/platform-browser-dynamic/test:test_web_chromium-local`
test target on CI. This commit turns on the tests and adds root causes
where they are known.

PR Close #27940
2019-01-05 17:48:11 -08:00
Greg Magolan e7f43386a6 build: update to Bazel 0.21.0 (#27935)
PR Close #27935
2019-01-04 18:38:44 -08:00
Miško Hevery 411de252d7 fix(ivy): disable test which rely on DebugElement in WebWorker (#27895)
PR Close #27895
2019-01-04 18:37:31 -08:00
Alan Agius b61dafaeac refactor: remove redundant error in catch (#25478)
PR Close #25478
2019-01-04 15:42:19 -08:00
Marc Laval 929334b0bf fix(ivy): should not throw when getting VCRef.parentInjector on the root view (#27909)
PR Close #27909
2019-01-04 14:57:39 -08:00
Marc Laval fb7816fed4 fix(ivy): element injector on the host of a component should see viewProviders of that component (#27928)
PR Close #27928
2019-01-04 14:46:15 -08:00
Matias Niemelä 5d3dcfc6ad fix(ivy): ensure @animation host bindings/listeners work properly (#27896)
PR Close #27896
2019-01-04 14:12:29 -08:00
Marc Laval 0bd9deb9f5 fix(ivy): pipes should overwrite pipes with later entry in the pipes array (#27910)
PR Close #27910
2019-01-04 13:21:46 -08:00
Kristiyan Kostadinov 13d23f315b fix(ivy): ngtsc program emit ignoring custom transformers (#27837)
Fixes the `customTransformers` that are passed to the `NgtscProgram.emit` not being passed along.

PR Close #27837
2019-01-04 12:29:15 -08:00
George Kalpakas 48555f95c6 fix(ivy): ensure unique template and listener function identifiers (#27766)
Previously, there could be identical template/listener function names
for a component's template, if it had multiple similarly structured
nested sub-templates or listeners.
This resulted in build errors:
`Identifier '<SOME_IDENTIFIER>' has already been declared`

This commit fixes this by ensuring that the template index is included
in the `contextName` passed to the `TemplateDefinitionBuilder`
responsible for processing nested sub-templates.
Similarly, the template or element index is included in the listener
names.

PR Close #27766
2019-01-04 12:28:11 -08:00
George Kalpakas d026b675be refactor(ivy): minor refactoring / code clean-up (#27766)
PR Close #27766
2019-01-04 12:28:11 -08:00
Kara Erickson 7eb2c41fb2 fix(ivy): ng-content tags in re-inserted templates should walk declaration tree (#27783)
This PR assures that content projection works if an <ng-content> tag is
placed inside an <ng-template> in one component and that <ng-template>
is inserted into a different component. It fixes a bug where the
projection instruction code would walk up the insertion tree to find
selector data instead of the declaration tree.

PR Close #27783
2019-01-04 12:20:18 -08:00
Andrew Kushnir 3f2ebbd7ab fix(ivy): support bindings in ICUs in nested contexts (#27914)
Prior to this change, ICU extraction logic was not taking into account nested bindings (that look like this: �0:1�) and only accounted for top level bindings (like this �0�). As a result, ICUs were not parsed and remained as text in the output. Now the extraction logic (regular expressions) take into account the nested bindings format as well.

PR Close #27914
2019-01-04 12:19:46 -08:00
Andrew Kushnir 38b4d15227 fix(ivy): implement 'TestBed.overrideTemplateUsingTestingModule' function (#27717)
Adding 'TestBed.overrideTemplateUsingTestingModule' function that overrides Component template and uses TestingModule as a scope.

PR Close #27717
2019-01-04 12:19:20 -08:00
Ben Lesh 51a0bd2e75 test(ivy): correct attribute marker in broken test (#27919)
Test incorrectly marks the attribute as a 'Class', when it should be 'SelectOnly'

PR Close #27919
2019-01-03 16:10:00 -08:00
Fabian Wiles 1b0b36d143 fix(forms): match getError and hasError to get method signature (#20211)
Internally getError and hasError call the AbstractControl#get method which takes  `path: Array<string | number> | string` as input, since there are different ways to traverse the AbstractControl tree.
This change matches the method signitures of all methods that use this.

PR Close #20211
2019-01-03 10:16:06 -08:00
Kara Erickson e268a0579a docs(forms): update desc for hasError and getError (#27861)
This commit adds docs for the changes made in #20211.

Closes #19734.

PR Close #27861
2019-01-03 10:15:23 -08:00
Misko Hevery 1f1e77b641 fix(ivy): don’t publish animation bindings as attributes (#27805)
Some of the animation tests have been failing because animation gets
triggered multiple times. The reason for this is that the compiler was
generating static attribute bindings in addition to dynamic bindings.
This created multiple writes to the animation render which failed the
tests.

PR Close #27805
2019-01-03 09:39:25 -08:00
crisbeto 5fee444fea test(ivy): update test failure root cause (#27855)
Updates the root cause for a couple of the test failures.

PR Close #27855
2019-01-03 09:37:26 -08:00
Paul Gschwendtner 1e6c9be86c fix(bazel): unable to launch protractor test on windows (#27850)
Due to an incorrect environment variable name, it's currently not possible to launch Protractor on Windows using the Bazel protractor rule.

PR Close #27850
2019-01-03 09:36:37 -08:00
Andrew Kushnir a9790018df fix(ivy): resolve `forwardRefs` correctly in TestBed (JIT) (#27737)
Forward refs in some places (like imports/export/providers/viewProviders/queries) were not resolved before passing to compilation phase. Now we resolve missing refs before invoking compile function.

PR Close #27737
2019-01-03 09:34:15 -08:00
Marc Laval b7d0ab7de3 test(ivy): enable more @angular/core tests (#27912)
PR Close #27912
2019-01-03 09:22:22 -08:00
Marc Laval 460be795cf test(ivy): add root cause analysis for failing core tests (view injector integration) (#27912)
PR Close #27912
2019-01-03 09:22:22 -08:00
Judy Bogart c4f7727408 docs: add api doc for viewport scroller (#27381)
PR Close #27381
2018-12-26 11:47:16 -08:00
Alex Eagle d1de9ff313 build: update to latest rules_nodejs (#27764)
This includes a performance fix for module resolution in the common case under Ivy

PR Close #27764
2018-12-26 11:31:37 -08:00
Olivier Combe c34eee4e8e test(ivy): root cause analysis for `@angular/platform-server` (#27800)
PR Close #27800
2018-12-26 11:17:45 -08:00
Michael De Wree 9b91beed69 docs: fix typo explictly (#27798)
Closes #27796

PR Close #27798
2018-12-26 06:57:55 -05:00
Matias Niemelä eea2b0f288 revert: fix(router): ensure URL is updated after second redirect with UrlUpdateStrategy="eager" (#27523) 2018-12-25 22:14:07 -08:00
Matias Niemelä 13eb57a59f fix(ivy): merge static style rendering across elements, directives and components (#27661)
PR Close #27661
2018-12-21 18:14:44 -05:00
Andrew Kushnir 4b67b0af3e fix(ivy): adding TestBed.overrideProvider support (#27693)
Prior to this change, provider overrides defined via TestBed.overrideProvider were not applied to Components/Directives. Now providers are taken into account while compiling Components/Directives (metadata is updated accordingly before being passed to compilation).

PR Close #27693
2018-12-21 16:39:34 -05:00
jnizet bba5e2632e docs(forms): clarify the pattern validator behavior (#27560)
PR Close #27560
2018-12-21 15:12:31 -05:00
Andrew Kushnir 509aa61619 fix(ivy): apply all overrides from TestBed, not the last one only (#27734)
In some cases in our tests we can define multiple overrides for a given class. As a result, only the last override is actually applied due to the fact that we store overrides in a Type<->Override map. This update changes the logic to keep all overrides defined in a given test for a Type (i.e. Type<->Override[] map) and applies them one by one at resolution phase. This behavior is more inline with the previous TestBed.

PR Close #27734
2018-12-21 15:09:00 -05:00
Pawel Kozlowski cdd737e28b test(ivy): mark tests using getDebugContext as obsolete in ivy (#27790)
PR Close #27790
2018-12-21 15:07:31 -05:00
Marc Laval 5da55d6246 test(ivy): add root cause analysis for failing router tests (#27792)
PR Close #27792
2018-12-21 15:06:56 -05:00
George Kalpakas 50a91ba28c docs(upgrade): add gotchas/tips/example for multiple downgraded modules (#27217)
PR Close #27217
2018-12-20 16:20:41 -05:00
George Kalpakas 077a5fb04b test(upgrade): test injector tree traversal for downgraded components (#27217)
This commit adds tests that verify the current behavior wrt injector
tree traversal for downgraded components, so that it is easier to
contrast with changed behavior is future commits (should we decide
to actually change it).

PR Close #27217
2018-12-20 16:20:41 -05:00
George Kalpakas bc0ee01d09 fix(upgrade): allow nesting components from different downgraded modules (#27217)
PR Close #27217
2018-12-20 16:20:41 -05:00
George Kalpakas 326b464d20 fix(upgrade): correctly handle nested downgraded components with `downgradeModule()` (#27217)
Previously, nested downgraded components would not be created/destroyed
inside the Angular zone (as they should) and they would not be wired up
correctly for change detection.

This commit ensures that ngUpgrade correctly detects whether this is an
ngUpgradeLite app (i.e. one using `downgradeModule()` instead of
`UpgradeModule`) and appropriately handles components, even if they are
nested inside other downgraded components.

Fixes #22581
Closes #22869
Closes #27083

PR Close #27217
2018-12-20 16:20:41 -05:00
George Kalpakas 8a7498e0ef refactor(upgrade): simplify special handling of ngUpgradeLite in `downgradeComponent()` (#27217)
PR Close #27217
2018-12-20 16:20:41 -05:00
Jason Aden 07ada7f3d9 fix(router): ensure URL is updated after second redirect with UrlUpdateStrategy="eager" (#27523)
Navigating to a route such as `/users`, you may get redirected to `/login`. Previously, if you go then route to `/users` again the URL will end up showing `/users` after the second redirect. This only happened in `UrlUpdateStrategy="eager"`. This is now fixed so after the second redirect, the URL shows the correct page.

Fixes #27116

PR Close #27523
2018-12-20 16:18:52 -05:00
Matias Niemelä 880e8a5cfc refactor: fix broken formatting 2018-12-20 09:16:09 -08:00
Pawel Kozlowski a0585c9a9a fix(ivy): correct content projection with nested templates (#27755)
Previously ivy code generation was emmiting the projectionDef instruction in
a template where the <ng-content> tag was found. This code generation logic was
incorrect since the ivy runtime expects the projectionDef instruction to be present
in the main template only.

This PR ammends the code generation logic so that the projectionDef instruction is
emmitedin the main template only.

PR Close #27755
2018-12-20 12:01:20 -05:00
Kristiyan Kostadinov a833b98fd0 fix(ivy): change detection strategy not being passed to compiler (#27753)
Fixes the defined change detection strategy not being passed to the compiler when a component is being compiled.

PR Close #27753
2018-12-20 12:00:58 -05:00
Pete Bacon Darwin 4b70a4e905 feat(ivy): support NgModule metadata from calls that do not return ModuleWithProviders types (#27326)
Normally functions that return `ModuleWithProvider` objects should parameterize
the return type to include the type of `NgModule` that is being returned. For
example `forRoot(): ModuleWithProviders<RouterModule>`.

But in some cases, especially those generated by nccc, these functions to not
explicitly declare `ModuleWithProviders` as their return type. Instead they
return a "intersection" type, one of whose members is a type literal that
declares the `NgModule` type returned. For example:
`forRoot(): CustomType&{ngModule:RouterModule}`.

This commit changes the `NgModuleDecoratorHandler` so that it can extract
the `NgModule` type from either kind of declaration.

PR Close #27326
2018-12-20 11:58:50 -05:00
Pete Bacon Darwin f2a1c66031 feat(ivy): ngcc - add typings to `ModuleWithProviders` functions (#27326)
Exported functions or static method that return a `ModuleWithProviders`
compatible structure need to provide information about the referenced
`NgModule` type in their return type.

This allows ngtsc to be able to understand the type of `NgModule` that is
being returned from calls to the function, without having to dig into the
internals of the compiled library.

There are two ways to provide this information:

* Add a type parameter to the `ModuleWithProviders` return type. E.g.

```
static forRoot(): ModuleWithProviders<SomeNgModule>;
```

* Convert the return type to a union that includes a literal type. E.g.

```
static forRoot(): (SomeOtherType)&{ngModule:SomeNgModule};
```

This commit updates the rendering of typings files to include this type
information on all matching functions/methods.

PR Close #27326
2018-12-20 11:58:49 -05:00
Pete Bacon Darwin cfb8c17511 feat(ivy): ngcc - map functions as well as classes from source to typings (#27326)
To support updating `ModuleWithProviders` calls,
we need to be able to map exported functions between
source and typings files, as well as classes.

PR Close #27326
2018-12-20 11:58:49 -05:00
Kara Erickson 99d0e27587 test(ivy): update root cause for core test (#27768)
PR Close #27768
2018-12-20 11:58:14 -05:00
Matias Niemelä 3ab25ab078 refactor: fix broken linting rules due to revert 2018-12-19 13:06:43 -08:00
Marc Laval 8f8572fd3e fix(ivy): @Host should behave as in View Engine (#27646)
PR Close #27646
2018-12-19 15:12:35 -05:00
Alex Eagle e8f7241366 build: fix our copy of Array#find typing (#27742)
It should be nullable, matching the lib.es2015.d.ts from TypeScript

PR Close #27742
2018-12-19 15:11:52 -05:00
Kara Erickson a20b2f72f2 fix(ivy): process creation mode deeply before running update mode (#27744)
Prior to this commit, we had two different modes for change detection
execution for Ivy, depending on whether you called `bootstrap()` or
`renderComponent()`. In the former case, we would complete creation
mode for all components in the tree before beginning update mode for
any component. In the latter case, we would run creation mode and
update mode together for each component individually.

Maintaining code to support these two different execution orders was
unnecessarily complex, so this commit aligns the two bootstrapping
mechanisms to execute in the same order. Now creation mode always
runs for all components before update mode begins.

This change also simplifies our rendering logic so that we use
`LView` flags as the source of truth for rendering mode instead of
`rf` function arguments. This fixed some related bugs (e.g. calling
`ViewRef.detectChanges` synchronously after the view's creation
would create view nodes twice, view queries would execute twice, etc).

PR Close #27744
2018-12-19 15:10:16 -05:00
Jason Aden 12c317603a feat(router): add predicate function mode for runGuardsAndResolvers (#27682)
This option means guards and resolvers will ignore changes when a provided predicate function returns `false`. This supports use cases where an application needs to ignore some param updates but not others. For example, changing a sort param in the URL might need to be ignored, whereas changing the a `project` param might require re-run of guards and resolvers.

Related to #26861 #18253 #27464

PR Close #27682
2018-12-18 13:55:06 -08:00
Miško Hevery 7901cd8cfb fix(ivy): add missing AttributeMarker export (#27485)
PR Close #27485
2018-12-18 13:23:20 -08:00
Keen Yee Liau 2c9b6c0c1f fix(compiler-cli): create LiteralLikeNode for String and Number literal (#27536)
Typescript 3.2 introduced BigInt type, and consequently the
implementation for checkExpressionWorker() in checkers.ts is refactored.

For NumberLiteral and StringLiteral types, 'text' filed must be present
in the Node type, therefore they must be LiteralLikeNode instead of
Node.

PR Close #27536
2018-12-18 13:20:01 -08:00
Igor Minar 17e702bf8b feat: add support for typescript 3.2 (#27536)
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-2.html
https://blogs.msdn.microsoft.com/typescript/2018/11/29/announcing-typescript-3-2/

Any application using tsickle for closure compatibility will need to update it's tsickle
dependency to 0.34

PR Close #27536
2018-12-18 13:20:01 -08:00