fix(ivy): allow HTML comments to be present inside <ng-content> (#28849)

Prior to this change presence of HTML comments inside <ng-content> caused compiler to throw an error that <ng-content> is not empty. Now HTML comments are not considered as a meaningful content, thus no error is thrown. This behavior is now aligned in Ivy/VE.

PR Close #28849
This commit is contained in:
Andrew Kushnir
2019-02-19 18:28:00 -08:00
committed by Igor Minar
parent df627e65df
commit 95d9aa22ef
2 changed files with 27 additions and 1 deletions

View File

@ -1834,6 +1834,26 @@ describe('ngtsc behavioral tests', () => {
expect(jsContents).toContain('ɵsetClassMetadata(TestPipe, ');
});
it('should not throw in case whitespaces and HTML comments are present inside <ng-content>',
() => {
env.tsconfig();
env.write('test.ts', `
import {Component} from '@angular/core';
@Component({
selector: 'cmp-a',
template: \`
<ng-content>
<!-- Some comments -->
</ng-content>
\`,
})
class CmpA {}
`);
const errors = env.driveDiagnostics();
expect(errors.length).toBe(0);
});
it('should compile a template using multiple directives with the same selector', () => {
env.tsconfig();
env.write('test.ts', `