Create `NameRegistry`, responsible for understanding how names are
generated for change detector fields and variables.
Use `NameRegistry` for both JS Jit & Dart pre-generated detectors.
Making progress on #3248
Previously, the compiler would detect cycles where there were none just because of other components that were compiled in parallel. Furthermore, the way ProtoView merging was triggered could result into early exits resulting in errors when trying to instantiate ProtoViews.
Fixes#3206Closes#3211
BREAKING CHANGE
Previously it was possible to pass a custom error reporter to bootstrap, which was used only during the construction of Injector. This had limited utility, so this capability has been removed.
BREAKING CHANGES:
Dart applications and TypeScript applications meant to transpile to Dart must now
import `package:angular2/bootstrap.dart` instead of `package:angular2/angular2.dart`
in their bootstrap code. `package:angular2/angular2.dart` no longer export the
bootstrap function. The transformer rewrites imports of `bootstrap.dart` and calls
to `bootstrap` to `bootstrap_static.dart` and `bootstrapStatic` respectively.
When a `Directive` implements a lifecycle interface (e.g. `OnChange` or
`OnInit`), populate its `lifecycle` property if not already populated).
Closes#3181
BREAKING CHANGE
The @Parent annotation has been removed. Use @Ancestor instead.
@Parent was used to enforce a particular DOM structure (e.g., a pane component is a direct child of the tabs component).
DI is not the right mechanism to do it. We should enforce it using schema instead.
The Angular 2 render compiler can get out of sync between its transformer
execution and its runtime execution, leading to incorrect change detectors with
out-of-order property values. Stable sorting solves this problem (temporarily).
Angular fetches template HTML files outside of the browser's normal parsing flow. As a result, URLs in template files are interpreted relative to the root application, when the components defined by the template files are inserted into the DOM. This change enables a template author to prefix URLs with the string $baseUrl, which will be replaced with the relative base path of the template file.
So for an example template loaded from /component/foo/template.html:
<img src="$baseUrl/logo.png" />
becomes:
<img src="/component/foo/logo.png" />
Addresses #2384.
Implement deferred libraries to work with dependency injection and other
angular codegen. This is done by not initializing the library in the parent
ng_deps file when it is declared as deferred, rewriting the import and,
chaining a future that initializes the library in any files that are using
deferred libraries which need angular codegen.
BREAKING CHANGES:
`ViewManager.createView` / `ViewContainerRef.create` have been split into 2 methods:
- `createHostView` which takes dynamically created bindings
- `createEmbeddedView` which takes the newly introduced `TemplateRef`
The new type `TemplateRef` is the combination of a `ProtoViewRef` and and `ElementRef`
from the same place. Use `TemplateRef` when working with embedded views in
`ng-if`, `ng-for`, ... instead of `ProtoViewRef`.
Also, `ProtoViewRef` is no more injectable, but `TemplateRef` is.
First part of #1989 to clean up manual content projection.
Closes#3114
Remove reflector parameter from initReflector method to simplify ng_deps for reflection
initialization. It wasn't used and was added for testability, but wasn't used. This
keeps the interface simplier.
In Dart, '$' indicates the beginning of an interpolation.
- Escapes '$' in strings when generating change detector classes.
- Adds a unit test to cover this case.
Closes#2529
BREAKING CHANGES:
- shadow dom emulation no longer
supports the `<content>` tag. Use the new `<ng-content>` instead
(works with all shadow dom strategies).
- removed `DomRenderer.setViewRootNodes` and `AppViewManager.getComponentView`
-> use `DomRenderer.getNativeElementSync(elementRef)` and change shadow dom directly
- the `Renderer` interface has changed:
* `createView` now also has to support sub views
* the notion of a container has been removed. Instead, the renderer has
to implement methods to attach views next to elements or other views.
* a RenderView now contains multiple RenderFragments. Fragments
are used to move DOM nodes around.
Internal changes / design changes:
- Introduce notion of view fragments on render side
- DomProtoViews and DomViews on render side are merged,
AppProtoViews are not merged, AppViews are partially merged
(they share arrays with the other merged AppViews but we keep
individual AppView instances for now).
- DomProtoViews always have a `<template>` element as root
* needed for storing subviews
* we have less chunks of DOM to clone now
- remove fake ElementBinder / Bound element for root text bindings
and model them explicitly. This removes a lot of special cases we had!
- AppView shares data with nested component views
- some methods in AppViewManager (create, hydrate, dehydrate) are iterative now
* now possible as we have all child AppViews / ElementRefs already in an array!
By binding the token `DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES` provided by
the dom_renderer module to `true` in the root injector (i.e. bootstrap()),
all elements whose properties are set by angular will be reflected as
attributes with the prefix "ng-reflect-".
Fixes#2910
This fixes several minor indentation issues (instanceof precendence,
type declaration specificity, template string length calculation).
This should also fix some flip-flop situations with template strings.
BREAKING CHANGE:
This change renames all instances of PipeRegistry to Pipes.
As part of this change, the former "defaultPipes" export is
now a Pipes instance, instead of a map. The map that was previously
called "defaultPipes" no longer exists, but may be accessed via
defaultPipes.config.
This is its own commit so that tools have an easier time of preserving
history of the file, by keeping the diff between pipes.ts and
pipe_registry.ts minimal.
Also moved pipe_registry_spec.ts
In non-transformed mode the funcOrValue check was enough, but once
transformed these all use the same function for getters, so we need
to also check the name.
The BaseRequestOptions class is responsible for declaring default values,
while the RequestOptions class is merely responsible for setting values
based on values provided in the constructor.
BREAKING CHANGE: HttpFactory is no longer available.
This factory provided a function alternative to the `request` method of the
Http class, but added no real value. The additional factory required an
additional IHttp interface, an odd way to inject while preserving type information
(`@Inject(HttpFactory) http:IHttp`), and required additional documentation in the
http module.
Closes#2564
BREAKING CHANGES:
- rename `ElementRef.domElement` to `ElementRef.nativeElement`
- add `Renderer.getNativeElementSync` to make the app side
less dependent on the dom renderer.
- don’t use `ElementRef.nativeElement` in directives but
use the methods on `Renderer` directly.
- Removed `ElementRef.setAttribute`. Use `Renderer.setElementAttribute` instead.
Closes#2712
Last part of #2476Closes#2476
BREAKING CHANGES:
- Almost all methods in `Renderer` now take a `RenderElementRef` instead
of a `ViewRef` + `boundElementIndex`.
- These methods can be called with the `ElementRef` from the app side
directly.
Closes#2706
Related to #2476
BREAKING CHANGES:
- host actions don't take an expression as value any more but only a method name,
and assumes to get an array via the EventEmitter with the method arguments.
- Renderer.setElementProperty does not take `style.`/... prefixes any more.
Use the new methods `Renderer.setElementAttribute`, ... instead
Part of #2476Closes#2637
BREAKING CHANGE: compiler will throw on binding to non-existing properties.
Till now it was possible to have a binding to a non-existing property,
ex.: `<div [foo]="exp">`. From now on this is compilation error - any
property binding needs to have at least one associated property:
eaither on an HTML element or on any directive associated with a
given element (directives' properites need to be declared using the
`properties` field in the `@Directive` / `@Component` annotation).
Closes#2598
While creating the ng_deps.dart file for a view inline the styleUrls attribute.
This copies the pattern used for templateUrl, aleviating the need to make an
XHR request for those resources.
closes#2566
Allows to add or remove previous siblings of text
interpolations (e.g. by added `<script>` tags for
content reproduction, or by removed `<style>` tags).
Also calculates correctly whether an element is
empty.
Fixes#2591
These wrappers are not natively understood by
ts2dart. Removing them will improve Dart2JS
compilation due to fewer megamorphic calls to List
functions.
It also makes Angular code more succinct and
improves type safety in Angular due to better type
inference of the Array component type.
This change exposed several bugs in Angular.
Closes#2472Closes#2339
BREAKING CHANGE
- `Compiler.compile` has been removed, the only way to compile
components dynamically is via `Compiler.compileInHost`
- `DynamicComponentLoader.loadIntoExistingLocation` has changed:
* renamed into `loadIntoLocation`
* will always create the host element as well
* requires an element with a variable inside of the host component view
next to which it will load new component.
- `DynamicComponentLoader.loadNextToExistingLocation` was renamed into
`DynamicComponentLoader.loadNextToLocation`
- `DynamicComponentLoader.loadIntoNewLocation` is removed
* use `DynamicComponentLoader.loadNextToLocation` instead
and then move the view nodes
manually around via `DomRenderer.getRootNodes()`
- `AppViewManager.{create,destroy}Free{Host,Embedded}View` was removed
* use `AppViewManager.createViewInContainer` and then move the view nodes
manually around via `DomRenderer.getRootNodes()`
- `Renderer.detachFreeView` was removed. Use `DomRenderer.getRootNodes()`
to get the root nodes of a view and detach them manually.
There are upcoming changes to the way we generate
and verify setters so more test are needed to cover
all the corner cases that are being handled today.
Closes#2559
Enable pregenerated (for Dart) and JIT (for Js) change detectors when
possible. Previously we would always use `DynamicChangeDetector`s, but
these cause megamorphic calls and are therefore much slower.
Closes#502
Move all remaining unit tests for change detectors to exercise Dart
pre-generated change detectors as well as `dynamic` and `JIT` change
detectors.
See #502
More the change detect tests that exercise various detection modes to
use the Dart pre-generated change detectors in addition to the `dynamic`
and `JIT` change detectors.
See #502
This implementation only works in JavaScript, while the Observable transpilation
story gets worked out. Right now, the service just makes a simple request,
and returns an Observable of Response.
Additional functionality will be captured in separate issues.
Fixes#2028
- Modify change detectors to `throw` when attempting to detect changes
on a dehydrated detector.
- Modify `DynamicChagneDetector` to use `null` for the `context` of a
dehydrated detector.
Note that this also removes the `components` option from `RouteConfig`.
This functionality will be reintroduced with the more general `//` routing.
See #2329 for more details.
Update the transformer's `TemplateCompiler` phase to avoid setting
`reflector.reflectionCapabilities`, allowing asynchronous
operations, and restoring the original value, which allows
`reflector.reflectionCapabilities` to get into a bad state.
Add a type for the `context` field in Dart's pre-generated change
detectors. This requires slight changes to set the dehydrated value of
`context` to `null` rather than `ChangeDetectionUtil.uninitialized()`,
which was its former dehydrated state.
Mirror these chagnes as closely as possible in the
`ChangeDetectionJITGenerator` to allow easier maintenance.
Closes#2070
To support interface-based lifecycle methods (#2220), we need to be able
to query for the `interface`s a class supports. Record implemented
interfaces to allow mirror-less querying at runtime.
Closes#2204
Replaces the multiple arrays of `DomView`
by a single array with `DomElement`s.
Note: this commit does not show a performance regression
(tested against the tree benchmark locally).
clang-format 1.0.17 substantially improves formatting for fat arrow functions
and array literal detection. It also fixes a number of minor formatting issues.
Free embedded views are view instances that are created
logically in the same was as views of a ViewContainer,
but their dom nodes are not attached.
BREAKING CHANGE:
- `Renderer.detachFreeHostView` was renamed to
`Renderer.detachFreeView`
- `DomRenderer.getHostElement()` was generalized into
`DomRenderer.getRootNodes()`
Largetable benchmark with `interpolationAttr` and 200 rows / 20 columns:
Time for destroy/create pair dropped from about 1260ms to about 150ms.
Related to #2298, but does not really fix it as we are still slow
if people are using `<content>`.
Closes#2297
The semantics between ES6 `Promise#all` and Dart's `Future#wait` are
different for values that are not `Promise`/`Future`s. In ES6,
non-`Promise` values are immediately completed to their current value.
In Dart, non-`Future` values cause an error.
Updated Dart's `PromiseWrapper#all` implementation to conform to the ES6
spec.
Use the `ProtoViewDto` created by the render `Compiler` to create a
`ChangeDetectorDefinition`.
From there, generate a subclass of `AbstractChangeDetector` for each
`ChangeDetectorDefinition`.
Run some basic unit tests for the dynamic and JIT change detectors on
pre-generated change detectors.
Usage: bootstrap the app with the special binding
`ELEMENT_PROBE_CONFIG` from `angular2/debug`.
This will provide a global method `ngProbe(element)` that
will expose a `DebugElement` with directive instances, ... on it.
During tests that use Angular's test injector, the probe is
enabled by default. The `DebugElement ` can be retrieved via the
function `inspectDomElement` of `angular2/debug`. Note
that the `TestComponentBuilder` already returns `DebugElement `s.
Closes#1992
Removes `.ng_deps.dart` files which
1. Do not register any `@Injectable` classes
2. Do not call `initReflector` on any other `.ng_deps.dart` files.
Closes#1929