Skip to content

Commit

Permalink
fix: align to Angular 4.1.0 template parser API
Browse files Browse the repository at this point in the history
Fix #301
  • Loading branch information
mgechev committed Apr 28, 2017
1 parent 5048cac commit 0fcdcd1
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions src/angular/templates/templateParser.ts
@@ -1,4 +1,4 @@
import { NO_ERRORS_SCHEMA, ViewEncapsulation } from '@angular/core';
import { NO_ERRORS_SCHEMA, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core';
import * as compiler from '@angular/compiler';

import { Config, DirectiveDeclaration } from '../config';
Expand Down Expand Up @@ -111,8 +111,37 @@ export const parseTemplate = (template: string, directives: DirectiveDeclaration
value: '',
identifier: null
};
const result = tmplParser.tryParse(
compiler.CompileDirectiveMetadata.create({ type, template: templateMetadata }),
let result = null;
SemVerDSL.lt('4.1.0', () => {
result = tmplParser.tryParse(
(compiler.CompileDirectiveMetadata as any).create({
type,
template: templateMetadata
}),
template, defaultDirectives, [], [NO_ERRORS_SCHEMA], '').templateAst;
}).else(() => {
result = tmplParser.tryParse(
compiler.CompileDirectiveMetadata.create({
type,
template: templateMetadata,
isHost: true,
isComponent: true,
selector: '',
exportAs: '',
changeDetection: ChangeDetectionStrategy.Default,
inputs: [],
outputs: [],
host: {},
providers: [],
viewProviders: [],
queries: [],
viewQueries: [],
entryComponents: [],
componentViewType: null,
rendererType: null,
componentFactory: null
}),
template, defaultDirectives, [], [NO_ERRORS_SCHEMA], '').templateAst;
});
return result;
};

0 comments on commit 0fcdcd1

Please sign in to comment.