From b89c5bc5818c62e775b0b0211931a81a32fd0293 Mon Sep 17 00:00:00 2001 From: Marc Laval Date: Wed, 14 Oct 2015 18:04:38 +0200 Subject: [PATCH] fix(compiler): attribute case in IE9 Closes #4743 --- modules/angular2/src/core/compiler/html_parser.ts | 4 +++- modules/angular2/test/core/compiler/html_parser_spec.ts | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/angular2/src/core/compiler/html_parser.ts b/modules/angular2/src/core/compiler/html_parser.ts index be3e14fe41..33bc2d9d62 100644 --- a/modules/angular2/src/core/compiler/html_parser.ts +++ b/modules/angular2/src/core/compiler/html_parser.ts @@ -45,7 +45,9 @@ function parseText(text: Text, indexInParent: number, parentSourceInfo: string): function parseAttr(element: Element, parentSourceInfo: string, attrName: string, attrValue: string): HtmlAttrAst { // TODO(tbosch): add source row/column source info from parse5 / package:html - return new HtmlAttrAst(attrName, attrValue, `${parentSourceInfo}[${attrName}=${attrValue}]`); + var lowerCaseAttrName = attrName.toLowerCase(); + return new HtmlAttrAst(lowerCaseAttrName, attrValue, + `${parentSourceInfo}[${lowerCaseAttrName}=${attrValue}]`); } function parseElement(element: Element, indexInParent: number, parentSourceInfo: string): diff --git a/modules/angular2/test/core/compiler/html_parser_spec.ts b/modules/angular2/test/core/compiler/html_parser_spec.ts index d5b0f55c0b..e539010ed1 100644 --- a/modules/angular2/test/core/compiler/html_parser_spec.ts +++ b/modules/angular2/test/core/compiler/html_parser_spec.ts @@ -81,6 +81,14 @@ export function main() { ]); }); + it('should parse and lower case attributes on regular elements', () => { + expect(humanizeDom(parser.parse('
', 'TestComp'))) + .toEqual([ + [HtmlElementAst, 'div', 'TestComp > div:nth-child(0)'], + [HtmlAttrAst, 'foo', 'bar', 'TestComp > div:nth-child(0)[foo=bar]'] + ]); + }); + it('should parse attributes on template elements', () => { expect(humanizeDom(parser.parse('', 'TestComp'))) .toEqual([