@@ -986,71 +986,6 @@ export function main() {
986986 } ) ) ;
987987 }
988988 } ) ;
989-
990- describe ( 'dependency injection' , ( ) => {
991-
992- it ( 'should publish parent component to shadow DOM via publishAs' ,
993- inject ( [ TestBed , AsyncTestCompleter , Compiler ] , ( tb , async , compiler ) => {
994- tb . overrideView ( MyComp , new View ( {
995- template : `<parent></parent>` ,
996- directives : [ ParentComponent ]
997- } ) ) ;
998-
999- tb . createView ( MyComp ) . then ( ( view ) => {
1000- view . detectChanges ( ) ;
1001- expect ( view . rootNodes ) . toHaveText (
1002- 'Parent,Parent' ) ;
1003- async . done ( ) ;
1004- } ) ;
1005- } ) ) ;
1006-
1007- it ( 'should override parent bindings via publishAs' ,
1008- inject ( [ TestBed , AsyncTestCompleter , Compiler ] , ( tb , async , compiler ) => {
1009- tb . overrideView ( MyComp , new View ( {
1010- template : `<recursive-parent></recursive-parent>` ,
1011- directives : [ RecursiveParentComponent ]
1012- } ) ) ;
1013-
1014- tb . createView ( MyComp ) . then ( ( view ) => {
1015- view . detectChanges ( ) ;
1016- expect ( view . rootNodes ) . toHaveText (
1017- 'ParentInterface,RecursiveParent,RecursiveParent' ) ;
1018- async . done ( ) ;
1019- } ) ;
1020- } ) ) ;
1021-
1022- // [DynamicComponentLoader] already supports providing a custom
1023- // injector as an argument to `loadIntoExistingLocation`, which should
1024- // be used instead of `publishAs`.
1025- //
1026- // Conceptually dynamically loaded components are loaded _instead_ of
1027- // the dynamic component itself. The dynamic component does not own the
1028- // shadow DOM. It's the loaded component that creates that shadow DOM.
1029- it ( 'should not publish into dynamically instantiated components via publishAs' ,
1030- inject ( [ TestBed , AsyncTestCompleter , Compiler ] , ( tb , async , compiler ) => {
1031- tb . overrideView ( MyComp , new View ( {
1032- template : `<dynamic-parent #cmp></dynamic-parent>` ,
1033- directives : [ DynamicParentComponent ]
1034- } ) ) ;
1035-
1036- tb . createView ( MyComp ) . then ( ( view ) => {
1037- view . detectChanges ( ) ;
1038- var comp = view . rawView . locals . get ( "cmp" ) ;
1039- PromiseWrapper . then ( comp . done ,
1040- ( value ) => {
1041- throw new BaseException ( `Expected to throw error, but got value ${ value } ` ) ;
1042- } ,
1043- ( err ) => {
1044- expect ( err . message )
1045- . toEqual ( 'No provider for ParentInterface! (ChildComponent -> ParentInterface)' ) ;
1046- async . done ( ) ;
1047- }
1048- ) ;
1049- } ) ;
1050- } ) ) ;
1051-
1052- } ) ;
1053-
1054989 } ) ;
1055990}
1056991
@@ -1479,70 +1414,6 @@ class NeedsPublicApi {
14791414 }
14801415}
14811416
1482- class ParentInterface {
1483- message :String ;
1484- constructor ( ) {
1485- this . message = 'ParentInterface' ;
1486- }
1487- }
1488-
1489- @Component ( {
1490- selector : 'parent' ,
1491- publishAs : [ ParentInterface ]
1492- } )
1493- @View ( {
1494- template : `<child></child>` ,
1495- directives : [ ChildComponent ]
1496- } )
1497- class ParentComponent extends ParentInterface {
1498- message :String ;
1499- constructor ( ) {
1500- super ( ) ;
1501- this . message = 'Parent' ;
1502- }
1503- }
1504-
1505- @Component ( {
1506- injectables : [ ParentInterface ] ,
1507- selector : 'recursive-parent' ,
1508- publishAs : [ ParentInterface ]
1509- } )
1510- @View ( {
1511- template : `{{parentService.message}},<child></child>` ,
1512- directives : [ ChildComponent ]
1513- } )
1514- class RecursiveParentComponent extends ParentInterface {
1515- parentService :ParentInterface ;
1516- message :String ;
1517- constructor ( parentService :ParentInterface ) {
1518- super ( ) ;
1519- this . message = 'RecursiveParent' ;
1520- this . parentService = parentService ;
1521- }
1522- }
1523-
1524- @Component ( {
1525- selector : 'dynamic-parent' ,
1526- publishAs : [ ParentInterface ]
1527- } )
1528- class DynamicParentComponent extends ParentInterface {
1529- message :String ;
1530- done ;
1531- constructor ( loader :DynamicComponentLoader , location :ElementRef ) {
1532- super ( ) ;
1533- this . message = 'DynamicParent' ;
1534- this . done = loader . loadIntoExistingLocation ( ChildComponent , location ) ;
1535- }
1536- }
1537-
1538- class AppDependency {
1539- parent :ParentInterface ;
1540-
1541- constructor ( p :ParentInterface ) {
1542- this . parent = p ;
1543- }
1544- }
1545-
15461417@Component ( {
15471418 selector : 'child' ,
15481419 injectables : [ AppDependency ]
0 commit comments