File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -944,6 +944,59 @@ runInEachFileSystem(() => {
944944
945945 expect ( messages ) . toEqual ( [ ] ) ;
946946 } ) ;
947+
948+ it ( 'should not produce a diagnostic when exposing an aliased binding' , ( ) => {
949+ env . write ( 'test.ts' , `
950+ import {Directive, EventEmitter} from '@angular/core';
951+
952+ @Directive({
953+ outputs: ['opened: triggerOpened'],
954+ selector: '[trigger]',
955+ standalone: true,
956+ })
957+ export class Trigger {
958+ opened = new EventEmitter();
959+ }
960+
961+ @Directive({
962+ standalone: true,
963+ selector: '[host]',
964+ hostDirectives: [{directive: Trigger, outputs: ['triggerOpened']}]
965+ })
966+ export class Host {}
967+ ` ) ;
968+
969+ const diags = env . driveDiagnostics ( ) ;
970+ expect ( diags . length ) . toBe ( 0 ) ;
971+ } ) ;
972+
973+ it ( 'should not produce a diagnostic when exposing an inherited aliased binding' , ( ) => {
974+ env . write ( 'test.ts' , `
975+ import {Directive, EventEmitter} from '@angular/core';
976+
977+ @Directive({standalone: true})
978+ export abstract class Base {
979+ opened = new EventEmitter();
980+ }
981+
982+ @Directive({
983+ outputs: ['opened: triggerOpened'],
984+ selector: '[trigger]',
985+ standalone: true,
986+ })
987+ export class Trigger extends Base {}
988+
989+ @Directive({
990+ standalone: true,
991+ selector: '[host]',
992+ hostDirectives: [{directive: Trigger, outputs: ['triggerOpened: hostOpened']}]
993+ })
994+ export class Host {}
995+ ` ) ;
996+
997+ const diags = env . driveDiagnostics ( ) ;
998+ expect ( diags . length ) . toBe ( 0 ) ;
999+ } ) ;
9471000 } ) ;
9481001 } ) ;
9491002} ) ;
Original file line number Diff line number Diff line change @@ -204,7 +204,7 @@ function validateMappings(
204204
205205 const remappedPublicName = hostDirectiveBindings [ publicName ] ;
206206
207- if ( bindings . hasOwnProperty ( remappedPublicName ) &&
207+ if ( bindings . hasOwnProperty ( remappedPublicName ) && remappedPublicName !== publicName &&
208208 bindings [ remappedPublicName ] !== publicName ) {
209209 throw new RuntimeError (
210210 RuntimeErrorCode . HOST_DIRECTIVE_CONFLICTING_ALIAS ,
Original file line number Diff line number Diff line change @@ -3219,5 +3219,65 @@ describe('host directives', () => {
32193219 fixture . detectChanges ( ) ;
32203220 } ) . not . toThrow ( ) ;
32213221 } ) ;
3222+
3223+ it ( 'should not throw when exposing an aliased binding' , ( ) => {
3224+ @Directive ( {
3225+ outputs : [ 'opened: triggerOpened' ] ,
3226+ selector : '[trigger]' ,
3227+ standalone : true ,
3228+ } )
3229+ class Trigger {
3230+ opened = new EventEmitter ( ) ;
3231+ }
3232+
3233+ @Directive ( {
3234+ standalone : true ,
3235+ selector : '[host]' ,
3236+ hostDirectives : [ { directive : Trigger , outputs : [ 'triggerOpened' ] } ]
3237+ } )
3238+ class Host {
3239+ }
3240+
3241+ @Component ( { template : '<div host></div>' , standalone : true , imports : [ Host ] } )
3242+ class App {
3243+ }
3244+
3245+ expect ( ( ) => {
3246+ const fixture = TestBed . createComponent ( App ) ;
3247+ fixture . detectChanges ( ) ;
3248+ } ) . not . toThrow ( ) ;
3249+ } ) ;
3250+
3251+ it ( 'should not throw when exposing an inherited aliased binding' , ( ) => {
3252+ @Directive ( { standalone : true } )
3253+ abstract class Base {
3254+ opened = new EventEmitter ( ) ;
3255+ }
3256+
3257+ @Directive ( {
3258+ outputs : [ 'opened: triggerOpened' ] ,
3259+ selector : '[trigger]' ,
3260+ standalone : true ,
3261+ } )
3262+ class Trigger extends Base {
3263+ }
3264+
3265+ @Directive ( {
3266+ standalone : true ,
3267+ selector : '[host]' ,
3268+ hostDirectives : [ { directive : Trigger , outputs : [ 'triggerOpened: hostOpened' ] } ]
3269+ } )
3270+ class Host {
3271+ }
3272+
3273+ @Component ( { template : '<div host></div>' , standalone : true , imports : [ Host ] } )
3274+ class App {
3275+ }
3276+
3277+ expect ( ( ) => {
3278+ const fixture = TestBed . createComponent ( App ) ;
3279+ fixture . detectChanges ( ) ;
3280+ } ) . not . toThrow ( ) ;
3281+ } ) ;
32223282 } ) ;
32233283} ) ;
You can’t perform that action at this time.
0 commit comments