Commit Graph

1631 Commits

Author SHA1 Message Date
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
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
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 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
cexbrayat 353362f5a4 docs(core): document isStable traps (#28102)
PR Close #28102
2019-02-06 15:13:19 -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
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
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
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
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
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
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
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
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 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
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
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
Paul Gschwendtner 40d64b6b58 build: run offline_compiler_test using bazel (#28191)
PR Close #28191
2019-01-28 20:07:22 -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
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
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
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
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
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
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
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
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
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 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 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 e0fbe8611e docs: add api doc to template_ref (#27380)
PR Close #27380
2019-01-22 12:13:50 -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
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
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
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
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
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
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
Ernest Galbrun a24120011e docs(core): fix typo (#28042)
PR Close #28042
2019-01-15 09:52:48 -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
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
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
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
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
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
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 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
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
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
Misko Hevery 885f1af509 build: extract interface and util sub compilation from core (#28028)
PR Close #28028
2019-01-10 16:31:44 -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
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 ee60c7679a test(ivy): turn on passing i18n test in CI (#28035)
PR Close #28035
2019-01-10 10:54:38 -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
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 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
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
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
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
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
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
Andrew Kushnir 4613864fc8 test(ivy): add i18n integration tests via TestBed (#27852)
PR Close #27852
2019-01-07 14:47:24 -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
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
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
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
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
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
Michael De Wree 9b91beed69 docs: fix typo explictly (#27798)
Closes #27796

PR Close #27798
2018-12-26 06:57:55 -05: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
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
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
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
Miško Hevery 7901cd8cfb fix(ivy): add missing AttributeMarker export (#27485)
PR Close #27485
2018-12-18 13:23:20 -08:00
Misko Hevery 1c93afe956 fix(ivy): fix property names of ngOnChanges (#27714)
- #reslove FW-812
- #reslove FW-844

PR Close #27714
2018-12-18 10:42:42 -08:00
Miško Hevery e98c57a404 refactor(core): rename spec file to match case of src file 2018-12-17 20:51:00 -08:00
Andrew Kushnir 9bfe42840b fix(ivy): call `hostBindings` function with proper element index (#27694)
We invoked `hostBindings` function in Create and Update modes with different element index due to the fact that we did not subtract HEADER_OFFSET from the index before passing it to `hostBindings` function in Create mode. Now we subtract HEADER_OFFSET value before invoking `hostBindings`, which makes Ceate and Update calls consistent.

PR Close #27694
2018-12-17 16:48:04 -08:00
Olivier Combe 4c1cd1bb78 feat(ivy): support context discovery for containers & ICU expressions (#27644)
Context discovery was only available on elements. This PR adds support for containers and ICU expressions.
FW-378 #resolve
FW-665 #comment linker integration tests

PR Close #27644
2018-12-17 16:47:29 -08:00
Kara Erickson 062c7af4f3 test(ivy): replace resolved issue in compiler-cli test with new root cause (#27709)
PR Close #27709
2018-12-17 16:46:42 -08:00
Marc Laval 8042140742 test(ivy): enable more @angular/core tests (#27654)
PR Close #27654
2018-12-17 16:45:53 -08:00
Miško Hevery e94975d109 fix(ivy): check semantics of NgModule for consistency (#27604)
`NgModule` requires that `Component`s/`Directive`s/`Pipe`s are listed in
declarations, and that each `Component`s/`Directive`s/`Pipe` is declared
in exactly one `NgModule`. This change adds runtime checks to ensure
that these sementics are true at runtime.

There will need to be seperate set of checks for the AoT path of the
codebase to verify that same set of semantics hold. Due to current
design there does not seem to be an easy way to share the two checks
because JIT deal with references where as AoT deals with AST nodes.

PR Close #27604
2018-12-17 14:49:51 -08:00
Pawel Kozlowski d132baede3 test(ivy): add more test for content projection with ngIf / ngFor (#27705)
PR Close #27705
2018-12-17 10:26:30 -08:00
JoostK 84084b1bdb fix(ivy): make exported pipes available in module scope (#27438)
This is tested in the Ivy CLI integration test.

PR Close #27438
2018-12-17 09:35:16 -08:00
JoostK 11600255fb fix(ivy): prevent DCE of __POST_R3__ symbols (#27438)
While creating FESM files, rollup usually drops all unused symbols.
All *__POST_R3__ are unused unless ngcc rewires stuff. To prevent this DCE
we reexport them as private symbols. If ngcc is not used, these symbols will
be dropped when we optimize an application bundle.

PR Close #27438
2018-12-17 09:35:15 -08:00
Andrew Kushnir dfbf6d72b0 fix(ivy): provide an ability to match <ng-template> tags (#27636)
Prior to this change, we were unable to match directives using `ng-template` tags (for example the following selector would not work even though there might be some <ng-template>s in a template: `ng-template[directiveA]`. As a result, that broke some components that relies on such selectors to work. In order to resolve the problem, we now pass tag name to the `template` instruction (where we passed `null` before) and this tag name is used for matching at runtime. This update should also help support projecting containers, because the tag name is required to properly match such elements.

PR Close #27636
2018-12-17 09:33:37 -08:00
Olivier Combe 4df82bdbc1 test(ivy): don't run`ViewEngine` tests for ivy (#27645)
All the tests in `packages/core/test/view/` are specific to the `ViewEngine` and shouldn't run for ivy. This PR introduces a new BUILD.bazel file to run those tests separately.

PR Close #27645
2018-12-14 15:23:15 -08:00
Pawel Kozlowski b00aeeff37 fix(ivy): properly destroy views created by ComponentFactory (#27676)
PR Close #27676
2018-12-14 15:22:11 -08:00
JoostK a9543457ef fix(ivy): prevent invalid forward references in setClassMetadata call (#27561)
In Ivy, a pure call to `setClassMetadata` is inserted to retain the
information that would otherwise be lost while eliding the Angular
decorators. In the past, the Angular constructor decorators were
wrapped inside of an anonymous function which was only evaluated once
`ReflectionCapabilities` was requested for such metadata. This approach
prevents forward references from inside the constructor parameter
decorators from being evaluated before they are available.

In the `setClassMetadata` call, the constructor parameters were not wrapped
within an anonymous function, such that forward references were evaluated
too early, causing runtime errors.

This commit changes the `setClassMetadata` call to pass the constructor
parameter decorators inside of an anonymous function again, such that
forward references are not resolved until requested by
`ReflectionCapabilities`, therefore avoiding the early reads of forward refs.

PR Close #27561
2018-12-14 10:24:16 -08:00
Kristiyan Kostadinov 5d34657198 fix(ivy): attempting to remove detached view on destroy (#27585)
Currently the `ViewRef.destroy` method assumes that its index inside the view container will always be valid, however if it has been removed already, it'll be -1 which will throw an error.

The error manifested itself in one of the unit tests where a view had been detached during the test and then `TestBed` attempted to destroy its `ComponentRef` which ended threw an `Error during cleanup of component`.

PR Close #27585
2018-12-14 10:21:23 -08:00
Alex Eagle d32939d51a build: restrict visibility of npm_package targets (#27611)
dependencies on these cause very long rebuilds which have to re-package angular.
Such tests belong in the integration/ folder

PR Close #27611
2018-12-14 10:20:40 -08:00
Igor Minar d528e30cef test(ivy): update fixmes in packages/core/test/linker/jit_summaries_integration_spec.ts (#27639)
the issues referenced were stale and unrelated.

PR Close #27639
2018-12-14 10:20:18 -08:00
Pawel Kozlowski 10c7b89f14 test(ivy): update root causes for @angular/core TestBed failures (#27650)
PR Close #27650
2018-12-13 14:56:00 -08:00
Pawel Kozlowski 0397e08153 test(ivy): update test status for cases modified in ivy (#27652)
PR Close #27652
2018-12-13 14:55:38 -08:00
Andrew Kushnir 37c05bd575 fix(ivy): avoid destroy renderer method invocation for child views (#27592)
Since Renderer is shared across root and child views, we need to avoid `destroy` method invocation for child views and only invoke is for root view when needed. Prior to this change, the `destroy` function was called whenever child view was destroyed, thus causing errors at runtime.

PR Close #27592
2018-12-12 13:04:09 -08:00
Pawel Kozlowski 28ceca0163 test(ivy): update root causes for @angular/core TestBed failures (#27627)
PR Close #27627
2018-12-12 11:02:03 -08:00
Pawel Kozlowski 6980631631 test(ivy): update root causes for @angular/core TestBed failures (#27602)
PR Close #27602
2018-12-11 11:28:43 -08:00
Kara Erickson 452668b581 fix(ivy): host bindings should work if input has same name (#27589)
Previously in Ivy, host bindings did not work if they shared a public name
with an Input because they used the `elementProperty` instruction as is.
This instruction was originally built for inside component templates, so it
would either set a directive input OR a native property. This is the
correct behavior for inside a template, but for host bindings, we always
want the native properties to be set regardless of the presence of an Input.

This change adds an extra argument to `elementProperty` so we can tell it to
ignore directive inputs and only set native properties (if it is in the
context of a host binding).

PR Close #27589
2018-12-11 11:27:08 -08:00
Andrew Kushnir 05cdfb90e9 fix(ivy): make ViewRef.detectChanges work with embedded views (FW-749) (#27521)
In `ViewRef.detectChanges`, we are passing `ViewRef.context` into `detectChanges` to trigger change detection. This only makes sense for component `ViewRefs` (i.e. injected `ChangeDetectorRefs`) because with embedded views, `context` is not a component instance where the view has been monkey-patched. It's a just a normal object, so the view will be undefined.

In order to resolve this problem, we now invoke `detectChangesInternal` and also pass `LView` (to make sure we always have a view available).

PR Close #27521
2018-12-10 14:20:22 -08:00
Pawel Kozlowski 2182be48c4 test(ivy): enable more of @angular/core tests on node and in a browser (#27572)
PR Close #27572
2018-12-10 10:30:03 -08:00
Olivier Combe 9e7a8f6e89 refactor(ivy): dedup render3 NodeInjector (#27541)
We had two `NodeInjector` classes: one in `view_compatibility` and one in `di`. We replaced the one in `di` with the one from `view_compatibility` and reconciled their differences.
PR Close #27541
2018-12-10 10:29:13 -08:00
Andrew Kushnir 255e672295 fix(ivy): define correct SVG namespace (FW-757) (#27529)
The trailing slash in SVG namespace prevented its correct resolution, thus triggering issues at runtime.

PR Close #27529
2018-12-07 11:53:52 -08:00
Pawel Kozlowski 5657126d86 test(ivy): run browser-specific @angular/core tests on CI (#27545)
PR Close #27545
2018-12-07 09:24:15 -08:00
Pawel Kozlowski 913563a41d test(ivy): finish root cause analysis for @angular/core TestBed failing tests (#27510)
PR Close #27510
2018-12-06 13:41:02 -08:00
Andrew Kushnir cad67148b1 fix(ivy): "select" attribute on <ng-content> should not be case-sensitive (FW-789) (#27500)
While generating attributes for `projection` instruction, we checked whether attribute name is equal to 'select' in lower case. However in other cases we treat 'select' attribute name as case-insensitive. This PR makes 'select' attribute consistently case-insensitive.

PR Close #27500
2018-12-06 13:40:15 -08:00
Andrew Kushnir c71d7b5633 fix(ivy): setting up animation properties correctly (FW-643) (#27496)
Prior to this change, animation properties were defined as element attributes, which caused errors at runtime. Now all animation-related attributes are defined as element properties.

Also as a part of this update, we start to account for bindings used in animations, which was previously missing.

PR Close #27496
2018-12-06 13:38:40 -08:00
Sander Elias 21d13dd15a fix(ivy): Added missing getHostElement to export (#27488)
PR Close #27488
2018-12-06 13:35:41 -08:00
Marc Laval 8e9858fadb fix(ivy): align NgModuleRef implementation between Ivy and ViewEngine (#27482)
Solves FW-765 and FW-767

PR Close #27482
2018-12-06 13:35:08 -08:00
JoostK 159ab1c257 fix(ivy): ngtsc should include generic types on injectable definitions (#27037)
Analogously to directives, the `ngInjectableDef` field in .d.ts files is
annotated with the type of service that it represents. If the service
contains required generic type arguments, these must be included in
the .d.ts file.

PR Close #27037
2018-12-06 13:33:13 -08:00
Pawel Kozlowski 821fecb413 test(ivy): update root causes for @angular/core TestBed failures (#27479)
PR Close #27479
2018-12-05 11:24:06 -08:00
Ben Lesh cd858323f2 feat(ivy): Forward refs now supported (#27439)
Adds deferred execution of scope setting for modules such that forward refs can be supported in ivy. Design docs can be found at https://docs.google.com/document/d/11KTbybis9rt0cZgMKd1wo_IKb6y1PMU-RoTDVLTXK4Y/edit#

PR Close #27439
2018-12-05 10:41:24 -08:00
Olivier Combe 2bc39860bb feat(ivy): support inputs & outputs with aliases in component decorators (#27350)
PR Close #27350
2018-12-05 10:40:08 -08:00
Olivier Combe 1279a503a1 feat(ivy): add ng-reflect debug text for containers (#27350)
PR Close #27350
2018-12-05 10:40:08 -08:00
Misko Hevery f52600e261 test(ivy): add ability to find already passing tests (#27449)
PR Close #27449
2018-12-05 09:34:52 -08:00
Miško Hevery 4b9948c1be fix(core): More precise return type for `InjectableDecorator` (#27360)
closes #26942

PR Close #27360
2018-12-04 23:18:19 -08:00
Misko Hevery faca8b1382 test(ivy): remove symbol tests which are too big and not useful (#27446)
PR Close #27446
2018-12-04 23:17:52 -08:00
Kristiyan Kostadinov b6dbcf93a0 test(ivy): add root cause on tree shakable providers test (#27465)
Adds the root cause on one of the failing NgModule tests.

PR Close #27465
2018-12-04 21:01:58 -08:00
Pawel Kozlowski b25f06ee7c test(ivy): update root causes for @angular/core TestBed failures (#27459)
PR Close #27459
2018-12-04 20:02:21 -08:00
Marc Laval 8973f12ee4 fix(ivy): provided Injector should be instantiated by its factory (#27456)
(FW-777)

When an Injector is provided, R3Injector instantiates it by calling its
constructor instead of its factory, not resolving dependencies.
With this fix, the ngInjectorDef is checked and the factory is correctly
used if it is found.

PR Close #27456
2018-12-04 20:01:49 -08:00
Andrew Kushnir 130ae158c4 test(ivy): more precise TestBed failure causes for View/Content Queries (FW-670) (#27447)
PR Close #27447
2018-12-04 20:01:03 -08:00
Misko Hevery 295e0f65a1 refactor(ivy): remove old unused test case (#27442)
PR Close #27442
2018-12-04 20:00:17 -08:00
Kristiyan Kostadinov 862697d4bd fix(ivy): return new ViewRef when detaching view (#27437)
When detaching a view by its index via `ViewContainerRef.detach(index)`, in `ViewEngine` we used to return a new `ViewRef` ([for reference](https://github.com/angular/angular/blob/master/packages/core/src/view/refs.ts#L227)), however in Ivy we return the same `ViewRef` which means that its internal `_viewContainerRef` is never reset and we'll throw an error if the consumer tried to attach it to the `ApplicationRef`. These changes return a new `ViewRef` in order to match the original behavior.

These changes also add the same errors as `ViewEngine` when attempting to attach a view that is attached already. This was the original goal of this PR, however it ended up uncovering the issues with the `ViewRef`.

PR Close #27437
2018-12-04 19:59:37 -08:00
Olivier Combe 7f17c70fd0 test(ivy): add bundling test `todo_i18n` (#27420)
PR Close #27420
2018-12-04 19:59:12 -08:00
Marc Laval bd864fb274 feat(ivy): support WrappedValue in pipes (FW-726) (#27409)
PR Close #27409
2018-12-04 19:59:01 -08:00
Miško Hevery b2d6f43b49 fix(ivy): Implement remaining methods for DebugNode (#27387)
PR Close #27387
2018-12-04 19:58:25 -08:00
Andrew Kushnir 8e644d99fc fix(ivy): taking "interpolation" config option into account (FW-723) (#27363)
PR Close #27363
2018-12-04 14:04:14 -08:00
George Kalpakas 56f8c23adf test(ivy): add tests for `ComponentFactory#create()` fix in #27341 (#27300)
PR Close #27300
2018-12-04 14:03:44 -08:00
George Kalpakas 6cf3c2b682 docs(ivy): fix component definition description of `inputs` (#27300)
PR Close #27300
2018-12-04 14:03:44 -08:00
JoostK 6552471c49 fix(ivy): account for `useValue: undefined` providers in module injector (#27035)
PR Close #27035
2018-12-03 14:39:25 -08:00
Kristiyan Kostadinov 7ec05b4d8c fix(ivy): run initialializers in TestBed on init (#27355)
Fixes the initializers not being run by `TestBed` when creating a fixture.

PR Close #27355
2018-12-03 14:37:49 -08:00
Andrew Kushnir 8eb102ab10 fix(ivy): avoid counting style/class bindings in component/directive `hostBindings` (#27388)
PR Close #27388
2018-12-03 14:37:30 -08:00
Kara Erickson 2a39425e48 fix(ivy): temporary hack to set host styles and static classes (#27385)
PR Close #27385
2018-12-03 11:05:36 -08:00
Misko Hevery 7d89cff545 fix(ivy): Ensure ComponentFactory uses both injectors to retrieve rendererFactory (#27341)
PR Close #27341
2018-12-03 10:02:05 -08:00
Andrew Kushnir 6f5c124fe9 fix(ivy): proper accounting of host vars in case of inherited Directives (#27392)
Prior to this change, the number of host vars stored for directives with `hostBindings` in expando block was incorrect for inherited directives (in case both parent and child directive have `hostBindings` defined). Now if we identify that we already added a `hostBinding` into expando block, we just increase the corresponding number of host binding vars

PR Close #27392
2018-12-03 09:18:07 -08:00
Matias Niemelä a082f6484a fix(ivy): fix style prop instructions to account for zero-based values (#27270)
PR Close #27270
2018-12-03 08:23:23 -08:00
Pawel Kozlowski a1470c94a6 test(ivy): update root causes for @angular/core TestBed failures (#27419)
PR Close #27419
2018-12-03 08:19:56 -08:00
Andrew Kushnir a088b8c203 feat(ivy): introduce "allocHostVars" instruction as a replacement for "hostVars" field (FW-692) (#27299)
PR Close #27299
2018-11-30 14:03:12 -08:00
Alex Rickabaugh 64a34616d8 fix(ivy): support string tokens in dependency injection (#27383)
In Angular, it used to be an accepted practice to use strings as dependency
injection tokens. E.g. {provide: 'test', useValue: 'provided'}. However,
the Ivy node injection system did not support this. The Ivy DI system
attempts to patch a Bloom bit index onto each type registered with it, and
this patch operation does not work for a string token.

This commit adds string token support to the bloom filter system by
reserving bit 0 for string tokens. This eliminates the need for each string
token to store its own Bloom bit, at the expense of slightly more expensive
lookups of string tokens.

PR Close #27383
2018-11-30 14:00:23 -08:00
Pawel Kozlowski 1fa5478fef test(ivy): update root causes for @angular/core TestBed failures (#27370)
PR Close #27370
2018-11-30 13:41:21 -08:00
Alex Rickabaugh 412e47d311 fix(ivy): support multiple directives with the same selector (#27298)
Previously the concept of multiple directives with the same selector was
not supported by ngtsc. This is due to the treatment of directives for a
component as a Map from selector to the directive, which is an erroneous
representation.

Now the directives for a component are stored as an array which supports
multiple directives with the same selector.

Testing strategy: a new ngtsc_spec test asserts that multiple directives
with the same selector are matched on an element.

PR Close #27298
2018-11-29 21:35:28 -08:00
Kristiyan Kostadinov 23bc8edf24 test: move remaining fixmeIvy to test level (#27354)
Moves all of the remaning `describe`-level fixme instances to the `it` level.

PR Close #27354
2018-11-29 21:28:01 -08:00
Misko Hevery 816ec0b1c3 refactor(ivy): treate LView as the primary global state (#27282)
- rename `LViewData` to `LView` (to be consistent with `TView`)
- Remove `getRenderer`, `getRendererFactory`, `getTview`, `getCurrentQueries`,

PR Close #27282
2018-11-29 21:26:15 -08:00
Pawel Kozlowski 8ceea0f238 test(ivy): update root causes for @angular/core TestBed failures (#27351)
PR Close #27351
2018-11-29 21:21:13 -08:00
Andrew Kushnir 7773d7f552 fix(ivy): add polyfill for goog.getMsg to unblock tests (FW-663) (#27218)
PR Close #27218
2018-11-28 11:40:56 -08:00
Pawel Kozlowski 7076773360 test(ivy): update root causes for @angular/core TestBed failures (#27321)
PR Close #27321
2018-11-28 11:38:51 -08:00
Misko Hevery 39e426cde3 fix(ivy): TestBed.get(Compiler) throws "Error: Runtime compiler is not loaded" (#27223)
BREAKING CHANGE:

The public API for `DebugNode` was accidentally too broad. This change removes
1. Public constructor. Since `DebugNode` is a way for Angular to communicate information
   on to the developer there is no reason why the developer should ever need to
   Instantiate the `DebugNode`
2. We are also removing `removeChild`, `addChild`, `insertBefore`, and `insertChildAfter`.
   All of these methods are used by Angular to constructor the correct `DebugNode` tree.
   There is no reason why the developer should ever be constructing a `DebugNode` tree
   And these methods should have never been made public.
3. All properties have been change to `readonly` since `DebugNode` is used by Angular
   to communicate to developer and there is no reason why these APIs should be writable.

While technically breaking change we don’t expect anyone to be effected by this change.

PR Close #27223
2018-11-27 13:42:23 -08:00
Miško Hevery 60e403bf6d build: ts-api-guardian should support interface with value types (#27223)
This fixes an issue where a value would hide the type.

```
export interface Foo {
  someMethod(): void;
}

export const Foo: Function = ...;
```

In the above example the `Foo` constant will hide the `interface Foo` symbol.
This change properly saves the interface in addition to the type.

PR Close #27223
2018-11-27 13:42:23 -08:00
Alex Rickabaugh 23b06af940 fix(core): export a value for InjectFlags (#27279)
A recent commit (probably 2c7386c) has changed the import graph of the
DI types in core, and somehow results in the ngc compiler deciding to
re-export core DI types from application factories which tangentially
use inject(). This is not really surprising; ngc's import graph can be
very unstable.

However, this results in a re-export of InjectFlags surviving JS
compilation. InjectFlags was a const enum, akin to an interface in TS,
with no runtime repesentation. This causes a warning to be emitted by
Webpack when it sees the re-export of InjectFlags.

This commit avoids the issue by removing 'const' from the declaration
of InjectFlags, causing it to have a runtime value. This is a temporary
fix. The real fix will be for ngc to no longer write exports of const
enums.

Testing strategy: manually verified. Due to the problem only manifesting
when recompiling after a change and then running Webpack, there is no
existing framework via which this could be easily tested with an
integration test. Additionally, the potential for this issue is gone in
Ivy, so this solution is only temporarily needed.

Fixes #27251.

PR Close #27279
2018-11-27 13:40:39 -08:00
Igor Minar 5d82c73da6 fix(ivy): @NgModule() should not require an metadata object (#27278)
There is no test in this diff because I'm making an already failing test pass.

PR Close #27278
2018-11-27 10:30:58 -08:00
Igor Minar 1cca27d823 fix(ivy): @Inject should not overwrite an existing ngInjectableDef (#27278)
There is no test in this diff because I've made a failing test pass.

PR Close #27278
2018-11-27 10:30:58 -08:00
Igor Minar f7ba4b2ff9 fix(ivy): remove obsolete ng_module code for global and jit mode (#27278)
These paths are no longer needed / used.

I had to disable one jit mode spec because it fails now that we actually run it.
I root caused the jit test failure as missing forwardRef support. See FW-645.

PR Close #27278
2018-11-27 10:30:58 -08:00
Igor Minar d1227ec800 ci(ivy): packages/core/test/render3 now passes with ivy aot (#27278)
PR Close #27278
2018-11-27 10:30:58 -08:00
Kristiyan Kostadinov 4622d0b23a fix(ivy): detach ViewRef from ApplicationRef on destroy (#27276)
Currently we store the `_appRef` when a `ViewRef` is attached, however we don't use it for anything. These changes use it to detach the view from the `ApplicationRef` when it is destroyed. These changes also fix that the `ComponentRef` doesn't remove its `ViewRef` on destroy.

PR Close #27276
2018-11-27 10:24:53 -08:00
Pawel Kozlowski 0487fbe236 fix(ivy): throw a descriptive error when trying to insert / move destroyed view (#27289)
PR Close #27289
2018-11-27 10:23:14 -08:00
Kara Erickson d0e8020506 fix(ivy): blueprints should be synced whenever they are off (#27281)
PR Close #27281
2018-11-27 10:22:03 -08:00
Kara Erickson a7ba05ad82 fix(ivy): fix directive instantiation at slots above 2^12 (#27280)
PR Close #27280
2018-11-27 10:20:02 -08:00
Olivier Combe 2fce701ced feat(ivy): enable ng-reflect debug attributes (#27268)
PR Close #27268
2018-11-27 10:18:51 -08:00
Olivier Combe 32157115da fix(ivy): register `ModuleWithProviders` when deduplicating imported modules (#27268)
PR Close #27268
2018-11-27 10:18:51 -08:00
Marc Laval c2f30542e7 fix(ivy): should support components without selector (#27169)
PR Close #27169
2018-11-27 10:17:35 -08:00
JoostK d767e0b2c0 fix(ivy): consider providers for view/content queries (#27156)
In ViewEngine it is possible to query for a token that is provided by
a directive that is in scope. See StackBlitz for example:
https://stackblitz.com/edit/ng-viewengine-viewchild-providers

Material uses this pattern with its `MatFormFieldControl` setup, see
https://bit.ly/2zgCUxD for documentation.

PR Close #27156
2018-11-27 10:16:57 -08:00
Pawel Kozlowski 9e5223eaba test(core): add more root causes for TestBed tests failures (#27236)
PR Close #27236
2018-11-26 09:24:32 -08:00
Pawel Kozlowski 3c9ad1d231 fix(ivy): inject null for missing attributes (#27237)
PR Close #27237
2018-11-26 09:23:56 -08:00
Andrew Kushnir dc300c5c41 feat(ivy): render flags support in host bindings function (FW-649) (#27204)
PR Close #27204
2018-11-21 15:33:47 -08:00
JoostK c8c8648abf fix(ivy): prevent ngcc from referencing missing ɵsetClassMetadata (#27055)
When ngtsc compiles @angular/core, it rewrites core imports to the
r3_symbols.ts file that exposes all internal symbols under their
external name. When creating the FESM bundle, the r3_symbols.ts file
causes the external symbol names to be rewritten to their internal name.

Under ngcc compilations of FESM bundles, the indirection of
r3_symbols.ts is no longer in place such that the external names are
retained in the bundle. Previously, the external name `ɵdefineNgModule`
was explicitly declared internally to resolve this issue, but the
recently added `setClassMetadata` was not declared as such, causing
runtime errors.

Instead of relying on the r3_symbols.ts file to perform the rewrite of
the external modules to their internal variants, the translation is
moved into the `ImportManager` during the compilation itself. This
avoids the need for providing the external name manually.

PR Close #27055
2018-11-21 09:20:11 -08:00
Pawel Kozlowski d666370e16 test(core): add JIRA references for root-casuse ivy TestBed failures (#27196)
PR Close #27196
2018-11-21 09:18:54 -08:00
Misko Hevery e56c8bf8d1 fix(ivy): align discovery methods for consistency (#27117)
PR Close #27117
2018-11-20 11:44:14 -08:00
Miško Hevery ca40565f9a fix(ivy): hack implementation of host styles (#27180)
PR Close #27180
2018-11-20 11:43:29 -08:00
Olivier Combe bf3beb5959 fix(ivy): set `ng-version` attribute on root component (#27175)
PR Close #27175
2018-11-20 10:43:51 -08:00
Olivier Combe 20729b3378 fix(ivy): deduplicate imported modules in r3_injector (#27102)
PR Close #27102
2018-11-19 09:20:39 -08:00
Matias Niemelä 20ea5b5634 refactor(ivy): ensure directive host bindings use the styling algorithm (#27145)
PR Close #27145
2018-11-17 10:12:47 -08:00
Misko Hevery 4222b63639 Revert "refactor(ivy): ensure directive host bindings use the styling algorithm (#27134)"
This reverts commit b5dbf5154e.
2018-11-16 17:55:41 -08:00
Matias Niemelä b5dbf5154e refactor(ivy): ensure directive host bindings use the styling algorithm (#27134)
PR Close #27134
2018-11-16 16:10:45 -08:00
Andrew Kushnir 92e80af875 feat(ivy): ICU support for Ivy (#26794)
PR Close #26794
2018-11-16 16:09:30 -08:00
JoostK 60800da6c1 fix(ivy): export elementContainerStart/End instructions (#27053)
PR Close #27053
2018-11-16 12:19:18 -08:00
Marc Laval 848f4148c0 fix(ivy): DI should work when no element injector on starting node (#27133)
PR Close #27133
2018-11-16 09:26:29 -08:00
crisbeto 6574e61062 test(ivy): skip useJit tests with Ivy (#27067)
Currently the `useJit` option from `TestBed.configureCompiler` isn't supported. These changes rework the existing test suites not to pass in `useJit` when running with Ivy.

PR Close #27067
2018-11-15 21:19:21 -08:00
Kara Erickson ee12e725c0 fix(ivy): component ref injector should support change detector ref (#27107)
PR Close #27107
2018-11-15 21:18:24 -08:00
Olivier Combe e22a302cad feat(ivy): support for i18n & ICU expressions (#27101)
PR Close #27101
2018-11-14 16:22:01 -08:00
Pawel Kozlowski ce5242462b fix(ivy): implement rootNodes getter on ViewRef (#27095)
PR Close #27095
2018-11-14 12:28:03 -08:00
Marc Laval 1c9e526a83 fix(ivy): use the root view injector when resolving dependencies (#27090)
PR Close #27090
2018-11-14 12:26:36 -08:00
Miško Hevery f8f1168fa6 Revert "feat(ivy): support for i18n & ICU expressions (#26275)"
This reverts commit a63fd2d0f5.
2018-11-14 10:23:21 -08:00
Kara Erickson f0c4f31771 fix(ivy): should export lifecycle hooks feature (#27082)
PR Close #27082
2018-11-13 16:17:30 -08:00
Olivier Combe a63fd2d0f5 feat(ivy): support for i18n & ICU expressions (#26275)
PR Close #26275
2018-11-13 14:50:30 -08:00
Kara Erickson bc652a2943 fix(ivy): jit compilation should support content queries with type predicates (#27068)
PR Close #27068
2018-11-13 12:18:13 -08:00
Kara Erickson e6e590479e fix(ivy): support forward refs in @Inject annotations (#27069)
PR Close #27069
2018-11-13 12:17:18 -08:00
Kara Erickson 123da1a8c2 test(ivy): split out provider tests (#27069)
PR Close #27069
2018-11-13 12:17:18 -08:00
Judy Bogart 9741f5b8cf docs: new doc for core directives (#26923)
PR Close #26923
2018-11-13 10:57:56 -08:00
Kristiyan Kostadinov 5247594e86 fix(ivy): add support for providers in TestBed.configureCompiler (#27066)
Adds support for the `providers` that are passed in through `TestBed.configureCompiler` and scopes the error only if the consumer has passed in `useJit`.

PR Close #27066
2018-11-12 15:33:56 -08:00
Kara Erickson 8b9249a670 fix(ivy): host bindings should support content children and content hooks (#27065)
PR Close #27065
2018-11-12 14:26:06 -08:00
Kara Erickson 1810cdf2c3 fix(ivy): compiler should generate restoreView() for local refs in listeners (#27034)
PR Close #27034
2018-11-12 12:50:58 -08:00
Kristiyan Kostadinov e5c9f7a507 fix(ivy): provide NgZone to ComponentRef (#26898)
Fixes the r3 `TestBed` not providing an `NgZone` to the `ComponentFixture`.

PR Close #26898
2018-11-12 12:47:07 -08:00
Kara Erickson 78b6f88cb3 fix(ivy): TestBed should use an NgZone (#27015)
PR Close #27015
2018-11-09 09:56:36 -08:00
Kara Erickson 552836ebf0 fix(ivy): merged host bindings functions should take superclass hostVars into account (#27013)
PR Close #27013
2018-11-09 09:55:47 -08:00
Kara Erickson 2f36a9591d fix(ivy): providers should not be inherited (#27013)
PR Close #27013
2018-11-09 09:55:47 -08:00
Igor Minar 499e303ea3 test(ivy): add global utils to the public_api_guard test (#27008)
This API is part of our public api surface and needs to be monitored by the public_api_guard.

I also had to go back and mark all of the exported functions with @publicApi jsdoc tag.

PR Close #27008
2018-11-08 15:37:11 -08:00
Matias Niemelä e618032d53 feat(ivy): introduce `getPlayers()` to global utils (#27008)
PR Close #27008
2018-11-08 15:37:11 -08:00
Andrew Kushnir 3567e81175 fix(ivy): restore missing match operation in View and Content Queries (#26847)
PR Close #26847
2018-11-07 16:29:19 -08:00
Kara Erickson 9e26216c40 fix(ivy): compiler should generate bindings to host attrs properly (#26973)
PR Close #26973
2018-11-07 11:09:31 -08:00
Miško Hevery 53e4e0c1a3 fix(ivy): Enable AoT tests to run on CI; disable failing tests (#26975)
PR Close #26975
2018-11-07 10:35:20 -08:00
Miško Hevery 5e769d9a25 fix(ivy): add `nocollapse` to ngInjectableDef for closure compatibility (#26975)
PR Close #26975
2018-11-07 10:35:20 -08:00
Matias Niemelä 931a363612 fix(ivy): use `window.ng` instead of `window.ngDev` for debug tooling (#26951)
PR Close #26951
2018-11-06 17:08:37 -08:00
Marc Laval 297c54ebb3 fix(ivy): support env where requestAnimationFrame is not available (#26779)
PR Close #26779
2018-11-06 11:49:32 -08:00
Kara Erickson dc2464eaaa fix(ivy): jit should handle undefined type in constructor deps (#26956)
PR Close #26956
2018-11-06 11:22:14 -08:00
Misko Hevery 7d2a746090 build: remove ivy JIT mode (#26863)
PR Close #26863
2018-11-02 15:44:05 -07:00
Miško Hevery c13f46c7c5 fix(ivy): enable packages/core/test/render3 test for AoT (#26863)
PR Close #26863
2018-11-02 15:44:05 -07:00
Kara Erickson ea0a99610d fix(ivy): init hooks should be called before host bindings (#26802)
PR Close #26802
2018-11-01 14:49:01 -07:00
Kara Erickson 3b9bc73db4 fix(ivy): host bindings after dirs without host bindings should work (#26801)
PR Close #26801
2018-11-01 14:18:57 -07:00
Pete Bacon Darwin a64859b4bc fix(core): ensure that `ɵdefineNgModule` is available in flat-file formats (#26403)
When compiling the flat-file version of the `@angular/core` we need to be aware
that we cannot rely upon imported names to access the ivy definition functions.
The compiler is already clever enough to use local function calls rather than
trying to add a namespaced import, but there is a problem if the local name of the
function is different to the exported name. This is the case for functions that
are not part of the public API, and so are exported under a barred-O private alias.

In `@angular/core` the only decorations in use are `@NgModule` and `@Injectable`.
There are no directives, components, pipes, etc.

Since `defineInjectable` is part of the public API of `@angular/core`, the compiler
is able to generate code that references the original non-barred-O version of the
function.

But the `defineNgModule` is not part of the public API and so the compiler must
generate code that refers to it by the private barred-O version of the function.

This commit imports and then re-exports this barred-O version of `defineModule` to
ensure that the symbol is available in the local scope of the flat-file versions of
the `@angular/core` library.

PR Close #26403
2018-11-01 14:13:26 -07:00
Miško Hevery 683d53db4b docs: add `Function Inlining` rules to `PERF_NOTES.md` (#26876)
PR Close #26876
2018-11-01 13:47:34 -07:00
Kara Erickson a2929dfd57 fix(ivy): dynamically created components should run init hooks (#26864)
PR Close #26864
2018-11-01 13:44:10 -07:00
Kara Erickson 911bfef04c fix(ivy): bindings should be checked in components created dynamically by root component' (#26864)
PR Close #26864
2018-11-01 13:44:10 -07:00
Kara Erickson aadbc8a9d3 fix(ivy): sync exported r3 symbol with compiler generated symbol (#26877)
PR Close #26877
2018-11-01 13:32:35 -07:00
Igor Minar 2e7b5c5d64 test: fix broken golden file for packages/core/test/bundling/hello_world_r2 (#26893)
PR Close #26893
2018-11-01 06:03:12 -07:00
Alex Rickabaugh 8634d0bcd8 feat(ivy): emit metadata along with all Angular types (#26860)
This commit causes a call to setClassMetadata() to be emitted for every
type being compiled by ngtsc (every Angular type). With this metadata,
the TestBed should be able to recompile these classes when overriding
decorator information.

Testing strategy: Tests in the previous commit for
generateSetClassMetadataCall() verify that the metadata as generated is
correct. This commit enables the generation for each DecoratorHandler,
and a test is added to ngtsc_spec to verify all decorated types have
metadata generated for them.

PR Close #26860
2018-10-31 19:52:36 -04:00
Alex Rickabaugh ca1e538752 feat(ivy): setClassMetadata() for assigning decorator metadata (#26860)
This commit introduces the setClassMetadata() private function, which
adds metadata to a type in a way that can be accessed via Angular's
ReflectionCapabilities. Currently, it writes to static fields as if
the metadata being added was downleveled from decorators by tsickle.

The plan is for ngtsc to emit code which calls this function, passing
metadata on to the runtime for testing purposes. Calls to this function
would then be tree-shaken away for production bundles.

Testing strategy: proper operation of this function will be an integral
part of TestBed metadata overriding. Angular core tests will fail if this
is broken.

PR Close #26860
2018-10-31 19:52:36 -04:00
Misko Hevery d042c4afe0 fix(core): Remove static dependency from @angular/core to @angular/compiler (#26734)
PR Close #26734
2018-10-31 14:15:06 -04:00
Matias Niemelä 5d740785a9 docs: fix aot typo 2018-10-30 17:37:20 -07:00
Matias Niemelä 68b2211e64 fix(ivy): ensure falsy styling is not applied during creation mode (#26793)
PR Close #26793
2018-10-30 19:41:56 -04:00
Trotyl 95743e3a64 fix(core): support computed base class in metadata inheritance (#24014)
PR Close #24014
2018-10-30 13:48:22 -04:00
Pawel Kozlowski ede65dbede fix(ivy): allow root components to inject ViewContainerRef (#26682)
PR Close #26682
2018-10-29 18:47:14 -04:00
Pawel Kozlowski 578e4c7642 fix(ivy): compile queries in JIT mode (#26816)
PR Close #26816
2018-10-29 18:46:44 -04:00
Kara Erickson 96770e5c6b fix(ivy): optional dependencies should not throw with module injector (#26763)
PR Close #26763
2018-10-29 14:12:36 -04:00
Kara Erickson 1130e48541 fix(ivy): host injection flag should not throw for embedded views (#26795)
PR Close #26795
2018-10-29 14:12:11 -04:00
Andrew Kushnir 2a869271f6 fix(ivy): move HostListeners generation to factory function (#26480)
PR Close #26480
2018-10-29 14:02:22 -04:00
Kara Erickson d52d82d744 fix(ivy): injecting optional TemplateRef on element should not throw (#26664)
PR Close #26664
2018-10-26 18:11:27 -04:00
Matias Niemelä d50d400231 build: fix formatting issue in host_binding_spec file 2018-10-26 14:33:04 -07:00
Kara Erickson 19fcfc3d00 fix(compiler): generate inputs with aliases properly (#26774)
PR Close #26774
2018-10-26 17:23:45 -04:00
Matias Niemelä c048358cf9 build: fix the golden files for hello_world_r2 2018-10-26 14:20:40 -07:00
Matias Niemelä 8171a2ab94 fix(ivy): ensure pipe declarations are populated lazily when a forward ref is detected (#26765)
PR Close #26765
2018-10-26 15:57:10 -04:00
Kara Erickson 2fd4c372d5 fix(ivy): resolve forward refs in providers (#26766)
PR Close #26766
2018-10-26 15:50:11 -04:00
Kara Erickson f76ce84ae1 fix(ivy): host bindings should work on nodes with providers (#26771)
PR Close #26771
2018-10-26 15:49:30 -04:00
Igor Minar 40bbfbf961 test(ivy): fix or disable failing ivy tests (#26735)
These tests were previously not running on CI so they have always been broken,
or got broken just recently :-(.

test(ivy): mark failing test targets with fixme-ivy-jit and fixme-ivy-local tags

PR Close #26735
2018-10-26 14:48:05 -04:00
Miško Hevery 95f852e856 build: fix comment formatting to make closure happy (#26769)
PR Close #26769
2018-10-25 19:40:36 -04:00
Kara Erickson 2c7386c961 feat(ivy): support injecting the injector (#26699)
PR Close #26699
2018-10-25 18:47:56 -04:00
Shino Kurian d5cbcef0ea fix(core): ignore comment nodes under unsafe elements (#25879)
Comment nodes that are child nodes of unsafe elements are identified as text nodes. This results in the comment node being returned as an encoded string.
Add a check to ignore such comment nodes.

PR Close #25879
2018-10-25 11:20:19 -07:00
Marc Laval b0476f308b feat(ivy): support providers and viewProviders (#25803)
PR Close #25803
2018-10-25 12:58:40 -04:00
Matias Niemelä 9dc52d9d04 feat(ivy): expose a series of debug console tools (#26705)
PR Close #26705
2018-10-24 20:30:51 -04:00
Matias Niemelä 297dc2bc02 fix(ivy): ensure `ngClass` works with [class] bindings (#26559)
PR Close #26559
2018-10-24 20:27:12 -04:00
Alex Rickabaugh bf9ab53f12 build(ivy): fix typo in build file 2018-10-24 10:07:49 -07:00
Alex Rickabaugh d99f661af7 build(ivy): properly tag the js_expected_symbol_test rules
Previously the rules were tagged ivy-only, but missing the ivy-aot tag
which would cause them to run under CI.
2018-10-24 10:04:06 -07:00
Alex Rickabaugh 5d58a31d86 fix(ivy): rename broken reflect_metadata switch file
This file was missed during the rename of the --define=compile
flag value from 'local' to 'aot. It's referenced as
reflect_metadata_${compile}.
2018-10-24 09:53:10 -07:00
Igor Minar ee0b857172 build: rename the ivy compile mode 'local' to 'aot' (#26686)
PR Close #26686
2018-10-23 14:14:49 -07:00
Igor Minar 4237c34c78 test(ivy): mark failing test targets with fixme-ivy-jit and fixme-ivy-local tags (#26471)
We are close enough to blacklist a few test targets, rather than whitelist targets to run...

Because bazel rules can be composed of other rules that don't inherit tags automatically,
I had to explicitly mark all of our ts_library and ng_module targes with "ivy-local" and
"ivy-jit" tags so that we can create a query that excludes all fixme- tagged targets even
if those targets are composed of other targets that don't inherit this tag.

This is the updated overview of ivy related bazel tags:

- ivy-only: target that builds or runs only under ivy
- fixme-ivy-jit: target that doesn't yet build or run under ivy with --compile=jit
- fixme-ivy-local: target that doesn't yet build or run under ivy with --compile=local
- no-ivy-jit: target that is not intended to build or run under ivy with --compile=jit
- no-ivy-local: target that is not intended to build or run under ivy with --compile=local

PR Close #26471
2018-10-23 08:57:42 -07:00
Pawel Kozlowski ff767dd153 fix(ivy): support ViewContainerRef ng-container children (#26646)
Issue found while running NgPlural tests with ivy

PR Close #26646
2018-10-23 08:52:30 -07:00
Anthony Ciccarello 6737e91974 docs(core): fix spelling in ComponentFactory (#26603)
PR Close #26603
2018-10-22 10:38:56 -07:00
Greg Magolan 15c2467dbd build: review comments addressed (#26488)
PR Close #26488
2018-10-19 20:59:29 -07:00
Greg Magolan 1f3331f5e6 build(bazel): use fine-grained npm deps (#26111) (#26488)
PR Close #26488
2018-10-19 20:59:29 -07:00
Pete Bacon Darwin 3903e5ebe7 docs: update core to use `@publicApi` tags (#26595)
PR Close #26595
2018-10-19 14:35:53 -07:00
Pete Bacon Darwin 24521f549c docs: convert all `@experimental` tags to `@publicApi` tags (#26595)
PR Close #26595
2018-10-19 14:35:52 -07:00
Olivier Combe 03bf0d6b41 docs(ivy): update status for i18n (#26502)
PR Close #26502
2018-10-19 11:06:25 -07:00
Alex Rickabaugh d4cee514f6 refactor(ivy): obviate the Bazel component of the ivy_switch (#26550)
Originally, the ivy_switch mechanism used Bazel genrules to conditionally
compile one TS file or another depending on whether ngc or ngtsc was the
selected compiler. This was done because we wanted to avoid importing
certain modules (and thus pulling them into the build) if Ivy was on or
off. This mechanism had a major drawback: ivy_switch became a bottleneck
in the import graph, as it both imports from many places in the codebase
and is imported by many modules in the codebase. This frequently resulted
in cyclic imports which caused issues both with TS and Closure compilation.

It turns out ngcc needs both code paths in the bundle to perform the switch
during its operation anyway, so import switching was later abandoned. This
means that there's no real reason why the ivy_switch mechanism needed to
operate at the Bazel level, and for the ivy_switch file to be a bottleneck.

This commit removes the Bazel-level ivy_switch mechanism, and introduces
an additional TypeScript transform in ngtsc (and the pass-through tsc
compiler used for testing JIT) to perform the same operation that ngcc
does, and flip the switch during ngtsc compilation. This allows the
ivy_switch file to be removed, and the individual switches to be located
directly next to their consumers in the codebase, greatly mitigating the
circular import issues and making the mechanism much easier to use.

As part of this commit, the tag for marking switched variables was changed
from __PRE_NGCC__ to __PRE_R3__, since it's no longer just ngcc which
flips these tags. Most variables were renamed from R3_* to SWITCH_* as well,
since they're referenced mostly in render2 code.

Test strategy: existing test coverage is more than sufficient - if this
didn't work correctly it would break the hello world and todo apps.

PR Close #26550
2018-10-19 09:23:05 -07:00
Pawel Kozlowski f8195e5e3d fix(ivy): stub TestBed.compileComponents implementation (#26506)
PR Close #26506
2018-10-17 13:08:14 -07:00
Andrew Kushnir 8a3fd58cad feat(ivy): i18n compiler support for i18nStart and i18nEnd instructions (#26442)
PR Close #26442
2018-10-17 11:03:52 -07:00
Matias Niemelä fa8e633be5 feat(ivy): enhance [style] and [class] bindings to be animation aware (#26096)
PR Close #26096
2018-10-16 20:39:19 -07:00
Matias Niemelä be337a2e52 refactor(ivy): move styling files around (#26096)
PR Close #26096
2018-10-16 20:39:18 -07:00
Miško Hevery 4d164b6ca4 fix(ivy): make defineComponent tree shakable by Closure Compiler (#26425)
PR Close #26425
2018-10-16 20:37:35 -07:00
Matias Niemelä 9e5d440a0b refactor(ivy): handle animation metadata normalization in the compiler (#26481)
PR Close #26481
2018-10-16 20:31:04 -07:00
Miško Hevery 7d82053117 docs(ivy): i18n design (#26091)
PR Close #26091
2018-10-16 14:08:01 -07:00
Kara Erickson e76a570908 refactor(ivy): remove LNode (#26426)
PR Close #26426
2018-10-15 11:20:32 -07:00
Kara Erickson 931e603f80 refactor(ivy): revert LNode.data into LViewData[HOST] (#26424)
PR Close #26424
2018-10-15 10:17:12 -07:00
Pawel Kozlowski 45732e5b91 fix(ivy): fix reference to pipeBind instruction with 2 args (#26451)
PR Close #26451
2018-10-15 10:14:25 -07:00
Manduro ff15043e48 fix(core): allow null value for renderer setElement(…) (#17065)
Using Renderer’s setElementAttribute or setElementStyle with a null or undefined value removes the
corresponding attribute or style. The argument type should allow this when using strictNullChecks.

Closes #13686

PR Close #17065
2018-10-12 09:17:59 -07:00
Miško Hevery 9ebb4c02a2 docs(ivy): update status.md (#26382)
PR Close #26382
2018-10-12 09:01:41 -07:00
Kara Erickson 735dfd3b1a refactor(ivy): replace LNode.dynamicLContainerNode with flat LContainers (#26407)
PR Close #26407
2018-10-11 21:07:21 -07:00
Kara Erickson 70cd112872 refactor(ivy): remove TNode.dynamicContainerNode (#26407)
PR Close #26407
2018-10-11 21:07:21 -07:00
Pawel Kozlowski 6a64ac4151 fix(ivy): Renderer2 should not use a special injection fn (#26369)
PR Close #26369
2018-10-11 14:12:03 -07:00
Pawel Kozlowski 4b494f23f5 fix(ivy): fix generated code for style bindings with units (#26397)
PR Close #26397
2018-10-11 14:11:15 -07:00
Pete Bacon Darwin 1e69d601fb fix(ivy): ensure that `ɵNgModuleDefWithMeta` is exported (#26082)
This is needed to build an app with `ngtsc` once `ngcc` has compiled
`@angular/core`.

PR Close #26082
2018-10-11 14:08:39 -07:00
Pawel Kozlowski 053bf27fb3 refactor(ivy): use context discovery in TestBed implementation (#26211)
PR Close #26211
2018-10-11 13:01:28 -07:00
Andrew Kushnir 39f42bad1c feat(ivy): i18n compiler support for element attributes (#26280)
PR Close #26280
2018-10-11 13:00:19 -07:00
Pawel Kozlowski 3f8ac238f1 refactor(ivy): remove unused directives field from TView (#26364)
It was removed in #26316

PR Close #26364
2018-10-11 12:59:02 -07:00
Andrew Kushnir be4edf15ee fix(core): resolving merge conflicts in query.ts (#26324)
PR Close #26324
2018-10-09 17:34:08 -07:00
Andrew Kushnir e5644204dc fix(ivy): removing unnecessary assert in getOrCreateNodeInjector function (#26305)
PR Close #26305
2018-10-09 16:52:00 -07:00
Andrew Kushnir 69b9758ab8 fix(ivy): removing no longer needed QueryReadType (#26314) (#26314)
PR Close #26314

PR Close #26314
2018-10-09 16:50:34 -07:00
Kara Erickson 7ea5161d4d refactor(ivy): merge directives into LViewData (#26316)
PR Close #26316
2018-10-09 16:46:00 -07:00
Kara Erickson b0879046b7 test(ivy): add testing utility to replace loadDirective (#26316)
PR Close #26316
2018-10-09 16:46:00 -07:00
Alex Rickabaugh 456f23f76a fix(ivy): reflect animations field directly into the output definition (#26322)
The 'animations' field of @Component metadata should be copied directly
into the ngComponentDef for that component and should not pass through
static resolution.

Previously the animations array was statically resolved and then the
values were translated back when generating ngComponentDef.

PR Close #26322
2018-10-09 16:45:31 -07:00
Judy Bogart f543d71cc3 docs: add package doc files (#26047)
PR Close #26047
2018-10-05 15:42:14 -07:00
JoostK 9953fe7c00 fix(ivy): reexport compileNgModuleFactory__POST_NGCC__ to prevent DCE in FESM (#26071)
While creating FESM files, rollup usually drops all unused symbols.
All *__POST_NGCC__ are unused unless ngcc rewires stuff. To prevent this DCE
we reexport them as private symbols. If ngcc is not used, these symbols will
be dropped when we optimize an application bundle.

PR Close #26071
2018-10-05 13:45:55 -07:00