Commit Graph

5066 Commits

Author SHA1 Message Date
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
Jason Aden b74ab83d2c refactor: update paths from 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
Tobias Bosch ad3b44aef7 RendererV2 -> Renderer2 rename (#14998)
* refactor: rename `RendererV2` into `Renderer2`

BREAKING CHANGE (since 4.0 rc.1):
- rename `RendererV2` to `Renderer2`
- rename `RendererTypeV2` to `RendererType2`
- rename `RendererFactoryV2` to `RendererFactory2`
2017-03-07 16:36:12 -08:00
Victor Savkin 5df998d086 fix(router): do not finish bootstrap until all the routes are resolved (#14762)
DEPRECATION:

Use `RouterModule.forRoot(routes, {initialNavigation: 'enabled'})` instead of
`RouterModule.forRoot(routes, {initialNavigtaion: true})`.

Before doing this, move the initialization logic affecting the router
from the bootstrapped component to the boostrapped module.

Similarly, use `RouterModule.forRoot(routes, {initialNavigation: 'disabled'})`
instead of `RouterModule.forRoot(routes, {initialNavigation: false})`.

Deprecated options: 'legacy_enabled', `true` (same as 'legacy_enabled'),
'legacy_disabled', `false` (same as 'legacy_disabled').

The "Router Initial Navigation" design document covers this change.
Read more here:
https://docs.google.com/document/d/1Hlw1fPaVs-PCj5KPeJRKhrQGAvFOxdvTlwAcnZosu5A/edit?usp=sharing
2017-03-07 14:27:20 -08:00
Tobias Bosch 1cff1250ba refactor: remove old compiler options (#14891)
DEPRECATION:
- `CompilerOptions.debug` has no effect any more, as the compiler
  always produces the same code independent of debug mode.
2017-03-07 11:16:27 -08:00
George Kalpakas 07122f0ad9 fix(upgrade): populate upgraded component's view before creating the controller (#14289)
Previously, the relative order of the AngularJS compiling/linking operations was
not similar to AngularJS's, resulting in inconsistent behavior for upgraded
components (which made upgrading to Angular less straight forward).

This commit fixes it, by following the compiling/linking process of AngularJS
more closely.

Main differences:

- The components view is already populated when the controller is instantiated
  (and subsequent hooks are called).
- The correct DOM content is available when running the `$onChanges`, `$onInit`,
  `$doCheck` hooks. Previously, the "content children" were still present, not
  the "view children".
- The same for pre-linking.
- The template is compiled in the correct DOM context (e.g. has access to
  ancestors). Previously, it was compiled in isolation, inside a dummy element.

For reference, here is the order of operations:

**Before**

1. Compile template
2. Instantiate controller
3. Hook: $onChanges
4. Hook: $onInit
5. Hook: $doCheck
6. Pre-linking
7. Collect content children
8. Insert compiled template
9. Linking
10. Post-linking
11. Hook: $postLink

**After**

1. Collect content children
2. Insert template
3. Compile template
4. Instantiate controller
5. Hook: $onChanges
6. Hook: $onInit
7. Hook: $doCheck
8. Pre-linking
9. Linking
10. Post-linking
11. Hook: $postLink

Fixes #13912
2017-03-07 09:32:52 -08:00
Tobias Bosch 3651d8d673 fix: throw for synthetic properties / listeners by default (#14880)
This allows to detect the case that the animation module is not loaded.
2017-03-06 17:15:08 -08:00
Tobias Bosch ba4b6f58d9 fix(core): allow to use the `Renderer` outside of views. (#14882)
Fixes #14872
2017-03-06 17:08:22 -08:00
Tobias Bosch 6cd3326b55 fix(compiler): don’t throw for empty array literal in assignments (#14878)
Closes #14782
2017-03-06 17:01:45 -08:00
Dzmitry Shylovich 6bc6482765 fix(compiler): improve error message when a module imports itself (#14646)
Closes #14644
2017-03-06 17:00:25 -08:00
Miško Hevery 8343fb7740 refactor: remove lang.ts (#14837) 2017-03-06 15:22:29 -08:00
Miško Hevery 84a65cf788 refactor: remove `global` from facade/lang (#14837) 2017-03-06 15:22:22 -08:00
Miško Hevery b0e0839075 refactor: remove facade/collection (#14837) 2017-03-06 15:22:14 -08:00
Miško Hevery 4fe0b90948 refactor: remove facade/browser (#14837) 2017-03-06 15:22:06 -08:00
Miško Hevery 928c5657c8 refactor: remove EventEmitter from facade (#14837)
As of right now each module has its own copy of the EventEmitter
contributing to bloat.
2017-03-06 15:21:39 -08:00
Igor Minar b8f0c3dc7b ci: redo how env variables are set and shared in ci to prevent collisions 2017-03-05 08:03:38 -08:00
Igor Minar a24e652f2b ci: clean up CI logging, folding, add build time logging, and improve error handling (#14425) 2017-03-02 00:22:24 -08:00
Igor Minar 180b705227 release: cut the 4.0.0-rc.2 release 2017-03-01 22:46:11 -08:00
Matias Niemelä 9560ad81b9 fix(animations): make animations work in AOT (#14775) 2017-03-01 17:13:06 -08:00
Jason Aden 3168ef75da build: fix secondary entry point es5 output and core Rx references (#14820)
Secondary entry points (testing, static, etc) are rolled up into a
single ESM/ES2015 file, then downleveled to ESM/ES2015. This downleveling
was not working and was producing ESM/ES2015. Also, the @angular/core
package's .babelrc file was missing reference to Rx Observable which
broke the UMD bundle.

Fixes #14730
2017-03-01 15:59:09 -08:00
Chuck Jazdzewski 6bae7378b1 fix(language-service): tolerate errors in decorators (#14634)
Fixes #14631
2017-03-01 13:23:34 -08:00
Tobias Bosch 79fc1e3959 fix(compiler): apply element bindings before host bindings (#14823) 2017-03-01 12:17:43 -08:00
vikerman 9402df92de test(platform-server): enable meta tag and title service specs for server (#14574)
Fix CSS selector syntax to allow single and double quotes. Needed for meta tag service selector to work properly on parse5.

Fixes #14565.
2017-03-01 11:19:22 -08:00
vikerman 47bdc2b0b7 fix(platform-server): don't setup Testability and TestabilityRegistry on the server (#14510) 2017-03-01 11:16:56 -08:00
Victor Berchet 5753de50f0 fix(core): fix `isComponentView()` and `isEmbeddedView()` tests (#14789)
fixes #14778
2017-03-01 08:03:14 -08:00
Victor Berchet d1182af1a4 refactor: change remaining `<template>` to `<ng-template>` (#14706) 2017-03-01 08:02:37 -08:00
Martin Probst 968995a4c6 fix(upgrade): fix upgrade component Closure optimization. (#14801)
$scope and $element are passed to AngularJS, which is not optimized
together with the app. That means properties must be quoted to prevent
renaming.
2017-03-01 06:49:25 -08:00
Tobias Bosch 5ba55b0e04 fix(compiler): fix identifier names of `EMPTY_MAP` / `EMPTY_ARRAY` (#14806) 2017-02-28 14:16:26 -08:00
Tobias Bosch 126fda2613 perf: delete pre-view-engine core, compiler, platform-browser, etc code (#14788)
After the introduction of the view engine, we can drop a lot of code that is not used any more.

This should reduce the size of the app bundles because a lot of this code was not being properly tree-shaken by today's tools even though it was dead code.
2017-02-27 23:08:19 -08:00
Tobias Bosch 5caab71f7d refactor: make identifiers for generated code small to improve dev size 2017-02-27 14:50:41 -08:00
Tobias Bosch d2e42567a6 fix(core): call lifecycle hooks for siblings in declaration order 2017-02-27 14:50:41 -08:00
Tobias Bosch 14d37fe052 refactor(core): move `NodeType` and `ProviderType` into `NodeFlags`
Also removes `ng-reflect` attributes for element properties.
2017-02-27 14:50:41 -08:00
Tobias Bosch 77682a3397 fix(compiler): quote `animation` in `RendererTypeV2` and skip if empty (#14773) 2017-02-27 11:23:37 -08:00
Igor Minar da79ad3cec build: cut 4.0.0-rc.1
rc.0 is not part of the repo history because of a missing fix that was discovered after publishing to npm
2017-02-24 18:03:23 -08:00
Igor Minar 7b02eae0e8 build: manually bump tsc-wrapped version to rc.0 2017-02-24 17:57:55 -08:00
Tobias Bosch 2602b039b4 fix(animations): ignore triggers that are registered multiple times (#14723) 2017-02-24 16:28:14 -08:00
Tobias Bosch 9186068df1 fix(animations): always create a new `AnimationRenderer`
E.g. for no view encapsulation, the delegate will always be the same.
Nevertheless, we still need to create a new `AnimationRenderer` per
component.

Attention: This change will conflict with a local mod in G3.
2017-02-24 16:27:45 -08:00
Tobias Bosch 8824e39325 refactor(platform-browser): extract animations providers into separate file
This is needed so that we can use them in a local modification in G3.

Attention: This change will conflict with a local mod in G3.
2017-02-24 16:27:45 -08:00
Jason Aden 932a02f1c5 build(language-service): fix tsconfig needed for language-service rollup (#14717) 2017-02-24 15:16:23 -08:00
Igor Minar 3c9a46c231 fix(core): fix directive instantiation (#14715)
this issue was discovered in g3 and the patch was confirmed there.

we should add a test as a followup up change.
2017-02-24 13:03:55 -08:00
Tobias Bosch 436a179552 fix(animations): properly cache renderer and namespace triggers (#14703)
- Don’t use the animation renderer if a component
  used style encapsulation but no animations.
- The `AnimationRenderer` should be cached in the same
  lifecycle as its delegate.
- Trigger names need to be namespaced per component type.
2017-02-24 12:10:19 -08:00
Chuck Jazdzewski 5094aef8fd fix(compiler-cli): fix flat module import on Windows (#14712) 2017-02-24 11:52:18 -08:00
Matias Niemelä 93ddd38107 refactor(animations): make modules and bundles into plural Animations (#14695) 2017-02-24 09:36:58 -08:00
Matias Niemelä 32c2fd5c9f refactor(animations): change NoOp -> Noop (#14690) 2017-02-24 00:32:19 -08:00
Jason Aden 2da3844673 build(language-service): support deep import bundling of language services (#14689) 2017-02-23 22:53:17 -08:00
Victor Berchet 41da5998cd feat(router): add an option to rerun guards and resolvers when query changes (#14624)
Closes #14514
Closes #14567
2017-02-23 22:12:30 -08:00
Matias Niemelä be8510356a fix(animations): microtasks should not be timeouts (#14687) 2017-02-23 21:23:57 -08:00
Victor Berchet 01907bafb0 build(platform-server): update parse5 to v3 (#14538) 2017-02-23 21:14:04 -08:00
Marc Laval 39f56fafdd feat(compiler-cli): add an `outFile` option to ng-xi18n
Fixes #11416
Closes #14508
Closes #14657
2017-02-23 20:39:46 -08:00
Marc Laval 234f05996c feat(compiler-cli): add a `locale` option to ng-xi18n
Fixes #12303
Closes #14537
2017-02-23 20:39:46 -08:00
Victor Berchet e99d721612 feat(compiler): Add a `enableLegacyTemplate` option to support `<template>`
When the `enableLegacyTemplate` is set to `false`, `<template>` tags and the
`template` attribute are no more used to define angular templates but are
treated as regular tag and attribute.

The default value is `true`.

In order to define a template, you have to use the `<ng-template>` tag.

This option applies to your application and all the libraries it uses. That is
you should make sure none of them rely on the legacy way to defined templates
when this option is turned off (`false`).
2017-02-23 20:03:16 -08:00
Victor Berchet bf8eb41248 feat(compiler): introduce `<ng-template>`, deprecate `<template>` and `template` attribute
The rationale of this change is to improve the inter-operability with web
components that might make use of the `<template>` tag.

DEPRECATION

The template tags and template attribute are deprecated:

    <template ngFor [ngFor]=items let-item><li>...</li></template>
    <li template="ngFor: let item of items">...</li>

should be rewritten as:

    <ng-template ngFor [ngFor]=items let-item><li>...</li></ng-template>

Note that they still be supported in 4.x with a deprecartion warning in
development mode.

MIGRATION

- `template` tags (or elements with a `template` attribute) should be rewritten
as a `ng-template` tag,
- `ng-content` selectors should be updated to referto a `ng-template` where they
use to refer to a template: `<ng-content selector="template[attr]">` should be
rewritten as `<ng-content selector="ng-template[attr]">`
- if you consume a component relying on your templates being actual `template`
elements (that is they include a `<ng-content selector="template[attr]">`). You
should  still migrate to `ng-template` and make use of `ngProjectAs` to override
the way `ng-content` sees the template:
`<ng-template projectAs="template[attr]">`
- while `template` elements are deprecated in 4.x they continue to work.
2017-02-23 20:03:16 -08:00
Victor Berchet 3f519207a4 refactor(compiler): misc + add a test for directives on inline templates 2017-02-23 20:03:16 -08:00
Dzmitry Shylovich ee747f7d0c refactor(core): change abstract classes for interfaces (#12324)
BREAKING CHANGE: Because all lifecycle hooks are now interfaces
the code that uses 'extends' keyword will no longer compile.

To migrate the code follow the example below:

Before:
```
@Component()
class SomeComponent extends OnInit {}
```
After:
```
@Component()
class SomeComponent implements OnInit {}
```

we don't expect anyone to be affected by this change.

Closes #10083
2017-02-23 18:04:51 -08:00
Chuck Jazdzewski a23634dfd0 fix(common): do not reference deprecated classes in providers (#14523) (#14523)
References to `NgFor` are now an alias for `NgForOf` instead of a
derived class.

Fixes #14521
2017-02-23 17:23:56 -08:00
Jason Aden c53621be8e build: resolve review comments on flat modules PR and fix more bugs (#14660) 2017-02-23 16:39:44 -08:00
Tobias Bosch 4b54c0e23f refactor(core): enable new animations dsl
Also deletes old tests that are not needed any
more with the new view engine.
2017-02-23 13:59:16 -08:00
Tobias Bosch ccb636c2e9 refactor: deprecate `RootRenderer` / `Renderer`
Use `RendererV2` instead of `Renderer` now. `Renderer` can still be injected
and delegates to `RendererV2`.

Use `RendererFactoryV2` instead of `RootRenderer`. `RootRenderer` cannot be used
anymore.

BREAKING CHANGE:
- `RootRenderer` cannot be used any more, use `RendererFactoryV2` instead.
  Note: `Renderer` can still be injected/used, but is deprecated.
2017-02-23 13:59:16 -08:00
Tobias Bosch d3a98c74d6 feat(core): enable new view engine 2017-02-23 13:59:16 -08:00
Matias Niemelä 187f7b68f2 refactor(animations): always remove elements right away unless they have a leave animation 2017-02-23 13:02:45 -08:00
Matias Niemelä 835e18709d refactor(animations): always flush animations when inserting children 2017-02-23 13:02:45 -08:00
Matias Niemelä 36b78e9502 refactor(animations): defer the noop engine's event deregistration 2017-02-23 13:02:45 -08:00
Tobias Bosch 4301dce7b0 fix(packaging): properly build the core-testing bundle 2017-02-23 12:57:07 -08:00
Tobias Bosch 6277f16187 fix: small fixes for view engine 2017-02-23 12:57:07 -08:00
Matias Niemelä e8d2743cfb feat(animations): noop animation module and zone fixes (#14661) 2017-02-23 08:51:00 -08:00
Tobias Bosch ab3527c99b refactor(core): view engine - misc
- fix bug when detaching view from `ApplicationRef`
- fix integration of adding `ng-reflect` attributes
  in debug mode.
2017-02-23 08:26:47 -08:00
Tobias Bosch 5049a50bf6 fix(core): host bindings and host listeners for animations
Host bindings / listeners for animation properties should use
the renderer of the component view.
2017-02-23 08:26:47 -08:00
Igor Minar 6b7937f112 test: fix flaky e2e inbox-app test due to net::ERR_SSL_PROTOCOL_ERROR from fetching google fonts (#14665)
example broken build: https://travis-ci.org/angular/angular/jobs/204456086#L2355
2017-02-22 22:00:01 -08:00
Chuck Jazdzewski 801b09066b fix(compiler-cli): import shallow import to @angular/upgrade/static correctly (#14658)
Fixes #14648
2017-02-22 17:23:08 -08:00
vikerman a1d4769199 feat: add a PLATFORM_ID token that provides a platform id Object. (#14647) 2017-02-22 16:49:46 -08:00
Alex Rickabaugh 88bc143431 fix: app ids for better <style> management for ssr (#14632)
Currently styles are rendered to the root component element, which ensures they're cleaned up automatically
when the client application is bootstrapped. This is less than ideal as progressive rendering can cause HTML
to be rendered before the CSS is loaded, causing flicker.

This change returns to rendering <style> elements in the <head>, and introduces a mechanism for removing
them on client bootstrap. This relies on associating the server and client bootstrap. Another way to think
of this is that the client, when bootstrapping an app, needs to know whether to expect a server rendered
application exists on the page, and to identify the <style> elements that are part of that app in order
to remove them.

This is accomplished by providing a string TRANSITION_ID on both server and client. For most applications,
this will be achieved by writing a client app module that imports BrowserModule.withServerTransition({appId: <id>}).
The server app module will import this client app module and therefore inherit the provider for
TRANSITION_ID. renderModule[Factory] on the server will validate that a TRANSITION_ID has been provided.
2017-02-22 16:06:21 -08:00
Matias Niemelä 830393d234 refactor(animations): support browser animation rendering (#14578) 2017-02-22 15:14:49 -08:00
Chuck Jazdzewski c9bfc59a21 fix(tsc-wrapped): use agreed on options names (#14630) 2017-02-22 10:57:01 -08:00
Chuck Jazdzewski fcc1d17ccb fix(compiler-cli): avoid generating unnecessary factories 2017-02-21 20:48:55 -08:00
Jason Aden de795ea233 perf: distrubute smaller bundled code and include es2015 bundle
TypeScript compiler will now build to ES2015 code and modules. Babili is used to minify ES2015
code, providing an initial optimization that we couldn't previously get just from Uglify. Uses
Babel to convert ES2015 to UMD/ES5 code, and Uglify to minimize the output.
2017-02-21 20:48:55 -08:00
Miško Hevery 738d93caf7 refactor: rewrite private export using the ɵ prefix 2017-02-21 20:48:55 -08:00
Tobias Bosch bb0460b93b refactor(core): don’t use switch fall through but rather multiple `if`s
V8 does this internally any ways. This way, we can also keep the existing
dirty checking order, which some apps sadly rely on.
2017-02-21 09:12:21 -08:00
Tobias Bosch 90226f7714 refactor(core): conditionally disable tests for the view engine. 2017-02-21 09:12:21 -08:00
Tobias Bosch 7db93310f1 fix: view engine - fix some corner cases 2017-02-21 09:12:21 -08:00
Tobias Bosch 32012a1ffb refactor(core): view engine - move handleEvent function from view to element
Some versions of TypeScript are super slow to compile functions that
contain a lot of `if` conditions in them. Splitting the handle event
expressions per element is similar to what we did in the old codegen.
2017-02-21 09:12:21 -08:00
Tobias Bosch 58ba4f0409 fix(compiler): make view engine work with Aot 2017-02-21 09:12:21 -08:00
Victor Berchet 2ddd1c3ed2 Revert "fix(http): Make ResponseOptionsArgs an interface (#14607)"
This reverts commit fbe4b76f2d.
2017-02-20 19:48:53 -08:00
Victor Berchet c2d5f203a5 Revert "feat(router): add an option to rerun guards and resolvers when query changes"
This reverts commit c2e0f71a78.
2017-02-20 19:48:43 -08:00
Victor Berchet 670f2eca00 Revert "fix(router): do not finish bootstrap until all the routes are resolved (#14608)"
This reverts commit 2a191cae2d.
2017-02-20 19:48:23 -08:00
Victor Berchet 2a191cae2d fix(router): do not finish bootstrap until all the routes are resolved (#14608)
Fixes #12162
closes #14155
2017-02-20 18:37:38 -08:00
vsavkin c2e0f71a78 feat(router): add an option to rerun guards and resolvers when query changes
Closes #14514
Closes #14567
2017-02-20 18:01:51 -08:00
Victor Berchet fbe4b76f2d fix(http): Make ResponseOptionsArgs an interface (#14607)
closes #13708
2017-02-20 17:55:03 -08:00
Dzmitry Shylovich 874243279d feat(forms): add option to use browser's native validation and angular forms (#13566)
Also renames NgNovalidate -> NgNoValidate

Closes #13573
2017-02-20 16:36:48 -08:00
Dzmitry Shylovich 551fe50ebd feat(forms): introduce AsyncValidator interface (#13483)
Closes #13398
2017-02-20 16:26:51 -08:00
Victor Berchet d6a58f9f70 feat(core): make `new Inject()` optional for deps specified as `InjectionToken` (#14486)
fixes #10625
2017-02-20 16:20:45 -08:00
Victor Berchet 5f3c8441e4 refactor(router): misc
closes #14517
2017-02-20 16:19:20 -08:00
Victor Berchet 78e8814103 feat(router): add `RouteConfigLoadStart` and `RouteConfigLoadEnd` events 2017-02-20 16:19:05 -08:00
Dzmitry Shylovich 7df6f46c1c feat(router): introduce RouteConfigLoaded event
Closes #14036
2017-02-20 16:19:05 -08:00
Victor Berchet 601fd3e305 fix(platform-webworker): integrate review feedback
closes #14581
2017-02-20 16:17:58 -08:00
Victor Berchet cdf99cf68b refactor(platform-webworker): cleanup 2017-02-20 16:17:43 -08:00
Victor Berchet 3517f28609 feat(platform-webworker): renderer v2 integration 2017-02-20 16:17:43 -08:00
Victor Berchet f38dbfbd64 refactor(platform-webworker): misc cleanup 2017-02-20 16:17:43 -08:00
Igor Minar 1bdf7061b8 release: cut v4.0.0-beta.8 2017-02-18 15:00:33 -08:00
Ward Bell 5129e8e47c docs(router): fix typo in canLoad interface doc comment (#14519) 2017-02-18 14:28:45 -08:00