Commit Graph

479 Commits

Author SHA1 Message Date
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
Matias Niemelä 94da80148e fix(animations): stringify boolean values as `1` and `0` (#15311)
Closes #15247
Closes #15311

PR Close #15311
2017-03-20 22:36:29 -05:00
Matias Niemelä 9bf2fb4a74 fix(animations): ensure enter/leave cancellations work (#15323)
Closes #15315
Closes #15323

PR Close #15323
2017-03-20 22:36:11 -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
Matias Niemelä aeb99645bb test(animations): test various combinations of animations with host bindings (#15251)
PR Close #15251
2017-03-19 12:21:54 -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
Matias Niemelä a6fb78ee3c fix(animations): make sure non-transitioned leave operations cancel existing animations (#15254)
Closes #15213

PR Close #15254
2017-03-17 15:35:11 -05:00
Matias Niemelä c66437fc13 fix(animations): only treat view removals as `void` state transitions (#15245)
Closes #15223

PR Close #15245
2017-03-17 13:48:25 -05:00
Tobias Bosch 8415910375 fix(compiler): add an empty content for source file of non mapped code. (#15246)
Before this when using ngc, tools tried to load `ng://…<component>.ts`
if `…<component>.ts` was the source file of a template.

PR Close #15246
2017-03-17 13:48:09 -05:00
Tobias Bosch 994089d36b fix(compiler): always use `ng://` prefix for sourcemap urls (#15218)
Fixes:
- In G3, filePaths don’t start with a `/` and therefore became relative.
- Always using the `ng://` prefix groups angular resources in the same
  way for AOT and JIT.
2017-03-16 17:33:17 -07: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
Tobias Bosch 492153a986 fix(compiler): make sourcemaps work in AOT mode
Inlcuded fixes:
- include preamble in generated source map
- always add a mapping for line/col 0 so that the
  generated sourcemap is not sparse
- use a uniue sourceUrl for inline templates even
  in the AOT case
2017-03-16 12:56:56 -07:00
Alex Rickabaugh 013d806b79 fix(platform-server): handle styles with extra ':'s correctly (#15189)
Previously, style values were parsed with a regex that split on /:+/.

This causes errors for CSS such as

div {
  background-url: url(http://server.com/img.png);
}

since the regex would split the background-url line into 3 values instead of 2.

Now, the : character is detected with indexOf, avoiding this error.

A test was added to verify the behavior is correct.
2017-03-15 17:13:31 -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
Matias Niemelä 3f38c6fdcd fix(animations): always fire callbacks even for noop animations (#15170)
Closes #15170
2017-03-15 13:41:00 -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
Bowen Ni 3c15916e17 fix(compiler): Improve error message for missing annotations (#14724)
Currently, it says:
Unexpected value 'FuzzyTimePipe in
javascript/angular2/example/search/fuzzy_time.ts' declared by the module
'SearchModule in javascript/angular2/example/search/search_module.ts'

The new error message also suggests: 'Please add a @Pipe/@Directive/@Component annotation.'
2017-03-14 17:12:18 -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
Matias Niemelä 0aad270267 refactor(platform-browser): move platform-browser/animations to animations/browser (#15130)
Closes: #15130
2017-03-14 11:55:49 -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
Chuck Jazdzewski e6c81d2a42 Revert "refactor(platform-browser): move platform-browser/animations to animations/browser (#15043)"
This reverts commit 195b863ea4.
2017-03-13 15:46:44 -07:00
Matias Niemelä 195b863ea4 refactor(platform-browser): move platform-browser/animations to animations/browser (#15043) 2017-03-13 14:39:19 -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
Jason Aden 8573e36574 build: fix file paths after moving modules/@angular/* to packages/* 2017-03-08 16:29:28 -08:00
Jason Aden 3e51a19983 refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00