Skip to content

Commit b89c5bc

Browse files
committed
fix(compiler): attribute case in IE9
Closes #4743
1 parent 7dde18b commit b89c5bc

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

modules/angular2/src/core/compiler/html_parser.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ function parseText(text: Text, indexInParent: number, parentSourceInfo: string):
4545
function parseAttr(element: Element, parentSourceInfo: string, attrName: string, attrValue: string):
4646
HtmlAttrAst {
4747
// TODO(tbosch): add source row/column source info from parse5 / package:html
48-
return new HtmlAttrAst(attrName, attrValue, `${parentSourceInfo}[${attrName}=${attrValue}]`);
48+
var lowerCaseAttrName = attrName.toLowerCase();
49+
return new HtmlAttrAst(lowerCaseAttrName, attrValue,
50+
`${parentSourceInfo}[${lowerCaseAttrName}=${attrValue}]`);
4951
}
5052

5153
function parseElement(element: Element, indexInParent: number, parentSourceInfo: string):

modules/angular2/test/core/compiler/html_parser_spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ 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')))
86+
.toEqual([
87+
[HtmlElementAst, 'div', 'TestComp > div:nth-child(0)'],
88+
[HtmlAttrAst, 'foo', 'bar', 'TestComp > div:nth-child(0)[foo=bar]']
89+
]);
90+
});
91+
8492
it('should parse attributes on template elements', () => {
8593
expect(humanizeDom(parser.parse('<template k="v"></template>', 'TestComp')))
8694
.toEqual([

0 commit comments

Comments
 (0)