From 85211f0a6bf5101bc2a1e4bee2d1b6e3cb328842 Mon Sep 17 00:00:00 2001 From: Marc Laval Date: Thu, 19 Feb 2015 18:14:29 +0100 Subject: [PATCH] fix(core): workaround for circular dependencies in nodejs Closes #716 --- .../src/core/compiler/view_container.js | 28 +++++++++---------- .../angular2/src/core/compiler/view_pool.js | 8 +++--- .../outputgeneration/DartParseTreeWriter.js | 6 ++++ 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/modules/angular2/src/core/compiler/view_container.js b/modules/angular2/src/core/compiler/view_container.js index 09aab4908b..c92fd8f2dc 100644 --- a/modules/angular2/src/core/compiler/view_container.js +++ b/modules/angular2/src/core/compiler/view_container.js @@ -1,25 +1,25 @@ -import {View, ProtoView} from './view'; +import * as viewModule from './view'; import {DOM, Node, Element} from 'angular2/src/facade/dom'; import {ListWrapper, MapWrapper, List} from 'angular2/src/facade/collection'; import {BaseException} from 'angular2/src/facade/lang'; import {Injector} from 'angular2/di'; -import {ElementInjector} from 'angular2/src/core/compiler/element_injector'; +import * as eiModule from 'angular2/src/core/compiler/element_injector'; import {isPresent, isBlank} from 'angular2/src/facade/lang'; import {EventManager} from 'angular2/src/core/events/event_manager'; export class ViewContainer { - parentView: View; + parentView: viewModule.View; templateElement: Element; - defaultProtoView: ProtoView; - _views: List; + defaultProtoView: viewModule.ProtoView; + _views: List; _lightDom: any; _eventManager: EventManager; - elementInjector: ElementInjector; + elementInjector: eiModule.ElementInjector; appInjector: Injector; - hostElementInjector: ElementInjector; + hostElementInjector: eiModule.ElementInjector; - constructor(parentView: View, templateElement: Element, defaultProtoView: ProtoView, - elementInjector: ElementInjector, eventManager: EventManager, lightDom = null) { + constructor(parentView: viewModule.View, templateElement: Element, defaultProtoView: viewModule.ProtoView, + elementInjector: eiModule.ElementInjector, eventManager: EventManager, lightDom = null) { this.parentView = parentView; this.templateElement = templateElement; this.defaultProtoView = defaultProtoView; @@ -33,7 +33,7 @@ export class ViewContainer { this._eventManager = eventManager; } - hydrate(appInjector: Injector, hostElementInjector: ElementInjector) { + hydrate(appInjector: Injector, hostElementInjector: eiModule.ElementInjector) { this.appInjector = appInjector; this.hostElementInjector = hostElementInjector; } @@ -50,7 +50,7 @@ export class ViewContainer { } } - get(index: number): View { + get(index: number): viewModule.View { return this._views[index]; } @@ -69,7 +69,7 @@ export class ViewContainer { // TODO(rado): profile and decide whether bounds checks should be added // to the methods below. - create(atIndex=-1): View { + create(atIndex=-1): viewModule.View { if (!this.hydrated()) throw new BaseException( 'Cannot create views on a dehydrated ViewContainer'); // TODO(rado): replace with viewFactory. @@ -78,7 +78,7 @@ export class ViewContainer { return this.insert(newView, atIndex); } - insert(view, atIndex=-1): View { + insert(view, atIndex=-1): viewModule.View { if (atIndex == -1) atIndex = this._views.length; ListWrapper.insert(this._views, atIndex, view); if (isBlank(this._lightDom)) { @@ -104,7 +104,7 @@ export class ViewContainer { * The method can be used together with insert to implement a view move, i.e. * moving the dom nodes while the directives in the view stay intact. */ - detach(atIndex=-1): View { + detach(atIndex=-1): viewModule.View { if (atIndex == -1) atIndex = this._views.length - 1; var detachedView = this.get(atIndex); ListWrapper.removeAt(this._views, atIndex); diff --git a/modules/angular2/src/core/compiler/view_pool.js b/modules/angular2/src/core/compiler/view_pool.js index 8c9b5bce44..ef6d42d67e 100644 --- a/modules/angular2/src/core/compiler/view_pool.js +++ b/modules/angular2/src/core/compiler/view_pool.js @@ -1,19 +1,19 @@ import {ListWrapper, MapWrapper, StringMapWrapper, List} from 'angular2/src/facade/collection'; -import {View} from './view'; +import * as viewModule from './view'; export class ViewPool { - _views: List; + _views: List; _capacity: number; constructor(capacity: number) { this._views = []; this._capacity = capacity; } - pop(): View { + pop(): viewModule.View { return ListWrapper.isEmpty(this._views) ? null : ListWrapper.removeLast(this._views); } - push(view: View) { + push(view: viewModule.View) { if (this._views.length < this._capacity) { ListWrapper.push(this._views, view); } diff --git a/tools/transpiler/src/outputgeneration/DartParseTreeWriter.js b/tools/transpiler/src/outputgeneration/DartParseTreeWriter.js index 896d9dcd2b..17e51a51ba 100644 --- a/tools/transpiler/src/outputgeneration/DartParseTreeWriter.js +++ b/tools/transpiler/src/outputgeneration/DartParseTreeWriter.js @@ -16,6 +16,7 @@ import { OPEN_PAREN, OBJECT_PATTERN, OPEN_SQUARE, + PERIOD, SEMI_COLON, STAR, STATIC, @@ -273,6 +274,11 @@ export class DartParseTreeWriter extends JavaScriptParseTreeWriter { args = []; } + if (typeNameNode.moduleName && typeNameNode.moduleName.name && typeNameNode.moduleName.name.value) { + this.write_(typeNameNode.moduleName.name.value); + this.write_(PERIOD); + } + // TODO(vojta): Figure out why `typeNameNode` has different structure when used with a variable. // This should probably be fixed in Traceur. var typeName = typeNameNode.typeToken && typeNameNode.typeToken.value || (typeNameNode.name && typeNameNode.name.value) || null;