Commit Graph

274 Commits

Author SHA1 Message Date
Marc Laval eccbc785b3 fix(ivy): ViewRef.detachFromAppRef should clean the DOM (#29159)
PR Close #29159
2019-03-07 08:56:26 -08:00
Marc Laval 25166d4f41 fix(ivy): support property values changed in ngOnChanges (forward rref case) (#29054)
PR Close #29054
2019-03-05 14:27:08 -08:00
Matias Niemelä 78adcfe0ee fix(ivy): ensure static styling is properly inherited into child components (#29015)
Angular supports having a component extend off of a parent component.
When this happens, all annotation-level data is inherited including styles
and classes. Up until now, Ivy only paid attention to static styling
values on the parent component and not the child component. This patch
ensures that both the parent's component and child component's styling
data is merged and rendered accordingly.

Jira Issue: FW-1081

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

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

PR Close #29047
2019-03-01 15:17:24 -08:00
Greg Magolan ea09430039 build: rules_nodejs 0.26.0 & use @npm instead of @ngdeps now that downstream angular build uses angular bundles (#28871)
PR Close #28871
2019-02-28 12:06:36 -08:00
Wassim Chegham dad5a258b8 style: enforce buildifier lint on CI (#28186)
PR Close #28186
2019-02-26 16:57:41 -08:00
Wassim Chegham ce68b4d839 style: enforce buildifier lint on CI (#28186)
PR Close #28186
2019-02-26 16:57:41 -08:00
Marc Laval dc9f0af080 fix(ivy): static host classes and styles should work on root component (#28926)
PR Close #28926
2019-02-26 13:29:36 -08:00
Misko Hevery 3cb497c6ac refactor(ivy): simplify differentiation of LView, `RNode`, `LView`, `LContainer`, `StylingContext` (#28947)
For efficiency reasons we often put several different data types (`RNode`, `LView`, `LContainer`,
`StylingContext`) in same location in `LView`. This is because we don't want to pre-allocate
space
for it because the storage is sparse. This file contains utilities for dealing with such data
types.
How do we know what is stored at a given location in `LView`.
- `Array.isArray(value) === false` => `RNode` (The normal storage value)
- `Array.isArray(value) === true` => than the `value[0]` represents the wrapped value.
  - `typeof value[TYPE] === 'object'` => `LView`
     - This happens when we have a component at a given location
  - `typeof value[TYPE] === 'number'` => `StylingContext`
     - This happens when we have style/class binding at a given location.
  - `typeof value[TYPE] === true` => `LContainer`
     - This happens when we have `LContainer` binding at a given location.
NOTE: it is assumed that `Array.isArray` and `typeof` operations are very efficient.

PR Close #28947
2019-02-26 02:01:07 +00:00
Ben Lesh 929fe029c2 refactor(ivy): LView is a proper linked list (#28382)
- TView no longer stores childIndex
- LView now as CHILD_HEAD and CHILD_TAIL

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

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

PR Close #28382
2019-02-22 13:17:30 -08:00
Greg Magolan fafabc0b92 build(bazel): use http_server rule from rules_nodejs (#28905)
PR Close #28905
2019-02-22 12:14:55 -08:00
Kristiyan Kostadinov 93a7836f7a fix(ivy): incorrectly remapping certain properties that refer inputs (#28765)
During build time we remap particular property bindings, because their names don't match their attribute equivalents (e.g. the property for the `for` attribute is called `htmlFor`). This breaks down if the particular element has an input that has the same name, because the property gets mapped to something invalid.

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

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

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

Jira Issue: FW-882

PR Close #28711
2019-02-20 13:46:15 -08:00
Greg Magolan 25aae64274 build(bazel): do not build rxjs from source under Bazel (#28720)
PR Close #28720
2019-02-19 16:28:14 -08:00
Matias Niemelä 627cecdfe2 fix(ivy): ensure host bindings and host styling works on a root component (#28664)
Prior to this fix if a root component was instantiated it create host
bindings, but never render them once update mode ran unless one or more
slot-allocated bindings were issued. Since styling in Ivy does not make
use of LView slots, the host bindings function never ran on the root
component.

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

Jira Issue: FW-1062

PR Close #28664
2019-02-14 19:23:25 +00:00
Trotyl Yu 77eee42963 fix(core): improve global variable detection (#28679)
Closes #16545

PR Close #28679
2019-02-13 12:05:41 -08:00
Matias Niemelä fe8301c462 feat(ivy): provide support for map-based host bindings for [style] and [class] (#28246)
Up until now, `[style]` and `[class]` bindings (the map-based ones) have only
worked as template bindings and have not been supported at all inside of host
bindings. This patch ensures that multiple host binding sources (components and
directives) all properly assign style values and merge them correctly in terms
of priority.

Jira: FW-882

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

PR Close #28644
2019-02-11 14:52:32 -08:00
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
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
Pawel Kozlowski 7c5c1fae62 refactor(ivy): move around logic of getting render parent (#28455)
PR Close #28455
2019-02-05 23:29:24 -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
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
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 b35ef184a7 refactor(ivy): remove firstTemplatePass as global state (#28450)
PR Close #28450
2019-01-30 20:39:35 -05: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
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
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
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
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
Daniel Ruf d4ecffe475 refactor: remove obsolete font-smoothing property (#28174)
PR Close #28174
2019-01-23 15:44:35 -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
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
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
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ä 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
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
Misko Hevery 6a9a48b0ac test: improve symbol-extractor test by ignoring $1 suffix (#28098)
PR Close #28098
2019-01-14 09:55:30 -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
Ben Lesh 8ebdb437dc fix(ivy): ngOnChanges only runs for binding updates (#27965)
PR Close #27965
2019-01-11 14:28:35 -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
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