Skip to content

Commit 85211f0

Browse files
marclavalmhevery
authored andcommitted
fix(core): workaround for circular dependencies in nodejs
Closes angular#716
1 parent d0ca07a commit 85211f0

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

modules/angular2/src/core/compiler/view_container.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
import {View, ProtoView} from './view';
1+
import * as viewModule from './view';
22
import {DOM, Node, Element} from 'angular2/src/facade/dom';
33
import {ListWrapper, MapWrapper, List} from 'angular2/src/facade/collection';
44
import {BaseException} from 'angular2/src/facade/lang';
55
import {Injector} from 'angular2/di';
6-
import {ElementInjector} from 'angular2/src/core/compiler/element_injector';
6+
import * as eiModule from 'angular2/src/core/compiler/element_injector';
77
import {isPresent, isBlank} from 'angular2/src/facade/lang';
88
import {EventManager} from 'angular2/src/core/events/event_manager';
99

1010
export class ViewContainer {
11-
parentView: View;
11+
parentView: viewModule.View;
1212
templateElement: Element;
13-
defaultProtoView: ProtoView;
14-
_views: List<View>;
13+
defaultProtoView: viewModule.ProtoView;
14+
_views: List<viewModule.View>;
1515
_lightDom: any;
1616
_eventManager: EventManager;
17-
elementInjector: ElementInjector;
17+
elementInjector: eiModule.ElementInjector;
1818
appInjector: Injector;
19-
hostElementInjector: ElementInjector;
19+
hostElementInjector: eiModule.ElementInjector;
2020

21-
constructor(parentView: View, templateElement: Element, defaultProtoView: ProtoView,
22-
elementInjector: ElementInjector, eventManager: EventManager, lightDom = null) {
21+
constructor(parentView: viewModule.View, templateElement: Element, defaultProtoView: viewModule.ProtoView,
22+
elementInjector: eiModule.ElementInjector, eventManager: EventManager, lightDom = null) {
2323
this.parentView = parentView;
2424
this.templateElement = templateElement;
2525
this.defaultProtoView = defaultProtoView;
@@ -33,7 +33,7 @@ export class ViewContainer {
3333
this._eventManager = eventManager;
3434
}
3535

36-
hydrate(appInjector: Injector, hostElementInjector: ElementInjector) {
36+
hydrate(appInjector: Injector, hostElementInjector: eiModule.ElementInjector) {
3737
this.appInjector = appInjector;
3838
this.hostElementInjector = hostElementInjector;
3939
}
@@ -50,7 +50,7 @@ export class ViewContainer {
5050
}
5151
}
5252

53-
get(index: number): View {
53+
get(index: number): viewModule.View {
5454
return this._views[index];
5555
}
5656

@@ -69,7 +69,7 @@ export class ViewContainer {
6969

7070
// TODO(rado): profile and decide whether bounds checks should be added
7171
// to the methods below.
72-
create(atIndex=-1): View {
72+
create(atIndex=-1): viewModule.View {
7373
if (!this.hydrated()) throw new BaseException(
7474
'Cannot create views on a dehydrated ViewContainer');
7575
// TODO(rado): replace with viewFactory.
@@ -78,7 +78,7 @@ export class ViewContainer {
7878
return this.insert(newView, atIndex);
7979
}
8080

81-
insert(view, atIndex=-1): View {
81+
insert(view, atIndex=-1): viewModule.View {
8282
if (atIndex == -1) atIndex = this._views.length;
8383
ListWrapper.insert(this._views, atIndex, view);
8484
if (isBlank(this._lightDom)) {
@@ -104,7 +104,7 @@ export class ViewContainer {
104104
* The method can be used together with insert to implement a view move, i.e.
105105
* moving the dom nodes while the directives in the view stay intact.
106106
*/
107-
detach(atIndex=-1): View {
107+
detach(atIndex=-1): viewModule.View {
108108
if (atIndex == -1) atIndex = this._views.length - 1;
109109
var detachedView = this.get(atIndex);
110110
ListWrapper.removeAt(this._views, atIndex);

modules/angular2/src/core/compiler/view_pool.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import {ListWrapper, MapWrapper, StringMapWrapper, List} from 'angular2/src/facade/collection';
2-
import {View} from './view';
2+
import * as viewModule from './view';
33

44
export class ViewPool {
5-
_views: List<View>;
5+
_views: List<viewModule.View>;
66
_capacity: number;
77
constructor(capacity: number) {
88
this._views = [];
99
this._capacity = capacity;
1010
}
1111

12-
pop(): View {
12+
pop(): viewModule.View {
1313
return ListWrapper.isEmpty(this._views) ? null : ListWrapper.removeLast(this._views);
1414
}
1515

16-
push(view: View) {
16+
push(view: viewModule.View) {
1717
if (this._views.length < this._capacity) {
1818
ListWrapper.push(this._views, view);
1919
}

tools/transpiler/src/outputgeneration/DartParseTreeWriter.js

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
OPEN_PAREN,
1717
OBJECT_PATTERN,
1818
OPEN_SQUARE,
19+
PERIOD,
1920
SEMI_COLON,
2021
STAR,
2122
STATIC,
@@ -273,6 +274,11 @@ export class DartParseTreeWriter extends JavaScriptParseTreeWriter {
273274
args = [];
274275
}
275276

277+
if (typeNameNode.moduleName && typeNameNode.moduleName.name && typeNameNode.moduleName.name.value) {
278+
this.write_(typeNameNode.moduleName.name.value);
279+
this.write_(PERIOD);
280+
}
281+
276282
// TODO(vojta): Figure out why `typeNameNode` has different structure when used with a variable.
277283
// This should probably be fixed in Traceur.
278284
var typeName = typeNameNode.typeToken && typeNameNode.typeToken.value || (typeNameNode.name && typeNameNode.name.value) || null;

0 commit comments

Comments
 (0)