Skip to content

Commit 080469f

Browse files
committed
fix(HtmlParser): allow ng-content elements regardless the namespace
relates to #5547 Closes #5745
1 parent 7c13372 commit 080469f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

modules/angular2/src/compiler/template_preparser.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {HtmlElementAst} from './html_ast';
22
import {isBlank, isPresent} from 'angular2/src/facade/lang';
3+
import {splitNsName} from './html_tags';
34

45
const NG_CONTENT_SELECT_ATTR = 'select';
56
const NG_CONTENT_ELEMENT = 'ng-content';
@@ -31,7 +32,7 @@ export function preparseElement(ast: HtmlElementAst): PreparsedElement {
3132
selectAttr = normalizeNgContentSelect(selectAttr);
3233
var nodeName = ast.name.toLowerCase();
3334
var type = PreparsedElementType.OTHER;
34-
if (nodeName == NG_CONTENT_ELEMENT) {
35+
if (splitNsName(nodeName)[1] == NG_CONTENT_ELEMENT) {
3536
type = PreparsedElementType.NG_CONTENT;
3637
} else if (nodeName == STYLE_ELEMENT) {
3738
type = PreparsedElementType.STYLE;

modules/angular2/test/compiler/template_parser_spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,15 @@ export function main() {
106106
expect(humanizeTplAst(parsed)).toEqual([[NgContentAst]]);
107107
});
108108

109+
it('should parse ngContent regardless the namespace', () => {
110+
var parsed = parse('<svg><ng-content></ng-content></svg>', []);
111+
expect(humanizeTplAst(parsed))
112+
.toEqual([
113+
[ElementAst, '@svg:svg'],
114+
[NgContentAst],
115+
]);
116+
});
117+
109118
it('should parse bound text nodes', () => {
110119
expect(humanizeTplAst(parse('{{a}}', []))).toEqual([[BoundTextAst, '{{ a }}']]);
111120
});

0 commit comments

Comments
 (0)