From f1f06018c17ec6e09a4b3b1a0249a5164c5aefe6 Mon Sep 17 00:00:00 2001 From: Marc Laval Date: Mon, 9 Mar 2015 11:33:35 +0100 Subject: [PATCH] fix(compiler): workaround for circular dependencies in nodejs Closes #897 --- .../angular2/src/core/compiler/element_injector.js | 8 ++++---- .../compiler/shadow_dom_emulation/content_tag.js | 8 ++++---- .../core/compiler/shadow_dom_emulation/light_dom.js | 10 +++++----- .../src/core/compiler/shadow_dom_strategy.js | 12 ++++++------ 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/modules/angular2/src/core/compiler/element_injector.js b/modules/angular2/src/core/compiler/element_injector.js index 0aca729dd8..4906e880d8 100644 --- a/modules/angular2/src/core/compiler/element_injector.js +++ b/modules/angular2/src/core/compiler/element_injector.js @@ -4,7 +4,7 @@ import {List, ListWrapper, MapWrapper} from 'angular2/src/facade/collection'; import {Injector, Key, Dependency, bind, Binding, NoProviderError, ProviderError, CyclicDependencyError} from 'angular2/di'; import {Parent, Ancestor} from 'angular2/src/core/annotations/visibility'; import {EventEmitter, PropertySetter} from 'angular2/src/core/annotations/di'; -import {View, ProtoView} from 'angular2/src/core/compiler/view'; +import * as viewModule from 'angular2/src/core/compiler/view'; import {LightDom, SourceLightDom, DestinationLightDom} from 'angular2/src/core/compiler/shadow_dom_emulation/light_dom'; import {ViewContainer} from 'angular2/src/core/compiler/view_container'; import {NgElement} from 'angular2/src/core/dom/element'; @@ -30,7 +30,7 @@ class StaticKeys { constructor() { //TODO: vsavkin Key.annotate(Key.get(View), 'static') - this.viewId = Key.get(View).id; + this.viewId = Key.get(viewModule.View).id; this.ngElementId = Key.get(NgElement).id; this.viewContainerId = Key.get(ViewContainer).id; this.destinationLightDomId = Key.get(DestinationLightDom).id; @@ -163,7 +163,7 @@ export class DirectiveBinding extends Binding { // TODO(rado): benchmark and consider rolling in as ElementInjector fields. export class PreBuiltObjects { - view:View; + view:viewModule.View; element:NgElement; viewContainer:ViewContainer; lightDom:LightDom; @@ -222,7 +222,7 @@ export class ProtoElementInjector { _keyId9:int; parent:ProtoElementInjector; index:int; - view:View; + view:viewModule.View; distanceToParent:number; /** Whether the element is exported as $implicit. */ diff --git a/modules/angular2/src/core/compiler/shadow_dom_emulation/content_tag.js b/modules/angular2/src/core/compiler/shadow_dom_emulation/content_tag.js index 62b9f44a05..bc842cb6ef 100644 --- a/modules/angular2/src/core/compiler/shadow_dom_emulation/content_tag.js +++ b/modules/angular2/src/core/compiler/shadow_dom_emulation/content_tag.js @@ -1,5 +1,5 @@ import {Decorator} from '../../annotations/annotations'; -import {SourceLightDom, DestinationLightDom, LightDom} from './light_dom'; +import * as ldModule from './light_dom'; import {Inject} from 'angular2/di'; import {DOM} from 'angular2/src/dom/dom_adapter'; import {isPresent} from 'angular2/src/facade/lang'; @@ -68,9 +68,9 @@ class RenderedContent extends ContentStrategy { * and thus does not get rendered but only affect the distribution of its parent component. */ class IntermediateContent extends ContentStrategy { - destinationLightDom:LightDom; + destinationLightDom:ldModule.LightDom; - constructor(destinationLightDom:LightDom) { + constructor(destinationLightDom:ldModule.LightDom) { super(); this.destinationLightDom = destinationLightDom; this.nodes = []; @@ -90,7 +90,7 @@ export class Content { select:string; _strategy:ContentStrategy; - constructor(@Inject(DestinationLightDom) destinationLightDom, contentEl:NgElement) { + constructor(@Inject(ldModule.DestinationLightDom) destinationLightDom, contentEl:NgElement) { this.select = contentEl.getAttribute('select'); this._strategy = isPresent(destinationLightDom) ? new IntermediateContent(destinationLightDom) : diff --git a/modules/angular2/src/core/compiler/shadow_dom_emulation/light_dom.js b/modules/angular2/src/core/compiler/shadow_dom_emulation/light_dom.js index 6d07233a33..56e00e996d 100644 --- a/modules/angular2/src/core/compiler/shadow_dom_emulation/light_dom.js +++ b/modules/angular2/src/core/compiler/shadow_dom_emulation/light_dom.js @@ -2,7 +2,7 @@ import {DOM} from 'angular2/src/dom/dom_adapter'; import {List, ListWrapper} from 'angular2/src/facade/collection'; import {isBlank, isPresent} from 'angular2/src/facade/lang'; -import {View} from '../view'; +import * as viewModule from '../view'; import {ElementInjector} from '../element_injector'; import {ViewContainer} from '../view_container'; import {Content} from './content_tag'; @@ -25,14 +25,14 @@ class _Root { // once interfaces are supported export class LightDom { // The light DOM of the element is enclosed inside the lightDomView - lightDomView:View; + lightDomView:viewModule.View; // The shadow DOM - shadowDomView:View; + shadowDomView:viewModule.View; // The nodes of the light DOM nodes:List; roots:List<_Root>; - constructor(lightDomView:View, shadowDomView:View, element) { + constructor(lightDomView:viewModule.View, shadowDomView:viewModule.View, element) { this.lightDomView = lightDomView; this.shadowDomView = shadowDomView; this.nodes = DOM.childNodesAsList(element); @@ -51,7 +51,7 @@ export class LightDom { } // Collects the Content directives from the view and all its child views - _collectAllContentTags(view: View, acc:List):List { + _collectAllContentTags(view: viewModule.View, acc:List):List { var eis = view.elementInjectors; for (var i = 0; i < eis.length; ++i) { var ei = eis[i]; diff --git a/modules/angular2/src/core/compiler/shadow_dom_strategy.js b/modules/angular2/src/core/compiler/shadow_dom_strategy.js index d6f9a9a479..ab4c02380a 100644 --- a/modules/angular2/src/core/compiler/shadow_dom_strategy.js +++ b/modules/angular2/src/core/compiler/shadow_dom_strategy.js @@ -4,7 +4,7 @@ import {PromiseWrapper} from 'angular2/src/facade/async'; import {DOM} from 'angular2/src/dom/dom_adapter'; -import {View} from './view'; +import * as viewModule from './view'; import {Content} from './shadow_dom_emulation/content_tag'; import {LightDom} from './shadow_dom_emulation/light_dom'; @@ -20,8 +20,8 @@ import {CompileElement} from './pipeline/compile_element'; import {CompileControl} from './pipeline/compile_control'; export class ShadowDomStrategy { - attachTemplate(el, view:View) {} - constructLightDom(lightDomView:View, shadowDomView:View, el): LightDom { return null; } + attachTemplate(el, view:viewModule.View) {} + constructLightDom(lightDomView:viewModule.View, shadowDomView:viewModule.View, el): LightDom { return null; } polyfillDirectives():List { return []; } /** @@ -78,12 +78,12 @@ export class EmulatedUnscopedShadowDomStrategy extends ShadowDomStrategy { this._styleHost = styleHost; } - attachTemplate(el, view:View){ + attachTemplate(el, view:viewModule.View){ DOM.clearNodes(el); _moveViewNodesIntoParent(el, view); } - constructLightDom(lightDomView:View, shadowDomView:View, el): LightDom { + constructLightDom(lightDomView:viewModule.View, shadowDomView:viewModule.View, el): LightDom { return new LightDom(lightDomView, shadowDomView, el); } @@ -147,7 +147,7 @@ export class NativeShadowDomStrategy extends ShadowDomStrategy { this._styleUrlResolver = styleUrlResolver; } - attachTemplate(el, view:View){ + attachTemplate(el, view:viewModule.View){ _moveViewNodesIntoParent(DOM.createShadowRoot(el), view); }