@@ -33,17 +33,14 @@ import {AppViewManager} from 'angular2/src/core/compiler/view_manager';
3333import { AppViewManagerUtils } from 'angular2/src/core/compiler/view_manager_utils' ;
3434import { ProtoViewFactory } from 'angular2/src/core/compiler/proto_view_factory' ;
3535import { Renderer , RenderCompiler } from 'angular2/src/render/api' ;
36- import { DirectDomRenderer } from 'angular2/src/render/dom/direct_dom_renderer' ;
37- import * as rc from 'angular2/src/render/dom/compiler/compiler' ;
38- import * as rvf from 'angular2/src/render/dom/view/view_factory' ;
39- import * as rvh from 'angular2/src/render/dom/view/view_hydrator' ;
36+ import { DomRenderer , DOCUMENT_TOKEN } from 'angular2/src/render/dom/dom_renderer' ;
37+ import { resolveInternalDomView } from 'angular2/src/render/dom/view/view' ;
38+ import { DefaultDomCompiler } from 'angular2/src/render/dom/compiler/compiler' ;
4039import { internalView } from 'angular2/src/core/compiler/view_ref' ;
4140
4241import {
4342 appComponentRefToken ,
44- appElementToken ,
45- appComponentAnnotatedTypeToken ,
46- appDocumentToken ,
43+ appComponentAnnotatedTypeToken
4744} from './application_tokens' ;
4845
4946var _rootInjector : Injector ;
@@ -56,28 +53,25 @@ var _rootBindings = [
5653
5754function _injectorBindings ( appComponentType ) : List < Binding > {
5855 return [
59- bind ( appDocumentToken ) . toValue ( DOM . defaultDoc ( ) ) ,
56+ bind ( DOCUMENT_TOKEN ) . toValue ( DOM . defaultDoc ( ) ) ,
6057 bind ( appComponentAnnotatedTypeToken ) . toFactory ( ( reader ) => {
6158 // TODO(rado): investigate whether to support bindings on root component.
6259 return reader . read ( appComponentType ) ;
6360 } , [ DirectiveMetadataReader ] ) ,
6461
65- bind ( appElementToken ) . toFactory ( ( appComponentAnnotatedType , appDocument ) => {
66- var selector = appComponentAnnotatedType . annotation . selector ;
67- var element = DOM . querySelector ( appDocument , selector ) ;
68- if ( isBlank ( element ) ) {
69- throw new BaseException ( `The app selector "${ selector } " did not match any elements` ) ;
70- }
71- return element ;
72- } , [ appComponentAnnotatedTypeToken , appDocumentToken ] ) ,
73- bind ( appComponentRefToken ) . toAsyncFactory ( ( dynamicComponentLoader , injector , appElement ,
62+ bind ( appComponentRefToken ) . toAsyncFactory ( ( dynamicComponentLoader , injector ,
7463 appComponentAnnotatedType , testability , registry ) => {
7564
76- // We need to do this here to ensure that we create Testability and
77- // it's ready on the window for users.
78- registry . registerApplication ( appElement , testability ) ;
79- return dynamicComponentLoader . loadIntoNewLocation ( appComponentAnnotatedType . type , null , appElement , injector ) ;
80- } , [ DynamicComponentLoader , Injector , appElementToken , appComponentAnnotatedTypeToken ,
65+ var selector = appComponentAnnotatedType . annotation . selector ;
66+ return dynamicComponentLoader . loadIntoNewLocation ( appComponentAnnotatedType . type , null , selector , injector ) . then ( ( componentRef ) => {
67+ var domView = resolveInternalDomView ( componentRef . hostView . render ) ;
68+ // We need to do this here to ensure that we create Testability and
69+ // it's ready on the window for users.
70+ registry . registerApplication ( domView . boundElements [ 0 ] , testability ) ;
71+
72+ return componentRef ;
73+ } ) ;
74+ } , [ DynamicComponentLoader , Injector , appComponentAnnotatedTypeToken ,
8175 Testability , TestabilityRegistry ] ) ,
8276
8377 bind ( appComponentType ) . toFactory ( ( ref ) => ref . instance ,
@@ -89,18 +83,16 @@ function _injectorBindings(appComponentType): List<Binding> {
8983 } , [ VmTurnZone ] ) ,
9084 bind ( ShadowDomStrategy ) . toFactory (
9185 ( styleUrlResolver , doc ) => new EmulatedUnscopedShadowDomStrategy ( styleUrlResolver , doc . head ) ,
92- [ StyleUrlResolver , appDocumentToken ] ) ,
93- DirectDomRenderer ,
94- bind ( Renderer ) . toClass ( DirectDomRenderer ) ,
95- bind ( RenderCompiler ) . toClass ( rc . DefaultDomCompiler ) ,
86+ [ StyleUrlResolver , DOCUMENT_TOKEN ] ) ,
9687 // TODO(tbosch): We need an explicit factory here, as
9788 // we are getting errors in dart2js with mirrors...
98- bind ( rvf . ViewFactory ) . toFactory (
99- ( capacity , eventManager , shadowDomStrategy ) => new rvf . ViewFactory ( capacity , eventManager , shadowDomStrategy ) ,
100- [ rvf . VIEW_POOL_CAPACITY , EventManager , ShadowDomStrategy ]
89+ bind ( DomRenderer ) . toFactory (
90+ ( eventManager , shadowDomStrategy , doc ) => new DomRenderer ( eventManager , shadowDomStrategy , doc ) ,
91+ [ EventManager , ShadowDomStrategy , DOCUMENT_TOKEN ]
10192 ) ,
102- bind ( rvf . VIEW_POOL_CAPACITY ) . toValue ( 10000 ) ,
103- rvh . RenderViewHydrator ,
93+ DefaultDomCompiler ,
94+ bind ( Renderer ) . toAlias ( DomRenderer ) ,
95+ bind ( RenderCompiler ) . toAlias ( DefaultDomCompiler ) ,
10496 ProtoViewFactory ,
10597 // TODO(tbosch): We need an explicit factory here, as
10698 // we are getting errors in dart2js with mirrors...
0 commit comments