@@ -33,17 +33,14 @@ import {AppViewManager} from 'angular2/src/core/compiler/view_manager';
33
33
import { AppViewManagerUtils } from 'angular2/src/core/compiler/view_manager_utils' ;
34
34
import { ProtoViewFactory } from 'angular2/src/core/compiler/proto_view_factory' ;
35
35
import { 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' ;
40
39
import { internalView } from 'angular2/src/core/compiler/view_ref' ;
41
40
42
41
import {
43
42
appComponentRefToken ,
44
- appElementToken ,
45
- appComponentAnnotatedTypeToken ,
46
- appDocumentToken ,
43
+ appComponentAnnotatedTypeToken
47
44
} from './application_tokens' ;
48
45
49
46
var _rootInjector : Injector ;
@@ -56,28 +53,25 @@ var _rootBindings = [
56
53
57
54
function _injectorBindings ( appComponentType ) : List < Binding > {
58
55
return [
59
- bind ( appDocumentToken ) . toValue ( DOM . defaultDoc ( ) ) ,
56
+ bind ( DOCUMENT_TOKEN ) . toValue ( DOM . defaultDoc ( ) ) ,
60
57
bind ( appComponentAnnotatedTypeToken ) . toFactory ( ( reader ) => {
61
58
// TODO(rado): investigate whether to support bindings on root component.
62
59
return reader . read ( appComponentType ) ;
63
60
} , [ DirectiveMetadataReader ] ) ,
64
61
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 ,
74
63
appComponentAnnotatedType , testability , registry ) => {
75
64
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 ,
81
75
Testability , TestabilityRegistry ] ) ,
82
76
83
77
bind ( appComponentType ) . toFactory ( ( ref ) => ref . instance ,
@@ -89,18 +83,16 @@ function _injectorBindings(appComponentType): List<Binding> {
89
83
} , [ VmTurnZone ] ) ,
90
84
bind ( ShadowDomStrategy ) . toFactory (
91
85
( 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 ] ) ,
96
87
// TODO(tbosch): We need an explicit factory here, as
97
88
// 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 ]
101
92
) ,
102
- bind ( rvf . VIEW_POOL_CAPACITY ) . toValue ( 10000 ) ,
103
- rvh . RenderViewHydrator ,
93
+ DefaultDomCompiler ,
94
+ bind ( Renderer ) . toAlias ( DomRenderer ) ,
95
+ bind ( RenderCompiler ) . toAlias ( DefaultDomCompiler ) ,
104
96
ProtoViewFactory ,
105
97
// TODO(tbosch): We need an explicit factory here, as
106
98
// we are getting errors in dart2js with mirrors...
0 commit comments