fix(compiler): allow WS as <ng-content> content (#12225)

This commit is contained in:
Victor Berchet
2016-10-12 07:58:06 -07:00
committed by Tobias Bosch
parent 17e3410d98
commit df1718d624
2 changed files with 17 additions and 9 deletions

View File

@ -428,10 +428,8 @@ class TemplateParseVisitor implements html.Visitor {
let parsedElement: TemplateAst;
if (preparsedElement.type === PreparsedElementType.NG_CONTENT) {
if (isPresent(element.children) && element.children.length > 0) {
this._reportError(
`<ng-content> element cannot have content. <ng-content> must be immediately followed by </ng-content>`,
element.sourceSpan);
if (element.children && !element.children.every(_isEmptyTextNode)) {
this._reportError(`<ng-content> element cannot have content.`, element.sourceSpan);
}
parsedElement = new NgContentAst(
@ -1201,3 +1199,7 @@ export class PipeCollector extends RecursiveAstVisitor {
function _isAnimationLabel(name: string): boolean {
return name[0] == '@';
}
function _isEmptyTextNode(node: html.Node): boolean {
return node instanceof html.Text && node.value.trim().length == 0;
}