Commit Graph

652 Commits

Author SHA1 Message Date
Tobias Bosch fcc91d862f fix(core): projected views should be dirty checked when the declaring component is dirty checked. (#16592)
Previously a projected view was only dirty checked when the
component in which it was inserted was dirty checked.

This fix changes the behavior so that a view is also dirty checked if
the declaring component is dirty checked.

Note: This does not change the order of change detection,
only the fact whether a projected view is dirty checked or not.

Fixes #14321
2017-05-08 17:48:58 -05:00
David Herges c5ce0408a1 docs(core): EventEmitter docs for isAsync defaults (#15780)
- solves #15758
2017-05-08 10:47:53 -07:00
Matias Niemelä 7f9c589ba3 feat(core): add `begin` and `end` renderer methods to track change detection 2017-05-04 15:07:27 -04:00
Igor Minar 71f5b73296 docs: fix links in api docs 2017-05-03 09:22:32 +01:00
Tobias Bosch e263e19a2a fix(core): don’t stop change detection because of errors
- prevents unsubscribing from the zone on error
- prevents unsubscribing from directive `EventEmitter`s on error
- prevents detaching views in dev mode if there on error
- ensures that `ngOnInit` is only called 1x (also in prod mode)

Fixes #9531
Fixes #2413
Fixes #15925
2017-05-01 18:56:25 -04:00
Tobias Bosch a4de214e2b fix(core): don’t set `ng-version` for dynamically created components (#16394)
Angular uses the `ng-version` attribute to indicate which elements
were used to bootstrap an application. However, after 4.0 we also
added this attribute for all dynamically created components.

Fixes #15880

PR Close #16394
2017-04-28 17:41:50 -05:00
Tobias Bosch aa8bba4865 fix(core): allow to detach `OnPush` components (#16394)
Fixes #9720
2017-04-28 17:41:45 -05:00
Tobias Bosch 392d584572 fix(core): allow directives to inject the component’s `ChangeDetectorRef`. (#16394)
When a directive lives on the same element as a component
(e.g. `<my-comp myDir>`), the directive was not able to get hold
of the `ChangeDetectorRef` of the component on that element. However,
as directives are supposed to decorate components, this is incorrect.

This commit enables this use case.

Closes #12816
2017-04-28 17:41:31 -05:00
Christoph Krautz 900a88b15d feat(core): allow custom selector when bootstrapping components (#15668)
- fixes #7136

PR Close #15668
2017-04-28 17:41:04 -05:00
Alex Eagle da668848c9 fix(core): distribute externs for testability API (#16179)
Workaround for #11119

PR Close #16179
2017-04-19 22:46:11 -05:00
Miško Hevery 5293794316 fix: turn on nullability in the code base. 2017-04-18 12:07:33 -07:00
Miško Hevery 728c9d0632 fix(platform-browser): Update types for TypeScript nullability support
Closes #15898
2017-04-18 12:07:33 -07:00
Victor Berchet cb5a7efa91 fix(core): key-value differ changes iteration (#15968)
fixes #14997
2017-04-14 09:03:16 -07:00
Miško Hevery 09d9f5fe54 fix(compiler): Update types for TypeScript nullability support 2017-04-10 15:26:33 -06:00
Tobias Bosch 14fd78fd85 fix(core): fix inheritance in JIT mode for TS 2.1 (#15599)
Fixes #15502
2017-03-29 16:14:51 -07:00
Victor Berchet d58a242fe7 refactor(router): cleanup & simplification (#15436) 2017-03-29 09:44:04 -07:00
Miško Hevery 910c0d9ee7 fix(core): Update types for TypeScript nullability support (#15472) 2017-03-29 09:34:45 -07:00
Shai Reznik 49162784a8 docs(core): fix API docs for `Injector.get` 2017-03-28 16:57:22 -07:00
Victor Berchet 93d48f1d89 fix(core): fix the key/value differ (#15539)
fixes #15457
2017-03-28 15:50:11 -07:00
Diego Barahona aa16ccda79 fix(core): check for undefined on normalizeDebugBindingValue (#15503)
DebugServices is parsing false atributes values incorrectly.
Parse5 expects a string value for attributes, but currently boolean is being sent.

Closes #15494
2017-03-28 13:33:07 -07:00
Dzmitry Shylovich b7fa5dec21 fix(core): improve error msg for invalid KeyValueDiffer.diff arg (#15489)
Closes #15402
2017-03-28 09:37:40 -07:00
JB Nizet d05aa70c6b docs(core): fix typo and example in InjectionToken doc (#15449)
The doc included an example that didn't use InjectionToken.
2017-03-28 09:37:08 -07:00
Ward Bell 816b389759 docs: in doc comments, replace [aA]ngular2 with Angular (#15463) 2017-03-27 09:44:35 -07:00
Dzmitry Shylovich c17b912eb9 refactor: use object spread operator rather than merge (#15426) 2017-03-24 14:45:33 -07:00
Victor Berchet ea49a95bd9 fix(upgrade): component injectors should not link the module injector tree (#15385) 2017-03-22 15:22:38 -07:00
Chuck Jazdzewski 90d2518d9a fix(compiler): look for flat module resources using declaration module path (#15367)
`ngc` would look for flat module resources relative to the flat module index.
`ngc` now looks for flat module resources relative to the `.d.ts` file that declarates
the component.

Fixes #15221

PR Close #15367
2017-03-21 19:05:03 -05:00
Victor Berchet bac265fdc2 refactor(core): misc cleanup (#15366)
PR Close #15366
2017-03-21 16:46:51 -05:00
Tobias Bosch 64beae9527 fix(core): mark components for check when host events trigger. (#15359)
Fixes #15352

PR Close #15359
2017-03-21 14:27:01 -05:00
Tobias Bosch 1e8b132ade refactor(compiler): only produce `log` expressions for elements / text (#15350)
This change reduces the amount of generated code by only adding `log`
calls for elements and text nodes.

We need the `log` calls to allow users to jump to the right place
in the template via source maps. However, we only need it for element
and text nodes, but not for directives, queries, … as for them we 
first locate the corresponding element or text node.

Related to #15239

PR Close #15350
2017-03-21 14:26:30 -05:00
Tobias Bosch 431eb309f3 fix(core): provide `NgModuleRef` in `ViewContainerRef.createComponent`. (#15350)
This is needed to support the corner cases:
- usage of a `ComponentFactory` that was created on the fly via `Compiler`
- overwriting of the `NgModuleRef` that is associated to a
  `ComponentFactory` by the `ComponentFactoryResolver` from
  which it was read.

Fixes #15241
2017-03-21 14:26:26 -05:00
Dzmitry Shylovich 8e6995c91e fix(core): stringify shouldn't throw when toString returns null/undefined (#14975)
Fixes #14948

PR Close #14975
2017-03-21 12:20:44 -05:00
Tobias Bosch f8c075ae27 fix(core): don’t create a comment for components with empty template. (#15260)
Fixes #15143

PR Close #15260
2017-03-19 12:22:26 -05:00
Tobias Bosch 0d3e314df0 fix(core): trigger host animations for elements that are removed. (#15251)
Fixes #14813
Fixes #15193
2017-03-19 12:21:42 -05:00
Tobias Bosch 28ce68a13d refactor(core): view engine - change `BindingType` to `BindingFlags` (#15251) 2017-03-19 12:21:37 -05:00
Tobias Bosch 0c43535ccc fix(core): only apply `WrappedValue` to the binding of the pipe (#15257)
Previously, a pipe that returned a `WrappedValue` would force the change
of the next bound property, independent of the binding in which the pipe
was used.

Now only the binding in which the `WrappedValue` is used will be assumed
as changed.

Fixes #15116

PR Close #15257
2017-03-17 17:38:36 -05:00
Tobias Bosch 2a0e55ffb5 fix(core): allow tree shaking of component factories and styles (#15214)
Closure compiler is very sensitive to top level function calls.
This commit makes the function calls `createComponentFactory`
and `createRendererTypeV2` logic-less.

Fixes #15181

PR Close #15214
2017-03-17 13:52:57 -05:00
Tobias Bosch 791534f2f4 feat(core): expose `inputs`, `outputs` and `ngContentSelectors` on `ComponentFactory`. (#15214)
E.g. for a component like this:
```
@Component({
  template: ‘<ng-content select=“child”></ng-content>’
})
class MyComp {
  @Input(‘aInputName’)
  aInputProp: string;

  @Output(‘aEventName’)
  aOuputProp: EventEmitter<any>;
}
```

the `ComponentFactory` will now contain the following:
- `inputs = {aInputProp: ‘aInputName’}`
- `outputs = {aOutputProp: ‘aOutputName’}`
- `ngContentSelectors = [‘child’]`
2017-03-17 13:52:41 -05:00
Miško Hevery 77fd91d615 fix(core): ErrorHandler should not rethrow an error by default (#15077) (#15208)
ErrorHandler can not throw errors because it will unsubscribe itself from
the error stream.

Zones captures errors and feed it into NgZone, which than has a Rx Observable
to feed it into ErrorHandler. If the ErroHandler throws, then Rx will teardown
the observable which in essence causes the ErrorHandler to be removed from the
error handling. This implies that the ErrorHandler can never throw errors.

Closes #14949
Closes #15182
Closes #14316
2017-03-16 12:58:41 -07:00
Dzmitry Shylovich 6e98757665 fix(core): use presence of .subscribe to detect observables rather then Symbol.observable (#15171)
Fixes #14298
Fixes #14473
Fixes #14926
2017-03-15 17:13:03 -07:00
Miško Hevery 313158132d Revert "fix(core): ErrorHandler should not rethrow an error by default (#15077)"
This reverts commit 6559425b07.
2017-03-15 16:29:24 -07:00
Chuck Jazdzewski cd981499f9 Revert "feat(core): expose `inputs`, `outputs` and `ngContentSelectors` on `ComponentFactory`."
This reverts commit 1171f91a80.
2017-03-15 13:23:10 -07:00
Tobias Bosch 1171f91a80 feat(core): expose `inputs`, `outputs` and `ngContentSelectors` on `ComponentFactory`.
E.g. for a component like this:
```
@Component({
  template: ‘<ng-content select=“child”></ng-content>’
})
class MyComp {
  @Input(‘aInputName’)
  aInputProp: string;

  @Output(‘aEventName’)
  aOuputProp: EventEmitter<any>;
}
```

the `ComponentFactory` will now contain the following:
- `inputs = {aInputProp: ‘aInputName’}`
- `outputs = {aOutputProp: ‘aOutputName’}`
- `ngContentSelectors = [‘child’]`
2017-03-15 11:42:12 -07:00
Tobias Bosch 06fc42bc44 fix(core): don’t throw if queries change during change detection.
Throwing on query changes would be a breaking change compared to v2.
Also discovers a bug with querying manually projected content, see #15117.

Related to #14748
Closes #14925
2017-03-14 19:52:53 -07:00
Victor Berchet 13686bb518 fix: element injector vs module injector (#15044)
fixes #12869
fixes #12889
fixes #13885
fixes #13870

Before this change there was a single injector tree.
Now we have 2 injector trees, one for the modules and one for the components.
This fixes lazy loading modules.

See the design docs for details:
https://docs.google.com/document/d/1OEUIwc-s69l1o97K0wBd_-Lth5BBxir1KuCRWklTlI4

BREAKING CHANGES

`ComponentFactory.create()` takes an extra optional `NgModuleRef` parameter.
No change should be required in user code as the correct module will be used
when none is provided

DEPRECATIONS

The following methods were used internally and are no more required:
- `RouterOutlet.locationFactoryResolver`
- `RouterOutlet.locationInjector`
2017-03-14 16:26:17 -07:00
Tobias Bosch 2c5a671341 fix: don't instantiate providers with ngOnDestroy eagerly. (#15070)
BREAKING CHANGE:

Perviously, any provider that had an ngOnDestroy lifecycle hook would be created eagerly.

Now, only classes that are annotated with @Component, @Directive, @Pipe, @NgModule are eager. Providers only become eager if they are either directly or transitively injected into one of the above.

This also makes all `useValue` providers eager, which
should have no observable impact other than code size.

EXPECTED IMPACT:
Making providers eager was an incorrect behavior and never documented.
Also, providers that are used by a directive / pipe / ngModule stay eager.
So the impact should be rather small.

Fixes #14552
2017-03-14 14:32:26 -07:00
Tobias Bosch cdc882bd36 feat: introduce source maps for templates (#15011)
The main use case for the generated source maps is to give
errors a meaningful context in terms of the original source
that the user wrote.

Related changes that are included in this commit:

* renamed virtual folders used for jit:
  * ng://<module type>/module.ngfactory.js
  * ng://<module type>/<comp type>.ngfactory.js
  * ng://<module type>/<comp type>.html (for inline templates)
* error logging:
  * all errors that happen in templates are logged
    from the place of the nearest element.
  * instead of logging error messages and stacks separately,
    we log the actual error. This is needed so that browsers apply
    source maps to the stack correctly.
  * error type and error is logged as one log entry.

Note that long-stack-trace zone has a bug that 
disables source maps for stack traces,
see https://github.com/angular/zone.js/issues/661.

BREAKING CHANGE:

- DebugNode.source no more returns the source location of a node.  

Closes 14013
2017-03-14 09:16:15 -07:00
Dzmitry Shylovich 6559425b07 fix(core): ErrorHandler should not rethrow an error by default (#15077) 2017-03-13 11:27:01 -07:00
Tobias Bosch df914ef4bf fix(core): don’t recreate `TemplateRef` when used as a reference. (#15066)
This was a regression introduced in v4 rc.0.

Fixes #14873
2017-03-13 10:44:12 -07:00
Tobias Bosch ff71eff157 refactor(core): use flags in `Renderer2.setStyle` instead of booleans (#15045)
BREAKING CHANGE: (since v4 rc.1)
- `Renderer2.setStyle` no longer takes booleans but rather a
  bit mask of flags.
2017-03-13 09:45:04 -07:00
Chuck Jazdzewski 601494734c Revert "fix(core): ErrorHandler should not rethrow an error by default (#13534)"
This reverts commit 1aebea52e1.
2017-03-10 15:05:48 -08:00
Dzmitry Shylovich 1aebea52e1 fix(core): ErrorHandler should not rethrow an error by default (#13534)
Closes #14949
Closes #13159
Closes #8993
2017-03-10 14:44:14 -08:00
Jason Aden 3e51a19983 refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00