From 080469f8e6692c7865fbd574aadd9be06ba35c55 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Wed, 9 Dec 2015 10:47:10 -0800 Subject: [PATCH] fix(HtmlParser): allow ng-content elements regardless the namespace relates to #5547 Closes #5745 --- modules/angular2/src/compiler/template_preparser.ts | 3 ++- modules/angular2/test/compiler/template_parser_spec.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/angular2/src/compiler/template_preparser.ts b/modules/angular2/src/compiler/template_preparser.ts index 3d1b31a7ff..6c2948d013 100644 --- a/modules/angular2/src/compiler/template_preparser.ts +++ b/modules/angular2/src/compiler/template_preparser.ts @@ -1,5 +1,6 @@ import {HtmlElementAst} from './html_ast'; import {isBlank, isPresent} from 'angular2/src/facade/lang'; +import {splitNsName} from './html_tags'; const NG_CONTENT_SELECT_ATTR = 'select'; const NG_CONTENT_ELEMENT = 'ng-content'; @@ -31,7 +32,7 @@ export function preparseElement(ast: HtmlElementAst): PreparsedElement { selectAttr = normalizeNgContentSelect(selectAttr); var nodeName = ast.name.toLowerCase(); var type = PreparsedElementType.OTHER; - if (nodeName == NG_CONTENT_ELEMENT) { + if (splitNsName(nodeName)[1] == NG_CONTENT_ELEMENT) { type = PreparsedElementType.NG_CONTENT; } else if (nodeName == STYLE_ELEMENT) { type = PreparsedElementType.STYLE; diff --git a/modules/angular2/test/compiler/template_parser_spec.ts b/modules/angular2/test/compiler/template_parser_spec.ts index 21916aacc1..1fe21daf89 100644 --- a/modules/angular2/test/compiler/template_parser_spec.ts +++ b/modules/angular2/test/compiler/template_parser_spec.ts @@ -106,6 +106,15 @@ export function main() { expect(humanizeTplAst(parsed)).toEqual([[NgContentAst]]); }); + it('should parse ngContent regardless the namespace', () => { + var parsed = parse('', []); + expect(humanizeTplAst(parsed)) + .toEqual([ + [ElementAst, '@svg:svg'], + [NgContentAst], + ]); + }); + it('should parse bound text nodes', () => { expect(humanizeTplAst(parse('{{a}}', []))).toEqual([[BoundTextAst, '{{ a }}']]); });