fix(compiler): check more cases for pipe usage inside host bindings (#37883)
Builds on top of #34655 to support more cases that could be using a pipe inside host bindings (e.g. ternary expressions or function calls). Fixes #37610. PR Close #37883
This commit is contained in:
@ -3070,44 +3070,6 @@ runInEachFileSystem(os => {
|
||||
.toContain('Host binding expression cannot contain pipes');
|
||||
});
|
||||
|
||||
it('should throw in case pipes are used in host bindings (defined as `!(value | pipe)`)',
|
||||
() => {
|
||||
env.write(`test.ts`, `
|
||||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'test',
|
||||
template: '...',
|
||||
host: {
|
||||
'[id]': '!(id | myPipe)'
|
||||
}
|
||||
})
|
||||
class FooCmp {}
|
||||
`);
|
||||
const errors = env.driveDiagnostics();
|
||||
expect(trim(errors[0].messageText as string))
|
||||
.toContain('Host binding expression cannot contain pipes');
|
||||
});
|
||||
|
||||
it('should throw in case pipes are used in host bindings (defined as `(value | pipe) === X`)',
|
||||
() => {
|
||||
env.write(`test.ts`, `
|
||||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'test',
|
||||
template: '...',
|
||||
host: {
|
||||
'[id]': '(id | myPipe) === true'
|
||||
}
|
||||
})
|
||||
class FooCmp {}
|
||||
`);
|
||||
const errors = env.driveDiagnostics();
|
||||
expect(trim(errors[0].messageText as string))
|
||||
.toContain('Host binding expression cannot contain pipes');
|
||||
});
|
||||
|
||||
it('should generate host bindings for directives', () => {
|
||||
env.write(`test.ts`, `
|
||||
import {Component, HostBinding, HostListener, TemplateRef} from '@angular/core';
|
||||
|
Reference in New Issue
Block a user