fix(compiler): no longer uses assetCacheKey for token identity.
Fixes #10545, Fixes #10538
This commit is contained in:

committed by
Victor Berchet

parent
c377e80670
commit
51877ef4ed
@ -10,7 +10,7 @@
|
||||
import {CompileDiDependencyMetadata, CompileDirectiveMetadata, CompileIdentifierMap, CompileIdentifierMetadata, CompileProviderMetadata, CompileQueryMetadata, CompileTokenMetadata} from '../compile_metadata';
|
||||
import {ListWrapper, StringMapWrapper} from '../facade/collection';
|
||||
import {isBlank, isPresent} from '../facade/lang';
|
||||
import {Identifiers, identifierToken} from '../identifiers';
|
||||
import {Identifiers, identifierToken, resolveIdentifier, resolveIdentifierToken} from '../identifiers';
|
||||
import * as o from '../output/output_ast';
|
||||
import {convertValueToOutputAst} from '../output/value_util';
|
||||
import {ProviderAst, ProviderAstType, ReferenceAst, TemplateAst} from '../template_parser/template_ast';
|
||||
@ -62,11 +62,12 @@ export class CompileElement extends CompileNode {
|
||||
this.referenceTokens = {};
|
||||
references.forEach(ref => this.referenceTokens[ref.name] = ref.value);
|
||||
|
||||
this.elementRef = o.importExpr(Identifiers.ElementRef).instantiate([this.renderNode]);
|
||||
this.instances.add(identifierToken(Identifiers.ElementRef), this.elementRef);
|
||||
this.elementRef =
|
||||
o.importExpr(resolveIdentifier(Identifiers.ElementRef)).instantiate([this.renderNode]);
|
||||
this.instances.add(resolveIdentifierToken(Identifiers.ElementRef), this.elementRef);
|
||||
this.injector = o.THIS_EXPR.callMethod('injector', [o.literal(this.nodeIndex)]);
|
||||
this.instances.add(identifierToken(Identifiers.Injector), this.injector);
|
||||
this.instances.add(identifierToken(Identifiers.Renderer), o.THIS_EXPR.prop('renderer'));
|
||||
this.instances.add(resolveIdentifierToken(Identifiers.Injector), this.injector);
|
||||
this.instances.add(resolveIdentifierToken(Identifiers.Renderer), o.THIS_EXPR.prop('renderer'));
|
||||
if (this.hasViewContainer || this.hasEmbeddedView || isPresent(this.component)) {
|
||||
this._createAppElement();
|
||||
}
|
||||
@ -77,16 +78,17 @@ export class CompileElement extends CompileNode {
|
||||
var parentNodeIndex = this.isRootElement() ? null : this.parent.nodeIndex;
|
||||
// private is fine here as no child view will reference an AppElement
|
||||
this.view.fields.push(new o.ClassField(
|
||||
fieldName, o.importType(Identifiers.AppElement), [o.StmtModifier.Private]));
|
||||
fieldName, o.importType(resolveIdentifier(Identifiers.AppElement)),
|
||||
[o.StmtModifier.Private]));
|
||||
var statement =
|
||||
o.THIS_EXPR.prop(fieldName)
|
||||
.set(o.importExpr(Identifiers.AppElement).instantiate([
|
||||
.set(o.importExpr(resolveIdentifier(Identifiers.AppElement)).instantiate([
|
||||
o.literal(this.nodeIndex), o.literal(parentNodeIndex), o.THIS_EXPR, this.renderNode
|
||||
]))
|
||||
.toStmt();
|
||||
this.view.createMethod.addStmt(statement);
|
||||
this.appElement = o.THIS_EXPR.prop(fieldName);
|
||||
this.instances.add(identifierToken(Identifiers.AppElement), this.appElement);
|
||||
this.instances.add(resolveIdentifierToken(Identifiers.AppElement), this.appElement);
|
||||
}
|
||||
|
||||
public createComponentFactoryResolver(entryComponents: CompileIdentifierMetadata[]) {
|
||||
@ -94,12 +96,13 @@ export class CompileElement extends CompileNode {
|
||||
return;
|
||||
}
|
||||
var createComponentFactoryResolverExpr =
|
||||
o.importExpr(Identifiers.CodegenComponentFactoryResolver).instantiate([
|
||||
o.importExpr(resolveIdentifier(Identifiers.CodegenComponentFactoryResolver)).instantiate([
|
||||
o.literalArr(entryComponents.map((entryComponent) => o.importExpr(entryComponent))),
|
||||
injectFromViewParentInjector(identifierToken(Identifiers.ComponentFactoryResolver), false)
|
||||
injectFromViewParentInjector(
|
||||
resolveIdentifierToken(Identifiers.ComponentFactoryResolver), false)
|
||||
]);
|
||||
var provider = new CompileProviderMetadata({
|
||||
token: identifierToken(Identifiers.ComponentFactoryResolver),
|
||||
token: resolveIdentifierToken(Identifiers.ComponentFactoryResolver),
|
||||
useValue: createComponentFactoryResolverExpr
|
||||
});
|
||||
// Add ComponentFactoryResolver as first provider as it does not have deps on other providers
|
||||
@ -122,11 +125,14 @@ export class CompileElement extends CompileNode {
|
||||
setEmbeddedView(embeddedView: CompileView) {
|
||||
this.embeddedView = embeddedView;
|
||||
if (isPresent(embeddedView)) {
|
||||
var createTemplateRefExpr = o.importExpr(Identifiers.TemplateRef_).instantiate([
|
||||
this.appElement, this.embeddedView.viewFactory
|
||||
]);
|
||||
var provider = new CompileProviderMetadata(
|
||||
{token: identifierToken(Identifiers.TemplateRef), useValue: createTemplateRefExpr});
|
||||
var createTemplateRefExpr =
|
||||
o.importExpr(resolveIdentifier(Identifiers.TemplateRef_)).instantiate([
|
||||
this.appElement, this.embeddedView.viewFactory
|
||||
]);
|
||||
var provider = new CompileProviderMetadata({
|
||||
token: resolveIdentifierToken(Identifiers.TemplateRef),
|
||||
useValue: createTemplateRefExpr
|
||||
});
|
||||
// Add TemplateRef as first provider as it does not have deps on other providers
|
||||
this._resolvedProvidersArray.unshift(new ProviderAst(
|
||||
provider.token, false, true, [provider], ProviderAstType.Builtin, [],
|
||||
@ -137,7 +143,7 @@ export class CompileElement extends CompileNode {
|
||||
beforeChildren(): void {
|
||||
if (this.hasViewContainer) {
|
||||
this.instances.add(
|
||||
identifierToken(Identifiers.ViewContainerRef), this.appElement.prop('vcRef'));
|
||||
resolveIdentifierToken(Identifiers.ViewContainerRef), this.appElement.prop('vcRef'));
|
||||
}
|
||||
|
||||
this._resolvedProviders = new CompileIdentifierMap<CompileTokenMetadata, ProviderAst>();
|
||||
@ -319,7 +325,7 @@ export class CompileElement extends CompileNode {
|
||||
if (isPresent(dep.token)) {
|
||||
// access builtins with special visibility
|
||||
if (isBlank(result)) {
|
||||
if (dep.token.equalsTo(identifierToken(Identifiers.ChangeDetectorRef))) {
|
||||
if (dep.token.equalsTo(resolveIdentifierToken(Identifiers.ChangeDetectorRef))) {
|
||||
if (requestingProviderType === ProviderAstType.Component) {
|
||||
return this._compViewExpr.prop('ref');
|
||||
} else {
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
import {CompilePipeMetadata} from '../compile_metadata';
|
||||
import {isBlank, isPresent} from '../facade/lang';
|
||||
import {Identifiers, identifierToken} from '../identifiers';
|
||||
import {Identifiers, identifierToken, resolveIdentifier, resolveIdentifierToken} from '../identifiers';
|
||||
import * as o from '../output/output_ast';
|
||||
|
||||
import {CompileView} from './compile_view';
|
||||
@ -42,7 +42,7 @@ export class CompilePipe {
|
||||
constructor(public view: CompileView, public meta: CompilePipeMetadata) {
|
||||
this.instance = o.THIS_EXPR.prop(`_pipe_${meta.name}_${view.pipeCount++}`);
|
||||
var deps = this.meta.type.diDeps.map((diDep) => {
|
||||
if (diDep.token.equalsTo(identifierToken(Identifiers.ChangeDetectorRef))) {
|
||||
if (diDep.token.equalsTo(resolveIdentifierToken(Identifiers.ChangeDetectorRef))) {
|
||||
return getPropertyInView(o.THIS_EXPR.prop('ref'), this.view, this.view.componentView);
|
||||
}
|
||||
return injectFromViewParentInjector(diDep.token, false);
|
||||
@ -66,7 +66,7 @@ export class CompilePipe {
|
||||
pipeInstanceSeenFromPureProxy.prop('transform')
|
||||
.callMethod(o.BuiltinMethod.Bind, [pipeInstanceSeenFromPureProxy]),
|
||||
args.length, purePipeProxyInstance, callingView);
|
||||
return o.importExpr(Identifiers.castByValue)
|
||||
return o.importExpr(resolveIdentifier(Identifiers.castByValue))
|
||||
.callFn([purePipeProxyInstance, pipeInstanceSeenFromPureProxy.prop('transform')])
|
||||
.callFn(args);
|
||||
} else {
|
||||
|
@ -9,7 +9,7 @@
|
||||
import {CompileIdentifierMap, CompileQueryMetadata, CompileTokenMetadata} from '../compile_metadata';
|
||||
import {ListWrapper} from '../facade/collection';
|
||||
import {isBlank, isPresent} from '../facade/lang';
|
||||
import {Identifiers} from '../identifiers';
|
||||
import {Identifiers, resolveIdentifier} from '../identifiers';
|
||||
import * as o from '../output/output_ast';
|
||||
|
||||
import {CompileElement} from './compile_element';
|
||||
@ -115,12 +115,13 @@ function mapNestedViews(
|
||||
export function createQueryList(
|
||||
query: CompileQueryMetadata, directiveInstance: o.Expression, propertyName: string,
|
||||
compileView: CompileView): o.Expression {
|
||||
compileView.fields.push(
|
||||
new o.ClassField(propertyName, o.importType(Identifiers.QueryList, [o.DYNAMIC_TYPE])));
|
||||
compileView.fields.push(new o.ClassField(
|
||||
propertyName, o.importType(resolveIdentifier(Identifiers.QueryList), [o.DYNAMIC_TYPE])));
|
||||
var expr = o.THIS_EXPR.prop(propertyName);
|
||||
compileView.createMethod.addStmt(
|
||||
o.THIS_EXPR.prop(propertyName)
|
||||
.set(o.importExpr(Identifiers.QueryList, [o.DYNAMIC_TYPE]).instantiate([]))
|
||||
.set(o.importExpr(resolveIdentifier(Identifiers.QueryList), [o.DYNAMIC_TYPE])
|
||||
.instantiate([]))
|
||||
.toStmt());
|
||||
return expr;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import {CompileDirectiveMetadata, CompileIdentifierMap, CompileIdentifierMetadat
|
||||
import {CompilerConfig} from '../config';
|
||||
import {ListWrapper} from '../facade/collection';
|
||||
import {isBlank, isPresent} from '../facade/lang';
|
||||
import {Identifiers} from '../identifiers';
|
||||
import {Identifiers, resolveIdentifier} from '../identifiers';
|
||||
import * as o from '../output/output_ast';
|
||||
import {createDiTokenExpression} from '../util';
|
||||
|
||||
@ -150,7 +150,7 @@ export class CompileView implements NameResolver {
|
||||
|
||||
createLiteralArray(values: o.Expression[]): o.Expression {
|
||||
if (values.length === 0) {
|
||||
return o.importExpr(Identifiers.EMPTY_ARRAY);
|
||||
return o.importExpr(resolveIdentifier(Identifiers.EMPTY_ARRAY));
|
||||
}
|
||||
var proxyExpr = o.THIS_EXPR.prop(`_arr_${this.literalArrayCount++}`);
|
||||
var proxyParams: o.FnParam[] = [];
|
||||
@ -170,7 +170,7 @@ export class CompileView implements NameResolver {
|
||||
|
||||
createLiteralMap(entries: Array<Array<string|o.Expression>>): o.Expression {
|
||||
if (entries.length === 0) {
|
||||
return o.importExpr(Identifiers.EMPTY_MAP);
|
||||
return o.importExpr(resolveIdentifier(Identifiers.EMPTY_MAP));
|
||||
}
|
||||
var proxyExpr = o.THIS_EXPR.prop(`_map_${this.literalMapCount++}`);
|
||||
var proxyParams: o.FnParam[] = [];
|
||||
|
@ -10,56 +10,80 @@ import {ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';
|
||||
|
||||
import {ChangeDetectorStatus, ViewType} from '../../core_private';
|
||||
import {CompileIdentifierMetadata} from '../compile_metadata';
|
||||
import {isBlank, resolveEnumToken} from '../facade/lang';
|
||||
import {Identifiers} from '../identifiers';
|
||||
import {isBlank} from '../facade/lang';
|
||||
import {Identifiers, resolveEnumIdentifier, resolveIdentifier} from '../identifiers';
|
||||
import * as o from '../output/output_ast';
|
||||
|
||||
function _enumExpression(classIdentifier: CompileIdentifierMetadata, value: any): o.Expression {
|
||||
if (isBlank(value)) return o.NULL_EXPR;
|
||||
var name = resolveEnumToken(classIdentifier.runtime, value);
|
||||
return o.importExpr(new CompileIdentifierMetadata({
|
||||
name: `${classIdentifier.name}.${name}`,
|
||||
moduleUrl: classIdentifier.moduleUrl,
|
||||
runtime: value
|
||||
}));
|
||||
function _enumExpression(classIdentifier: CompileIdentifierMetadata, name: string): o.Expression {
|
||||
return o.importExpr(resolveEnumIdentifier(classIdentifier, name));
|
||||
}
|
||||
|
||||
export class ViewTypeEnum {
|
||||
static fromValue(value: ViewType): o.Expression {
|
||||
return _enumExpression(Identifiers.ViewType, value);
|
||||
const viewType = resolveIdentifier(Identifiers.ViewType);
|
||||
switch (value) {
|
||||
case ViewType.HOST:
|
||||
return _enumExpression(viewType, 'HOST');
|
||||
case ViewType.COMPONENT:
|
||||
return _enumExpression(viewType, 'COMPONENT');
|
||||
case ViewType.EMBEDDED:
|
||||
return _enumExpression(viewType, 'EMBEDDED');
|
||||
default:
|
||||
throw Error(`Inavlid ViewType value: ${value}`);
|
||||
}
|
||||
}
|
||||
static HOST = ViewTypeEnum.fromValue(ViewType.HOST);
|
||||
static COMPONENT = ViewTypeEnum.fromValue(ViewType.COMPONENT);
|
||||
static EMBEDDED = ViewTypeEnum.fromValue(ViewType.EMBEDDED);
|
||||
}
|
||||
|
||||
export class ViewEncapsulationEnum {
|
||||
static fromValue(value: ViewEncapsulation): o.Expression {
|
||||
return _enumExpression(Identifiers.ViewEncapsulation, value);
|
||||
const viewEncapsulation = resolveIdentifier(Identifiers.ViewEncapsulation);
|
||||
switch (value) {
|
||||
case ViewEncapsulation.Emulated:
|
||||
return _enumExpression(viewEncapsulation, 'Emulated');
|
||||
case ViewEncapsulation.Native:
|
||||
return _enumExpression(viewEncapsulation, 'Native');
|
||||
case ViewEncapsulation.None:
|
||||
return _enumExpression(viewEncapsulation, 'None');
|
||||
default:
|
||||
throw Error(`Inavlid ViewEncapsulation value: ${value}`);
|
||||
}
|
||||
}
|
||||
static Emulated = ViewEncapsulationEnum.fromValue(ViewEncapsulation.Emulated);
|
||||
static Native = ViewEncapsulationEnum.fromValue(ViewEncapsulation.Native);
|
||||
static None = ViewEncapsulationEnum.fromValue(ViewEncapsulation.None);
|
||||
}
|
||||
|
||||
export class ChangeDetectionStrategyEnum {
|
||||
static fromValue(value: ChangeDetectionStrategy): o.Expression {
|
||||
return _enumExpression(Identifiers.ChangeDetectionStrategy, value);
|
||||
const changeDetectionStrategy = resolveIdentifier(Identifiers.ChangeDetectionStrategy);
|
||||
switch (value) {
|
||||
case ChangeDetectionStrategy.OnPush:
|
||||
return _enumExpression(changeDetectionStrategy, 'OnPush');
|
||||
case ChangeDetectionStrategy.Default:
|
||||
return _enumExpression(changeDetectionStrategy, 'Default');
|
||||
default:
|
||||
throw Error(`Inavlid ChangeDetectionStrategy value: ${value}`);
|
||||
}
|
||||
}
|
||||
static OnPush = ChangeDetectionStrategyEnum.fromValue(ChangeDetectionStrategy.OnPush);
|
||||
static Default = ChangeDetectionStrategyEnum.fromValue(ChangeDetectionStrategy.Default);
|
||||
}
|
||||
|
||||
export class ChangeDetectorStatusEnum {
|
||||
static fromValue(value: ChangeDetectorStatusEnum): o.Expression {
|
||||
return _enumExpression(Identifiers.ChangeDetectorStatus, value);
|
||||
const changeDetectorStatus = resolveIdentifier(Identifiers.ChangeDetectorStatus);
|
||||
switch (value) {
|
||||
case ChangeDetectorStatus.CheckOnce:
|
||||
return _enumExpression(changeDetectorStatus, 'CheckOnce');
|
||||
case ChangeDetectorStatus.Checked:
|
||||
return _enumExpression(changeDetectorStatus, 'Checked');
|
||||
case ChangeDetectorStatus.CheckAlways:
|
||||
return _enumExpression(changeDetectorStatus, 'CheckAlways');
|
||||
case ChangeDetectorStatus.Detached:
|
||||
return _enumExpression(changeDetectorStatus, 'Detached');
|
||||
case ChangeDetectorStatus.Errored:
|
||||
return _enumExpression(changeDetectorStatus, 'Errored');
|
||||
case ChangeDetectorStatus.Destroyed:
|
||||
return _enumExpression(changeDetectorStatus, 'Destroyed');
|
||||
default:
|
||||
throw Error(`Inavlid ChangeDetectorStatus value: ${value}`);
|
||||
}
|
||||
}
|
||||
static CheckOnce = ChangeDetectorStatusEnum.fromValue(ChangeDetectorStatus.CheckOnce);
|
||||
static Checked = ChangeDetectorStatusEnum.fromValue(ChangeDetectorStatus.Checked);
|
||||
static CheckAlways = ChangeDetectorStatusEnum.fromValue(ChangeDetectorStatus.CheckAlways);
|
||||
static Detached = ChangeDetectorStatusEnum.fromValue(ChangeDetectorStatus.Detached);
|
||||
static Errored = ChangeDetectorStatusEnum.fromValue(ChangeDetectorStatus.Errored);
|
||||
static Destroyed = ChangeDetectorStatusEnum.fromValue(ChangeDetectorStatus.Destroyed);
|
||||
}
|
||||
|
||||
export class ViewConstructorVars {
|
||||
|
@ -10,7 +10,7 @@ import {AnimationOutput} from '../../core_private';
|
||||
import {CompileDirectiveMetadata} from '../compile_metadata';
|
||||
import {ListWrapper, StringMapWrapper} from '../facade/collection';
|
||||
import {StringWrapper, isBlank, isPresent} from '../facade/lang';
|
||||
import {Identifiers, identifierToken} from '../identifiers';
|
||||
import {Identifiers, identifierToken, resolveIdentifier} from '../identifiers';
|
||||
import * as o from '../output/output_ast';
|
||||
import {BoundEventAst, DirectiveAst} from '../template_parser/template_ast';
|
||||
|
||||
@ -130,7 +130,7 @@ export class CompileEventListener {
|
||||
'registerAnimationOutput',
|
||||
[
|
||||
this.compileElement.renderNode,
|
||||
o.importExpr(Identifiers.AnimationOutput).instantiate([
|
||||
o.importExpr(resolveIdentifier(Identifiers.AnimationOutput)).instantiate([
|
||||
o.literal(output.name), o.literal(output.phase)
|
||||
]),
|
||||
outputListener
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
import * as cdAst from '../expression_parser/ast';
|
||||
import {isArray, isBlank, isPresent} from '../facade/lang';
|
||||
import {Identifiers} from '../identifiers';
|
||||
import {Identifiers, resolveIdentifier} from '../identifiers';
|
||||
import * as o from '../output/output_ast';
|
||||
|
||||
export interface NameResolver {
|
||||
@ -193,7 +193,7 @@ class _AstToIrVisitor implements cdAst.AstVisitor {
|
||||
args.push(this.visit(ast.expressions[i], _Mode.Expression));
|
||||
}
|
||||
args.push(o.literal(ast.strings[ast.strings.length - 1]));
|
||||
return o.importExpr(Identifiers.interpolate).callFn(args);
|
||||
return o.importExpr(resolveIdentifier(Identifiers.interpolate)).callFn(args);
|
||||
}
|
||||
|
||||
visitKeyedRead(ast: cdAst.KeyedRead, mode: _Mode): any {
|
||||
|
@ -11,7 +11,7 @@ import {SecurityContext} from '@angular/core';
|
||||
import {EMPTY_STATE as EMPTY_ANIMATION_STATE, LifecycleHooks, isDefaultChangeDetectionStrategy} from '../../core_private';
|
||||
import * as cdAst from '../expression_parser/ast';
|
||||
import {isBlank, isPresent} from '../facade/lang';
|
||||
import {Identifiers} from '../identifiers';
|
||||
import {Identifiers, resolveIdentifier} from '../identifiers';
|
||||
import * as o from '../output/output_ast';
|
||||
import {BoundElementPropertyAst, BoundTextAst, DirectiveAst, PropertyBindingType} from '../template_parser/template_ast';
|
||||
import {camelCaseToDashCase} from '../util';
|
||||
@ -52,8 +52,9 @@ function bind(
|
||||
|
||||
// private is fine here as no child view will reference the cached value...
|
||||
view.fields.push(new o.ClassField(fieldExpr.name, null, [o.StmtModifier.Private]));
|
||||
view.createMethod.addStmt(
|
||||
o.THIS_EXPR.prop(fieldExpr.name).set(o.importExpr(Identifiers.UNINITIALIZED)).toStmt());
|
||||
view.createMethod.addStmt(o.THIS_EXPR.prop(fieldExpr.name)
|
||||
.set(o.importExpr(resolveIdentifier(Identifiers.UNINITIALIZED)))
|
||||
.toStmt());
|
||||
|
||||
if (checkExpression.needsValueUnwrapper) {
|
||||
var initValueUnwrapperStmt = DetectChangesVars.valUnwrapper.callMethod('reset', []).toStmt();
|
||||
@ -62,7 +63,7 @@ function bind(
|
||||
method.addStmt(
|
||||
currValExpr.set(checkExpression.expression).toDeclStmt(null, [o.StmtModifier.Final]));
|
||||
|
||||
var condition: o.Expression = o.importExpr(Identifiers.checkBinding).callFn([
|
||||
var condition: o.Expression = o.importExpr(resolveIdentifier(Identifiers.checkBinding)).callFn([
|
||||
DetectChangesVars.throwOnChange, fieldExpr, currValExpr
|
||||
]);
|
||||
if (checkExpression.needsValueUnwrapper) {
|
||||
@ -160,14 +161,14 @@ function bindAndWriteToRenderer(
|
||||
var oldRenderVar = o.variable('oldRenderVar');
|
||||
updateStmts.push(oldRenderVar.set(oldRenderValue).toDeclStmt());
|
||||
updateStmts.push(new o.IfStmt(
|
||||
oldRenderVar.equals(o.importExpr(Identifiers.UNINITIALIZED)),
|
||||
oldRenderVar.equals(o.importExpr(resolveIdentifier(Identifiers.UNINITIALIZED))),
|
||||
[oldRenderVar.set(emptyStateValue).toStmt()]));
|
||||
|
||||
// ... => void
|
||||
var newRenderVar = o.variable('newRenderVar');
|
||||
updateStmts.push(newRenderVar.set(renderValue).toDeclStmt());
|
||||
updateStmts.push(new o.IfStmt(
|
||||
newRenderVar.equals(o.importExpr(Identifiers.UNINITIALIZED)),
|
||||
newRenderVar.equals(o.importExpr(resolveIdentifier(Identifiers.UNINITIALIZED))),
|
||||
[newRenderVar.set(emptyStateValue).toStmt()]));
|
||||
|
||||
updateStmts.push(
|
||||
@ -218,7 +219,8 @@ function sanitizedValue(
|
||||
throw new Error(`internal error, unexpected SecurityContext ${boundProp.securityContext}.`);
|
||||
}
|
||||
let ctx = ViewProperties.viewUtils.prop('sanitizer');
|
||||
let args = [o.importExpr(Identifiers.SecurityContext).prop(enumValue), renderValue];
|
||||
let args =
|
||||
[o.importExpr(resolveIdentifier(Identifiers.SecurityContext)).prop(enumValue), renderValue];
|
||||
return ctx.callMethod('sanitize', args);
|
||||
}
|
||||
|
||||
@ -264,12 +266,13 @@ export function bindDirectiveInputs(
|
||||
statements.push(new o.IfStmt(
|
||||
DetectChangesVars.changes.identical(o.NULL_EXPR),
|
||||
[DetectChangesVars.changes
|
||||
.set(o.literalMap([], new o.MapType(o.importType(Identifiers.SimpleChange))))
|
||||
.set(o.literalMap(
|
||||
[], new o.MapType(o.importType(resolveIdentifier(Identifiers.SimpleChange)))))
|
||||
.toStmt()]));
|
||||
statements.push(
|
||||
DetectChangesVars.changes.key(o.literal(input.directiveName))
|
||||
.set(o.importExpr(Identifiers.SimpleChange).instantiate([fieldExpr, currValExpr]))
|
||||
.toStmt());
|
||||
statements.push(DetectChangesVars.changes.key(o.literal(input.directiveName))
|
||||
.set(o.importExpr(resolveIdentifier(Identifiers.SimpleChange))
|
||||
.instantiate([fieldExpr, currValExpr]))
|
||||
.toStmt());
|
||||
}
|
||||
if (isOnPushComp) {
|
||||
statements.push(DetectChangesVars.changed.set(o.literal(true)).toStmt());
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
import {CompileDirectiveMetadata, CompileTokenMetadata} from '../compile_metadata';
|
||||
import {isBlank, isPresent} from '../facade/lang';
|
||||
import {Identifiers} from '../identifiers';
|
||||
import {Identifiers, resolveIdentifier} from '../identifiers';
|
||||
import * as o from '../output/output_ast';
|
||||
import {createDiTokenExpression} from '../util';
|
||||
|
||||
@ -87,6 +87,7 @@ export function createPureProxy(
|
||||
if (isBlank(pureProxyId)) {
|
||||
throw new Error(`Unsupported number of argument for pure functions: ${argCount}`);
|
||||
}
|
||||
view.createMethod.addStmt(
|
||||
o.THIS_EXPR.prop(pureProxyProp.name).set(o.importExpr(pureProxyId).callFn([fn])).toStmt());
|
||||
view.createMethod.addStmt(o.THIS_EXPR.prop(pureProxyProp.name)
|
||||
.set(o.importExpr(resolveIdentifier(pureProxyId)).callFn([fn]))
|
||||
.toStmt());
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import {AnimationCompiler} from '../animation/animation_compiler';
|
||||
import {CompileDirectiveMetadata, CompileIdentifierMetadata, CompileTokenMetadata, CompileTypeMetadata} from '../compile_metadata';
|
||||
import {ListWrapper, SetWrapper, StringMapWrapper} from '../facade/collection';
|
||||
import {StringWrapper, isPresent} from '../facade/lang';
|
||||
import {Identifiers, identifierToken} from '../identifiers';
|
||||
import {Identifiers, identifierToken, resolveIdentifier, resolveIdentifierToken} from '../identifiers';
|
||||
import * as o from '../output/output_ast';
|
||||
import {AttrAst, BoundDirectivePropertyAst, BoundElementPropertyAst, BoundEventAst, BoundTextAst, DirectiveAst, ElementAst, EmbeddedTemplateAst, NgContentAst, ProviderAst, ReferenceAst, TemplateAst, TemplateAstVisitor, TextAst, VariableAst, templateVisitAll} from '../template_parser/template_ast';
|
||||
import {createDiTokenExpression} from '../util';
|
||||
@ -148,7 +148,8 @@ class ViewBuilderVisitor implements TemplateAstVisitor {
|
||||
'projectNodes',
|
||||
[
|
||||
parentRenderNode,
|
||||
o.importExpr(Identifiers.flattenNestedViewRenderNodes).callFn([nodesExpression])
|
||||
o.importExpr(resolveIdentifier(Identifiers.flattenNestedViewRenderNodes))
|
||||
.callFn([nodesExpression])
|
||||
])
|
||||
.toStmt());
|
||||
} else if (this._isRootNode(parent)) {
|
||||
@ -396,7 +397,8 @@ function createViewTopLevelStmts(view: CompileView, targetStatements: o.Statemen
|
||||
.set(o.literalArr(
|
||||
view.nodes.map(createStaticNodeDebugInfo),
|
||||
new o.ArrayType(
|
||||
new o.ExternalType(Identifiers.StaticNodeDebugInfo), [o.TypeModifier.Const])))
|
||||
new o.ExternalType(resolveIdentifier(Identifiers.StaticNodeDebugInfo)),
|
||||
[o.TypeModifier.Const])))
|
||||
.toDeclStmt(null, [o.StmtModifier.Final]));
|
||||
}
|
||||
|
||||
@ -404,8 +406,9 @@ function createViewTopLevelStmts(view: CompileView, targetStatements: o.Statemen
|
||||
var renderCompTypeVar: o.ReadVarExpr =
|
||||
o.variable(`renderType_${view.component.type.name}`); // fix highlighting: `
|
||||
if (view.viewIndex === 0) {
|
||||
targetStatements.push(renderCompTypeVar.set(o.NULL_EXPR)
|
||||
.toDeclStmt(o.importType(Identifiers.RenderComponentType)));
|
||||
targetStatements.push(
|
||||
renderCompTypeVar.set(o.NULL_EXPR)
|
||||
.toDeclStmt(o.importType(resolveIdentifier(Identifiers.RenderComponentType))));
|
||||
}
|
||||
|
||||
var viewClass = createViewClass(view, renderCompTypeVar, nodeDebugInfosVar);
|
||||
@ -429,23 +432,29 @@ function createStaticNodeDebugInfo(node: CompileNode): o.Expression {
|
||||
[varName, isPresent(token) ? createDiTokenExpression(token) : o.NULL_EXPR]);
|
||||
});
|
||||
}
|
||||
return o.importExpr(Identifiers.StaticNodeDebugInfo)
|
||||
return o.importExpr(resolveIdentifier(Identifiers.StaticNodeDebugInfo))
|
||||
.instantiate(
|
||||
[
|
||||
o.literalArr(providerTokens, new o.ArrayType(o.DYNAMIC_TYPE, [o.TypeModifier.Const])),
|
||||
componentToken,
|
||||
o.literalMap(varTokenEntries, new o.MapType(o.DYNAMIC_TYPE, [o.TypeModifier.Const]))
|
||||
],
|
||||
o.importType(Identifiers.StaticNodeDebugInfo, null, [o.TypeModifier.Const]));
|
||||
o.importType(
|
||||
resolveIdentifier(Identifiers.StaticNodeDebugInfo), null, [o.TypeModifier.Const]));
|
||||
}
|
||||
|
||||
function createViewClass(
|
||||
view: CompileView, renderCompTypeVar: o.ReadVarExpr,
|
||||
nodeDebugInfosVar: o.Expression): o.ClassStmt {
|
||||
var viewConstructorArgs = [
|
||||
new o.FnParam(ViewConstructorVars.viewUtils.name, o.importType(Identifiers.ViewUtils)),
|
||||
new o.FnParam(ViewConstructorVars.parentInjector.name, o.importType(Identifiers.Injector)),
|
||||
new o.FnParam(ViewConstructorVars.declarationEl.name, o.importType(Identifiers.AppElement))
|
||||
new o.FnParam(
|
||||
ViewConstructorVars.viewUtils.name, o.importType(resolveIdentifier(Identifiers.ViewUtils))),
|
||||
new o.FnParam(
|
||||
ViewConstructorVars.parentInjector.name,
|
||||
o.importType(resolveIdentifier(Identifiers.Injector))),
|
||||
new o.FnParam(
|
||||
ViewConstructorVars.declarationEl.name,
|
||||
o.importType(resolveIdentifier(Identifiers.AppElement)))
|
||||
];
|
||||
var superConstructorArgs = [
|
||||
o.variable(view.className), renderCompTypeVar, ViewTypeEnum.fromValue(view.viewType),
|
||||
@ -462,7 +471,7 @@ function createViewClass(
|
||||
var viewMethods = [
|
||||
new o.ClassMethod(
|
||||
'createInternal', [new o.FnParam(rootSelectorVar.name, o.STRING_TYPE)],
|
||||
generateCreateMethod(view), o.importType(Identifiers.AppElement)),
|
||||
generateCreateMethod(view), o.importType(resolveIdentifier(Identifiers.AppElement))),
|
||||
new o.ClassMethod(
|
||||
'injectorGetInternal',
|
||||
[
|
||||
@ -482,17 +491,23 @@ function createViewClass(
|
||||
].concat(view.eventHandlerMethods);
|
||||
var superClass = view.genConfig.genDebugInfo ? Identifiers.DebugAppView : Identifiers.AppView;
|
||||
var viewClass = new o.ClassStmt(
|
||||
view.className, o.importExpr(superClass, [getContextType(view)]), view.fields, view.getters,
|
||||
viewConstructor, viewMethods.filter((method) => method.body.length > 0));
|
||||
view.className, o.importExpr(resolveIdentifier(superClass), [getContextType(view)]),
|
||||
view.fields, view.getters, viewConstructor,
|
||||
viewMethods.filter((method) => method.body.length > 0));
|
||||
return viewClass;
|
||||
}
|
||||
|
||||
function createViewFactory(
|
||||
view: CompileView, viewClass: o.ClassStmt, renderCompTypeVar: o.ReadVarExpr): o.Statement {
|
||||
var viewFactoryArgs = [
|
||||
new o.FnParam(ViewConstructorVars.viewUtils.name, o.importType(Identifiers.ViewUtils)),
|
||||
new o.FnParam(ViewConstructorVars.parentInjector.name, o.importType(Identifiers.Injector)),
|
||||
new o.FnParam(ViewConstructorVars.declarationEl.name, o.importType(Identifiers.AppElement))
|
||||
new o.FnParam(
|
||||
ViewConstructorVars.viewUtils.name, o.importType(resolveIdentifier(Identifiers.ViewUtils))),
|
||||
new o.FnParam(
|
||||
ViewConstructorVars.parentInjector.name,
|
||||
o.importType(resolveIdentifier(Identifiers.Injector))),
|
||||
new o.FnParam(
|
||||
ViewConstructorVars.declarationEl.name,
|
||||
o.importType(resolveIdentifier(Identifiers.AppElement)))
|
||||
];
|
||||
var initRenderCompTypeStmts: any[] = [];
|
||||
var templateUrlInfo: string;
|
||||
@ -522,7 +537,7 @@ function createViewFactory(
|
||||
o.variable(viewClass.name)
|
||||
.instantiate(viewClass.constructorMethod.params.map(
|
||||
(param) => o.variable(param.name))))]),
|
||||
o.importType(Identifiers.AppView, [getContextType(view)]))
|
||||
o.importType(resolveIdentifier(Identifiers.AppView), [getContextType(view)]))
|
||||
.toDeclStmt(view.viewFactory.name, [o.StmtModifier.Final]);
|
||||
}
|
||||
|
||||
@ -589,12 +604,14 @@ function generateDetectChangesMethod(view: CompileView): o.Statement[] {
|
||||
varStmts.push(DetectChangesVars.changed.set(o.literal(true)).toDeclStmt(o.BOOL_TYPE));
|
||||
}
|
||||
if (SetWrapper.has(readVars, DetectChangesVars.changes.name)) {
|
||||
varStmts.push(DetectChangesVars.changes.set(o.NULL_EXPR)
|
||||
.toDeclStmt(new o.MapType(o.importType(Identifiers.SimpleChange))));
|
||||
varStmts.push(
|
||||
DetectChangesVars.changes.set(o.NULL_EXPR)
|
||||
.toDeclStmt(new o.MapType(o.importType(resolveIdentifier(Identifiers.SimpleChange)))));
|
||||
}
|
||||
if (SetWrapper.has(readVars, DetectChangesVars.valUnwrapper.name)) {
|
||||
varStmts.push(
|
||||
DetectChangesVars.valUnwrapper.set(o.importExpr(Identifiers.ValueUnwrapper).instantiate([]))
|
||||
DetectChangesVars.valUnwrapper
|
||||
.set(o.importExpr(resolveIdentifier(Identifiers.ValueUnwrapper)).instantiate([]))
|
||||
.toDeclStmt(null, [o.StmtModifier.Final]));
|
||||
}
|
||||
return varStmts.concat(stmts);
|
||||
|
Reference in New Issue
Block a user