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
It is possible for a class defined first to be referencing a class defined later,
and as a result at the time of the definition it is not possible to access the later's
class reference. This allows to refer to the later defined class through
a closure.Closes #1891
BREAKING CHANGE:
`AppViewManager.createInPlaceHostView` is replaced by
`AppViewManager.createRootHostView` (for bootstrap) and
`AppViewManager.createFreeHostView` (for imperative components).
The later creates new host elements that are not attached anywhere.
To attach them, use `DomRenderer.getHostElement(hostviewRef)`
to get the host element.
Closes#1920
Also consolidates metadata handling in `ElementInjector`
BREAKING CHANGE:
- renames `DirectiveMetadataReader` into `DirectiveResolver`
and removes `src/core/compiler/directive_metadata`.
Fixes#1712Fixes#1713
BREAKING CHANGE:
VmTurnZone has been renamed to NgZone.
- The public API has not chnanged,
- The "outer" zone is now named "mount" zone (private to NgZone).
Before this PR there were only 2 zones: root zone = outer zone > inner
zone.
This PR creates the outer zone as a fork of the root zone: root > outer
> inner.
By doing this it is possible to detected microtasks scheduling in the
outer zone and run the change detection less often (no more than one
time per VM turn).
The PR also introduce a Promise monkey patch for the JS implementation.
It makes Promises aware of microtasks and again allow running the change
detection only once per turn.
The async pipe in templates will now delegate to both Observable pipe or Promise pipe,
whichever first says it can support the input. Therefore, it's beneficial to disambiguate
the name of the AsyncPipe/AsyncPipeFactory constructors to reflect that these actually
support only Observables.
Update the `TemplateCompile` step to use the full render `Compiler`.
Provide `DirectiveMetadata` for `ViewDefinition` objects and use it to
run the `DirectiveParser` step of the render compile pipeline.
The goal is to make implementing a renderer straight forward.
BREAKING_CHANGE:
- Renderer interface was redone / simplified.
- `DirectDomRenderer` was replaced by `DomRenderer`.
- `DirectDomRenderer.setImperativeComponentRootNodes` is replaced
by the following 2 steps:
1. `ViewManager.getComponentView(elementRef) -> ViewRef`
2. `DomRenderer.setComponentViewRootNodes(viewRef, rootNodes)`
- all `@View` annotations need to have a template, but the template
may be empty. Previously views that had a `renderer` property did
not have to have a `template`.
- `dynamicComponentLoader.loadIntoNewLocation` does no more allow
to pass an element, but requires a css selector.
Special syntax: `:document` can be used as prefix to search globally
on the document instead of in the provided parent view.
Part of #1675
Using string1 === string2 translates to identical(string1, string2) in
dart, which is incorrect as it is possilbe for dart strings to have
different reference.
Add a step that reads `DirectiveMetadata` object off annotated classes
into `.ng_meta.dart` files. These will be used by the `TemplateCompiler`
step as inputs to the Angular 2 render compiler.
Update one test to avoid unsupported functionality, format others.
In 'angular2/di' the symbol:
- Inject is a decorator
- InjectAnnotation is an annotation
Internally one an get a hold of annotations without *Annotations appened
(to make ts2dart work without workarounds) by importing from
'angular2/src/di/annotations_impl' instead of 'angular2/di'. This is
needed only for users that transpile through TS and through ts2dart.
This removes .es6 files which are pure duplicates of a
.ts file in the same folder.
Next we need to remove .js files as well, and remove karma preprocessors for dart.
BREAKING CHANGE:
Previously, `Directive` was the abstract base class of several directives.
Now, `Directive` is the former `Decorator`, and `Component` inherits from it.
BREAKING_CHANGE:
- The special type of `Viewport` directives is removed
in favor of a more general `Decorator` directive
- `ViewContainerRef` now no more has a default `ProtoViewRef`
but requires an explicit one when creating views.
Closes#1536
Add utility methods to convert `render.dom.DirectiveMetadata` to and
from maps. This will allow saving and restoring `DirectiveMetadata` in
the Angular 2 Transformer.
We discussed adding this as a member on `DirectiveMetadata`. Since this
is not necessary for anything except the Transformer, we decided to put
it into a separate file to avoid shipping it with the Angular 2 core
code.
BREAKING CHANGES:
- `NgElement` merged into `ElementRef`
- `Compiler.compile…` returns `ProtoViewRef`
- `ViewContainer` uses `ProtoViewRef`s and `ViewRef`s.
- `ViewRef`/`ProtoViewRef` in renderer were renamed to
`RenderViewRef`/`RenderProtoViewRef`.
Related to #1477Closes#1592
AppViewManager is the single entry point to changing the view hierarchy.
It is split between the manager itself which does coordination and
helper methods, so both are easily testable in isolation.
Also, ViewContainer is now only a pure reference to a bound element
with the previous functionality but does not contain the list of views
any more.
Part of #1477
Add two transform parameters to aid in debugging the transformer
- `mirror_mode`, with values {`debug`, `none`, and `verbose`}
- `init_reflector`, with values {`true`, `false`}
`mirror_mode`:
- `debug`: Allow reflective access, but log a message if it is used
- `none`: Remove reflective access, `throw` if it is used. Default value
- `verbose`: Allow reflective access, log a stack trace if it is used
`init_reflector`: Whether to generate calls to our generated
`initReflector` code.
These will be useful to reveal areas where the transformer is not generating
appropriate code and to quickly see where reflective accesses occur.
When the pub mode is `transform_dynamic`, we run in MirrorMode.debug
with `init_reflector = false`. This is used for testing purposes.
Previously, light dom nodes that were not used by any content tag
were not removed from a view on redistribute. This lead
to a bug when reusing a view from the view pool, as it
still contained stale reprojected nodes.
Fixes#1416
Major changes:
- `compiler.compileRoot(el, type)`
-> `compiler.compileInHost(type) + viewHydrator.hydrateHostViewInPlace(el, view)`
- move all `hydrate`/`dehydrate` methods out of `View` and `ViewContainer` into
a standalone class `view_hydrator` as private methods and provide new public
methods dedicated to the individual use cases.
Note: This PR does not change the current functionality, only moves it
into different places.
See design discussion in #1351, in preparation for imperative views.
Create a method that recursively walks imports from an entry point and
determines where classes are registered.
Use this information to determine if a particular annotation implements or
extends Injectable or Template.
Add two factory static functions to Injector: resolveAndCreate and
fromResolvedBindings.
We want to avoid resolution and flattening every time we create a new
injector. This commit allows the user to cache resolved bindings and
reuse them.
- Allow the user to specify multiple entry points to an app.
- Allow the Angular 2 transformer to run without explicit entry points to
generate necessary setters & getters on built-in directives like `For`
and `If`.
Closes#1246
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
(keydown.shift.enter)
(keyup.space)
(keydown.control.shift.a)
(keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close#523close#1136
Queries allow a directive to inject a live list of directives of a given
type from its LightDom. The injected list is Iterable (in JS and Dart).
It will be Observable when Observables are support in JS, for now it
maintains a simple list of onChange callbacks API.
To support queries, element injectors now maintain a list of
child injectors in the correct DOM order (dynamically updated by
viewports).
For performance reasons we allow only 3 active queries in an injector
subtree. The feature adds no overhead to the application when not
used. Queries walk the injector tree only during dynamic view
addition/removal as triggered by viewport directives.
Syncs changes between viewContainer on the render and logic sides.
Closes#792
Introduces angular2/src/core/compiler/ViewFactory which
extracts ProtoView.instantiate and replaces ViewPool.
Note: This is a work in progress commit to unblock other commits.
There will be follow ups to add unit tests, remove TODOs, …
Needed to change Renderer.mergeChildComponentProtoViews to not create
new ProtoViews to be able to deal with cyclic references.
This commit is part of using the new render layer in Angular.