refactor(compiler): use the new compiler everywhere
Closes #3605 BREAKING CHANGE: - we don't mark an element as bound any more if it only contains text bindings E.g. <div>{{hello}}</div> This changes the indices when using `DebugElement.componentViewChildren` / `DebugElement.children`. - `@Directive.compileChildren` was removed, `ng-non-bindable` is now builtin and not a directive any more - angular no more adds the `ng-binding` class to elements with bindings - directives are now ordered as they are listed in the View.directives regarding change detection. Previously they had an undefined order. - the `Renderer` interface has new methods `createProtoView` and `registerComponentTemplate`. See `DomRenderer` for default implementations. - reprojection with `ng-content` is now all or nothing per `ng-content` element - angular2 transformer can't be used in tests that modify directive metadata. Use `angular2/src/transform/inliner_for_test` transformer instead.
This commit is contained in:
@ -18,7 +18,7 @@ import {
|
||||
DomEventsPlugin,
|
||||
EVENT_MANAGER_PLUGINS
|
||||
} from 'angular2/src/core/render/dom/events/event_manager';
|
||||
import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler';
|
||||
import {ProtoViewFactory} from 'angular2/src/core/compiler/proto_view_factory';
|
||||
import {BrowserDomAdapter} from 'angular2/src/core/dom/browser_adapter';
|
||||
import {KeyEventsPlugin} from 'angular2/src/core/render/dom/events/key_events';
|
||||
import {HammerGesturesPlugin} from 'angular2/src/core/render/dom/events/hammer_gestures';
|
||||
@ -46,7 +46,6 @@ import {NgZone} from 'angular2/src/core/zone/ng_zone';
|
||||
import {AppViewManager} from 'angular2/src/core/compiler/view_manager';
|
||||
import {AppViewManagerUtils} from 'angular2/src/core/compiler/view_manager_utils';
|
||||
import {AppViewListener} from 'angular2/src/core/compiler/view_listener';
|
||||
import {ProtoViewFactory} from 'angular2/src/core/compiler/proto_view_factory';
|
||||
import {ViewResolver} from 'angular2/src/core/compiler/view_resolver';
|
||||
import {ViewLoader} from 'angular2/src/core/render/dom/compiler/view_loader';
|
||||
import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
|
||||
@ -68,7 +67,6 @@ import {
|
||||
import {AnchorBasedAppRootUrl} from 'angular2/src/core/services/anchor_based_app_root_url';
|
||||
import {WebWorkerApplication} from 'angular2/src/web_workers/ui/impl';
|
||||
import {MessageBus} from 'angular2/src/web_workers/shared/message_bus';
|
||||
import {MessageBasedRenderCompiler} from 'angular2/src/web_workers/ui/render_compiler';
|
||||
import {MessageBasedRenderer} from 'angular2/src/web_workers/ui/renderer';
|
||||
import {MessageBasedXHRImpl} from 'angular2/src/web_workers/ui/xhr_impl';
|
||||
import {WebWorkerSetup} from 'angular2/src/web_workers/ui/setup';
|
||||
@ -111,14 +109,12 @@ function _injectorBindings(): any[] {
|
||||
bind(ElementSchemaRegistry).toValue(new DomElementSchemaRegistry()),
|
||||
RenderViewWithFragmentsStore,
|
||||
RenderProtoViewRefStore,
|
||||
ProtoViewFactory,
|
||||
AppViewPool,
|
||||
bind(APP_VIEW_POOL_CAPACITY).toValue(10000),
|
||||
AppViewManager,
|
||||
AppViewManagerUtils,
|
||||
AppViewListener,
|
||||
Compiler,
|
||||
CompilerCache,
|
||||
ProtoViewFactory,
|
||||
ViewResolver,
|
||||
DEFAULT_PIPES,
|
||||
bind(ChangeDetection).toValue(bestChangeDetection),
|
||||
@ -138,7 +134,6 @@ function _injectorBindings(): any[] {
|
||||
bind(AppRootUrl).toAlias(AnchorBasedAppRootUrl),
|
||||
WebWorkerApplication,
|
||||
WebWorkerSetup,
|
||||
MessageBasedRenderCompiler,
|
||||
MessageBasedXHRImpl,
|
||||
MessageBasedRenderer,
|
||||
ServiceMessageBrokerFactory,
|
||||
|
@ -77,7 +77,6 @@ Map<String, dynamic> serializeKeyboardEvent(dynamic e) {
|
||||
serialized['eventPhase'] = e.eventPhase;
|
||||
serialized['keyCode'] = e.keyCode;
|
||||
serialized['keyLocation'] = e.keyLocation;
|
||||
serialized['layer'] = serializePoint(e.layer);
|
||||
serialized['location'] = e.location;
|
||||
serialized['repeat'] = e.repeat;
|
||||
serialized['shiftKey'] = e.shiftKey;
|
||||
|
@ -12,7 +12,6 @@ import {Injectable} from 'angular2/src/core/di';
|
||||
import {BrowserDomAdapter} from 'angular2/src/core/dom/browser_adapter';
|
||||
import {wtfInit} from 'angular2/src/core/profile/wtf_init';
|
||||
import {WebWorkerSetup} from 'angular2/src/web_workers/ui/setup';
|
||||
import {MessageBasedRenderCompiler} from 'angular2/src/web_workers/ui/render_compiler';
|
||||
import {MessageBasedRenderer} from 'angular2/src/web_workers/ui/renderer';
|
||||
import {MessageBasedXHRImpl} from 'angular2/src/web_workers/ui/xhr_impl';
|
||||
import {
|
||||
@ -35,7 +34,6 @@ export function bootstrapUICommon(bus: MessageBus): WebWorkerApplication {
|
||||
bus.attachToZone(zone);
|
||||
return zone.run(() => {
|
||||
var injector = createInjector(zone, bus);
|
||||
injector.get(MessageBasedRenderCompiler).start();
|
||||
injector.get(MessageBasedRenderer).start();
|
||||
injector.get(MessageBasedXHRImpl).start();
|
||||
injector.get(WebWorkerSetup).start();
|
||||
|
@ -1,31 +0,0 @@
|
||||
import {Injectable} from 'angular2/src/core/di/decorators';
|
||||
import {
|
||||
RenderDirectiveMetadata,
|
||||
ProtoViewDto,
|
||||
ViewDefinition,
|
||||
RenderProtoViewRef,
|
||||
RenderProtoViewMergeMapping,
|
||||
RenderCompiler
|
||||
} from 'angular2/src/core/render/api';
|
||||
import {RENDER_COMPILER_CHANNEL} from 'angular2/src/web_workers/shared/messaging_api';
|
||||
import {bind} from './bind';
|
||||
import {ServiceMessageBrokerFactory} from 'angular2/src/web_workers/shared/service_message_broker';
|
||||
|
||||
@Injectable()
|
||||
export class MessageBasedRenderCompiler {
|
||||
constructor(private _brokerFactory: ServiceMessageBrokerFactory,
|
||||
private _renderCompiler: RenderCompiler) {}
|
||||
|
||||
start(): void {
|
||||
var broker = this._brokerFactory.createMessageBroker(RENDER_COMPILER_CHANNEL, false);
|
||||
broker.registerMethod("compileHost", [RenderDirectiveMetadata],
|
||||
bind(this._renderCompiler.compileHost, this._renderCompiler),
|
||||
ProtoViewDto);
|
||||
broker.registerMethod("compile", [ViewDefinition],
|
||||
bind(this._renderCompiler.compile, this._renderCompiler), ProtoViewDto);
|
||||
broker.registerMethod(
|
||||
"mergeProtoViewsRecursively", [RenderProtoViewRef],
|
||||
bind(this._renderCompiler.mergeProtoViewsRecursively, this._renderCompiler),
|
||||
RenderProtoViewMergeMapping);
|
||||
}
|
||||
}
|
@ -5,13 +5,15 @@ import {
|
||||
RenderViewRef,
|
||||
RenderFragmentRef,
|
||||
RenderProtoViewRef,
|
||||
Renderer
|
||||
Renderer,
|
||||
RenderTemplateCmd
|
||||
} from 'angular2/src/core/render/api';
|
||||
import {WebWorkerElementRef} from 'angular2/src/web_workers/shared/api';
|
||||
import {WebWorkerElementRef, WebWorkerTemplateCmd} from 'angular2/src/web_workers/shared/api';
|
||||
import {EVENT_CHANNEL, RENDERER_CHANNEL} from 'angular2/src/web_workers/shared/messaging_api';
|
||||
import {Type} from 'angular2/src/core/facade/lang';
|
||||
import {bind} from './bind';
|
||||
import {EventDispatcher} from 'angular2/src/web_workers/ui/event_dispatcher';
|
||||
import {RenderProtoViewRefStore} from 'angular2/src/web_workers/shared/render_proto_view_ref_store';
|
||||
import {
|
||||
RenderViewWithFragmentsStore
|
||||
} from 'angular2/src/web_workers/shared/render_view_with_fragments_store';
|
||||
@ -21,12 +23,18 @@ import {ServiceMessageBrokerFactory} from 'angular2/src/web_workers/shared/servi
|
||||
export class MessageBasedRenderer {
|
||||
constructor(private _brokerFactory: ServiceMessageBrokerFactory, private _bus: MessageBus,
|
||||
private _serializer: Serializer,
|
||||
private _renderProtoViewRefStore: RenderProtoViewRefStore,
|
||||
private _renderViewWithFragmentsStore: RenderViewWithFragmentsStore,
|
||||
private _renderer: Renderer) {}
|
||||
|
||||
start(): void {
|
||||
var broker = this._brokerFactory.createMessageBroker(RENDERER_CHANNEL);
|
||||
this._bus.initChannel(EVENT_CHANNEL);
|
||||
|
||||
broker.registerMethod("registerComponentTemplate", [PRIMITIVE, WebWorkerTemplateCmd, PRIMITIVE],
|
||||
bind(this._renderer.registerComponentTemplate, this._renderer));
|
||||
broker.registerMethod("createProtoView", [WebWorkerTemplateCmd, PRIMITIVE],
|
||||
bind(this._createProtoView, this));
|
||||
broker.registerMethod("createRootHostView",
|
||||
[RenderProtoViewRef, PRIMITIVE, PRIMITIVE, PRIMITIVE],
|
||||
bind(this._createRootHostView, this));
|
||||
@ -64,6 +72,11 @@ export class MessageBasedRenderer {
|
||||
this._renderViewWithFragmentsStore.remove(viewRef);
|
||||
}
|
||||
|
||||
private _createProtoView(cmds: RenderTemplateCmd[], refIndex: number) {
|
||||
var protoViewRef = this._renderer.createProtoView(cmds);
|
||||
this._renderProtoViewRefStore.store(protoViewRef, refIndex);
|
||||
}
|
||||
|
||||
private _createRootHostView(ref: RenderProtoViewRef, fragmentCount: number, selector: string,
|
||||
startIndex: number) {
|
||||
var renderViewWithFragments = this._renderer.createRootHostView(ref, fragmentCount, selector);
|
||||
|
Reference in New Issue
Block a user