Skip to content

Commit 6133f2c

Browse files
committed
fix(compiler): don’t lowercase attributes to support svg
This reverts commit b89c5bc and adds an additional test. Closes #5166
1 parent 63e853d commit 6133f2c

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

modules/angular2/src/compiler/html_parser.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ function parseText(text: Text, indexInParent: number, parentSourceInfo: string):
4343
function parseAttr(element: Element, parentSourceInfo: string, attrName: string,
4444
attrValue: string): HtmlAttrAst {
4545
// TODO(tbosch): add source row/column source info from parse5 / package:html
46-
var lowerCaseAttrName = attrName.toLowerCase();
47-
return new HtmlAttrAst(lowerCaseAttrName, attrValue,
48-
`${parentSourceInfo}[${lowerCaseAttrName}=${attrValue}]`);
46+
return new HtmlAttrAst(attrName, attrValue, `${parentSourceInfo}[${attrName}=${attrValue}]`);
4947
}
5048

5149
function parseElement(element: Element, indexInParent: number,

modules/angular2/test/compiler/html_parser_spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ export function main() {
8181
]);
8282
});
8383

84-
it('should parse and lower case attributes on regular elements', () => {
85-
expect(humanizeDom(parser.parse('<div FoO="bar"></div>', 'TestComp')))
84+
it('should parse attributes on svg elements case sensitive', () => {
85+
expect(humanizeDom(parser.parse('<svg viewBox="0"></svg>', 'TestComp')))
8686
.toEqual([
87-
[HtmlElementAst, 'div', 'TestComp > div:nth-child(0)'],
88-
[HtmlAttrAst, 'foo', 'bar', 'TestComp > div:nth-child(0)[foo=bar]']
87+
[HtmlElementAst, 'svg', 'TestComp > svg:nth-child(0)'],
88+
[HtmlAttrAst, 'viewBox', '0', 'TestComp > svg:nth-child(0)[viewBox=0]']
8989
]);
9090
});
9191

0 commit comments

Comments
 (0)