fix(CssSelector): fix `getMatchingElementTemplate()` for void tags
fixes #11407
This commit is contained in:
parent
a52d076912
commit
077e0be1e7
|
@ -9,6 +9,7 @@
|
|||
|
||||
import {ListWrapper} from './facade/collection';
|
||||
import {StringWrapper, isBlank, isPresent} from './facade/lang';
|
||||
import {getHtmlTagDefinition} from './ml_parser/html_tags';
|
||||
|
||||
const _EMPTY_ATTR_VALUE = '';
|
||||
|
||||
|
@ -101,7 +102,8 @@ export class CssSelector {
|
|||
attrs += ` ${attrName}${attrValue}`;
|
||||
}
|
||||
|
||||
return `<${tagName}${classAttr}${attrs}></${tagName}>`;
|
||||
return getHtmlTagDefinition(tagName).isVoid ? `<${tagName}${classAttr}${attrs}/>` :
|
||||
`<${tagName}${classAttr}${attrs}></${tagName}>`;
|
||||
}
|
||||
|
||||
addAttribute(name: string, value: string = _EMPTY_ATTR_VALUE) {
|
||||
|
|
|
@ -374,5 +374,11 @@ export function main() {
|
|||
|
||||
expect(template).toEqual('<grape></grape>');
|
||||
});
|
||||
|
||||
it('should support void tags', () => {
|
||||
const selector = CssSelector.parse('input[fancy]')[0];
|
||||
const template = selector.getMatchingElementTemplate();
|
||||
expect(template).toEqual('<input fancy/>');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue