fix(compiler): attribute case in IE9

Closes #4743
This commit is contained in:
Marc Laval 2015-10-14 18:04:38 +02:00
parent 7dde18b181
commit b89c5bc581
2 changed files with 11 additions and 1 deletions

View File

@ -45,7 +45,9 @@ function parseText(text: Text, indexInParent: number, parentSourceInfo: string):
function parseAttr(element: Element, parentSourceInfo: string, attrName: string, attrValue: string): function parseAttr(element: Element, parentSourceInfo: string, attrName: string, attrValue: string):
HtmlAttrAst { HtmlAttrAst {
// TODO(tbosch): add source row/column source info from parse5 / package:html // 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): function parseElement(element: Element, indexInParent: number, parentSourceInfo: string):

View File

@ -81,6 +81,14 @@ export function main() {
]); ]);
}); });
it('should parse and lower case attributes on regular elements', () => {
expect(humanizeDom(parser.parse('<div FoO="bar"></div>', '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', () => { it('should parse attributes on template elements', () => {
expect(humanizeDom(parser.parse('<template k="v"></template>', 'TestComp'))) expect(humanizeDom(parser.parse('<template k="v"></template>', 'TestComp')))
.toEqual([ .toEqual([