@@ -22,12 +22,14 @@ import {
2222 BoundEvent ,
2323 BoundText ,
2424 Comment ,
25+ Component ,
2526 Content ,
2627 DeferredBlock ,
2728 DeferredBlockError ,
2829 DeferredBlockLoading ,
2930 DeferredBlockPlaceholder ,
3031 DeferredTrigger ,
32+ Directive ,
3133 Element ,
3234 ForLoopBlock ,
3335 ForLoopBlockEmpty ,
@@ -338,6 +340,8 @@ class Scope implements Visitor {
338340 }
339341
340342 visitElement ( element : Element ) {
343+ element . directives . forEach ( ( node ) => node . visit ( this ) ) ;
344+
341345 // `Element`s in the template may have `Reference`s which are captured in the scope.
342346 element . references . forEach ( ( node ) => this . visitReference ( node ) ) ;
343347
@@ -348,6 +352,8 @@ class Scope implements Visitor {
348352 }
349353
350354 visitTemplate ( template : Template ) {
355+ template . directives . forEach ( ( node ) => node . visit ( this ) ) ;
356+
351357 // References on a <ng-template> are defined in the outer scope, so capture them before
352358 // processing the template's child scope.
353359 template . references . forEach ( ( node ) => this . visitReference ( node ) ) ;
@@ -418,6 +424,14 @@ class Scope implements Visitor {
418424 this . maybeDeclare ( decl ) ;
419425 }
420426
427+ visitComponent ( component : Component ) {
428+ throw new Error ( 'TODO' ) ;
429+ }
430+
431+ visitDirective ( directive : Directive ) {
432+ throw new Error ( 'TODO' ) ;
433+ }
434+
421435 // Unused visitors.
422436 visitBoundAttribute ( attr : BoundAttribute ) { }
423437 visitBoundEvent ( event : BoundEvent ) { }
@@ -537,6 +551,11 @@ class DirectiveBinder<DirectiveT extends DirectiveMeta> implements Visitor {
537551 // Do this by building up a `CssSelector` for the node.
538552 const cssSelector = createCssSelectorFromNode ( node ) ;
539553
554+ // TODO(crisbeto): account for selectorless directives here.
555+ if ( node . directives . length > 0 ) {
556+ throw new Error ( 'TODO' ) ;
557+ }
558+
540559 // Next, use the `SelectorMatcher` to get the list of directives on the node.
541560 const directives : DirectiveT [ ] = [ ] ;
542561 this . matcher . match ( cssSelector , ( _selector , results ) => directives . push ( ...results ) ) ;
@@ -660,6 +679,14 @@ class DirectiveBinder<DirectiveT extends DirectiveMeta> implements Visitor {
660679 content . children . forEach ( ( child ) => child . visit ( this ) ) ;
661680 }
662681
682+ visitComponent ( component : Component ) {
683+ throw new Error ( 'TODO' ) ;
684+ }
685+
686+ visitDirective ( directive : Directive ) {
687+ throw new Error ( 'TODO' ) ;
688+ }
689+
663690 // Unused visitors.
664691 visitVariable ( variable : Variable ) : void { }
665692 visitReference ( reference : Reference ) : void { }
@@ -806,6 +833,7 @@ class TemplateBinder extends RecursiveAstVisitor implements Visitor {
806833 // Visit the inputs, outputs, and children of the element.
807834 element . inputs . forEach ( this . visitNode ) ;
808835 element . outputs . forEach ( this . visitNode ) ;
836+ element . directives . forEach ( this . visitNode ) ;
809837 element . children . forEach ( this . visitNode ) ;
810838 element . references . forEach ( this . visitNode ) ;
811839 }
@@ -814,6 +842,7 @@ class TemplateBinder extends RecursiveAstVisitor implements Visitor {
814842 // First, visit inputs, outputs and template attributes of the template node.
815843 template . inputs . forEach ( this . visitNode ) ;
816844 template . outputs . forEach ( this . visitNode ) ;
845+ template . directives . forEach ( this . visitNode ) ;
817846 template . templateAttrs . forEach ( this . visitNode ) ;
818847 template . references . forEach ( this . visitNode ) ;
819848
@@ -835,6 +864,14 @@ class TemplateBinder extends RecursiveAstVisitor implements Visitor {
835864 }
836865 }
837866
867+ visitComponent ( component : Component ) {
868+ throw new Error ( 'TODO' ) ;
869+ }
870+
871+ visitDirective ( directive : Directive ) {
872+ throw new Error ( 'TODO' ) ;
873+ }
874+
838875 // Unused template visitors
839876 visitText ( text : Text ) { }
840877 visitTextAttribute ( attribute : TextAttribute ) { }
0 commit comments