refactor: change template for view where it makes sense
This commit is contained in:
@ -139,9 +139,9 @@ export class Compiler {
|
||||
// It happens when a template references a component multiple times.
|
||||
return pvPromise;
|
||||
}
|
||||
var template = this._viewResolver.resolve(component);
|
||||
var view = this._viewResolver.resolve(component);
|
||||
|
||||
var directives = this._flattenDirectives(template);
|
||||
var directives = this._flattenDirectives(view);
|
||||
|
||||
for (var i = 0; i < directives.length; i++) {
|
||||
if (!Compiler._isValidDirective(directives[i])) {
|
||||
@ -153,7 +153,7 @@ export class Compiler {
|
||||
var boundDirectives =
|
||||
ListWrapper.map(directives, (directive) => this._bindDirective(directive));
|
||||
|
||||
var renderTemplate = this._buildRenderTemplate(component, template, boundDirectives);
|
||||
var renderTemplate = this._buildRenderTemplate(component, view, boundDirectives);
|
||||
pvPromise =
|
||||
this._render.compile(renderTemplate)
|
||||
.then((renderPv) => {
|
||||
|
@ -10,9 +10,7 @@ export class MockViewResolver extends ViewResolver {
|
||||
_viewCache: Map<Type, View> = new Map();
|
||||
_directiveOverrides: Map<Type, Map<Type, Type>> = new Map();
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
constructor() { super(); }
|
||||
|
||||
/**
|
||||
* Overrides the {@link View} for a component.
|
||||
|
@ -10,19 +10,19 @@ import {ShadowDomCompileStep} from '../shadow_dom/shadow_dom_compile_step';
|
||||
import {ShadowDomStrategy} from '../shadow_dom/shadow_dom_strategy';
|
||||
|
||||
export class CompileStepFactory {
|
||||
createSteps(template: ViewDefinition): List<CompileStep> { return null; }
|
||||
createSteps(view: ViewDefinition): List<CompileStep> { return null; }
|
||||
}
|
||||
|
||||
export class DefaultStepFactory extends CompileStepFactory {
|
||||
constructor(public _parser: Parser, public _shadowDomStrategy: ShadowDomStrategy) { super(); }
|
||||
|
||||
createSteps(template: ViewDefinition): List<CompileStep> {
|
||||
createSteps(view: ViewDefinition): List<CompileStep> {
|
||||
return [
|
||||
new ViewSplitter(this._parser),
|
||||
new PropertyBindingParser(this._parser),
|
||||
new DirectiveParser(this._parser, template.directives),
|
||||
new DirectiveParser(this._parser, view.directives),
|
||||
new TextInterpolationParser(this._parser),
|
||||
new ShadowDomCompileStep(this._shadowDomStrategy, template)
|
||||
new ShadowDomCompileStep(this._shadowDomStrategy, view)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import {StyleInliner} from './style_inliner';
|
||||
import {StyleUrlResolver} from './style_url_resolver';
|
||||
|
||||
/**
|
||||
* Strategy to load component templates.
|
||||
* Strategy to load component views.
|
||||
* TODO: Make public API once we are more confident in this approach.
|
||||
*/
|
||||
@Injectable()
|
||||
|
@ -37,10 +37,10 @@ export class TestBed {
|
||||
* @see setInlineTemplate() to only override the html
|
||||
*
|
||||
* @param {Type} component
|
||||
* @param {ViewDefinition} template
|
||||
* @param {ViewDefinition} view
|
||||
*/
|
||||
overrideView(component: Type, template: View): void {
|
||||
this._injector.get(ViewResolver).setView(component, template);
|
||||
overrideView(component: Type, view: View): void {
|
||||
this._injector.get(ViewResolver).setView(component, view);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,7 +74,7 @@ export class TestComponentBuilder {
|
||||
|
||||
/**
|
||||
* Overrides only the html of a {@link Component}.
|
||||
* All the other propoerties of the component's {@link View} are preserved.
|
||||
* All the other properties of the component's {@link View} are preserved.
|
||||
*
|
||||
* @param {Type} component
|
||||
* @param {string} html
|
||||
@ -130,9 +130,8 @@ export class TestComponentBuilder {
|
||||
var mockViewResolver = this._injector.get(ViewResolver);
|
||||
MapWrapper.forEach(this._viewOverrides,
|
||||
(view, type) => { mockViewResolver.setView(type, view); });
|
||||
MapWrapper.forEach(this._templateOverrides, (template, type) => {
|
||||
mockViewResolver.setInlineTemplate(type, template);
|
||||
});
|
||||
MapWrapper.forEach(this._templateOverrides,
|
||||
(template, type) => { mockViewResolver.setInlineTemplate(type, template); });
|
||||
MapWrapper.forEach(this._directiveOverrides, (overrides, component) => {
|
||||
MapWrapper.forEach(overrides, (to, from) => {
|
||||
mockViewResolver.overrideViewDirective(component, from, to);
|
||||
|
Reference in New Issue
Block a user