diff --git a/modules/@angular/compiler/src/selector.ts b/modules/@angular/compiler/src/selector.ts
index 50df253add..b1408f8e9d 100644
--- a/modules/@angular/compiler/src/selector.ts
+++ b/modules/@angular/compiler/src/selector.ts
@@ -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) {
diff --git a/modules/@angular/compiler/test/selector_spec.ts b/modules/@angular/compiler/test/selector_spec.ts
index 1f3002af34..b6491e4876 100644
--- a/modules/@angular/compiler/test/selector_spec.ts
+++ b/modules/@angular/compiler/test/selector_spec.ts
@@ -374,5 +374,11 @@ export function main() {
expect(template).toEqual('');
});
+
+ it('should support void tags', () => {
+ const selector = CssSelector.parse('input[fancy]')[0];
+ const template = selector.getMatchingElementTemplate();
+ expect(template).toEqual('');
+ });
});
}