diff --git a/modules/angular2/src/compiler/api.ts b/modules/angular2/src/compiler/api.ts index 5925e9173d..972fdb046b 100644 --- a/modules/angular2/src/compiler/api.ts +++ b/modules/angular2/src/compiler/api.ts @@ -1,3 +1,4 @@ +import {isPresent} from 'angular2/src/core/facade/lang'; import {HtmlAst} from './html_ast'; export class TypeMeta { @@ -54,18 +55,18 @@ export enum ViewEncapsulation { export class DirectiveMetadata { type: TypeMeta; + isComponent: boolean; selector: string; - constructor({type, selector}: {type?: TypeMeta, selector?: string} = {}) { - this.type = type; - this.selector = selector; - } -} - -export class ComponentMetadata extends DirectiveMetadata { template: TemplateMeta; - constructor({type, selector, template}: - {type?: TypeMeta, selector?: string, template?: TemplateMeta}) { - super({type: type, selector: selector}); + constructor({type, isComponent, selector, template}: { + type?: TypeMeta, + isComponent?: boolean, + selector?: string, + template?: TemplateMeta + } = {}) { + this.type = type; + this.isComponent = isPresent(isComponent) ? isComponent : false; + this.selector = selector; this.template = template; } } diff --git a/modules/angular2/src/compiler/template_parser.ts b/modules/angular2/src/compiler/template_parser.ts index d8e180fe05..dfc4998cd1 100644 --- a/modules/angular2/src/compiler/template_parser.ts +++ b/modules/angular2/src/compiler/template_parser.ts @@ -12,7 +12,7 @@ import { import {Parser, AST, ASTWithSource} from 'angular2/src/core/change_detection/change_detection'; -import {DirectiveMetadata, ComponentMetadata} from './api'; +import {DirectiveMetadata} from './api'; import { ElementAst, BoundPropertyAst, @@ -279,8 +279,8 @@ class TemplateParseVisitor implements HtmlAstVisitor { // as selectorMatcher uses Maps inside. // Also need to make components the first directive in the array ListWrapper.sort(directives, (dir1: DirectiveMetadata, dir2: DirectiveMetadata) => { - var dir1Comp = dir1 instanceof ComponentMetadata; - var dir2Comp = dir2 instanceof ComponentMetadata; + var dir1Comp = dir1.isComponent; + var dir2Comp = dir2.isComponent; if (dir1Comp && !dir2Comp) { return -1; } else if (!dir1Comp && dir2Comp) { diff --git a/modules/angular2/test/compiler/template_parser_spec.ts b/modules/angular2/test/compiler/template_parser_spec.ts index cdb3931bec..fb5717ff2b 100644 --- a/modules/angular2/test/compiler/template_parser_spec.ts +++ b/modules/angular2/test/compiler/template_parser_spec.ts @@ -3,7 +3,7 @@ import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach} from ' import {Parser, Lexer} from 'angular2/src/core/change_detection/change_detection'; import {TemplateParser, splitClasses} from 'angular2/src/compiler/template_parser'; import {HtmlParser} from 'angular2/src/compiler/html_parser'; -import {DirectiveMetadata, ComponentMetadata, TypeMeta} from 'angular2/src/compiler/api'; +import {DirectiveMetadata, TypeMeta} from 'angular2/src/compiler/api'; import { templateVisitAll, TemplateAstVisitor, @@ -192,8 +192,8 @@ export function main() { new DirectiveMetadata({selector: '[a=b]', type: new TypeMeta({typeName: 'DirA'})}); var dirB = new DirectiveMetadata({selector: '[a]', type: new TypeMeta({typeName: 'DirB'})}); - var comp = - new ComponentMetadata({selector: 'div', type: new TypeMeta({typeName: 'ZComp'})}); + var comp = new DirectiveMetadata( + {selector: 'div', isComponent: true, type: new TypeMeta({typeName: 'ZComp'})}); expect(humanizeTemplateAsts(parse('