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
@ -32,8 +32,6 @@ export abstract class CompileMetadataWithIdentifier {
|
||||
|
||||
get runtimeCacheKey(): any { return unimplemented(); }
|
||||
|
||||
get assetCacheKey(): any { return unimplemented(); }
|
||||
|
||||
equalsTo(id2: CompileMetadataWithIdentifier): boolean { return unimplemented(); }
|
||||
}
|
||||
|
||||
@ -93,7 +91,6 @@ export class CompileIdentifierMetadata implements CompileMetadataWithIdentifier
|
||||
prefix: string;
|
||||
moduleUrl: string;
|
||||
value: any;
|
||||
private _assetCacheKey: any = UNDEFINED;
|
||||
|
||||
constructor(
|
||||
{runtime, name, moduleUrl, prefix, value}:
|
||||
@ -109,23 +106,9 @@ export class CompileIdentifierMetadata implements CompileMetadataWithIdentifier
|
||||
|
||||
get runtimeCacheKey(): any { return this.identifier.runtime; }
|
||||
|
||||
get assetCacheKey(): any {
|
||||
if (this._assetCacheKey === UNDEFINED) {
|
||||
if (isPresent(this.moduleUrl) && isPresent(getUrlScheme(this.moduleUrl))) {
|
||||
var uri = reflector.importUri({'filePath': this.moduleUrl, 'name': this.name});
|
||||
this._assetCacheKey = `${this.name}|${uri}`;
|
||||
} else {
|
||||
this._assetCacheKey = null;
|
||||
}
|
||||
}
|
||||
return this._assetCacheKey;
|
||||
}
|
||||
|
||||
equalsTo(id2: CompileIdentifierMetadata): boolean {
|
||||
var rk = this.runtimeCacheKey;
|
||||
var ak = this.assetCacheKey;
|
||||
return (isPresent(rk) && rk == id2.runtimeCacheKey) ||
|
||||
(isPresent(ak) && ak == id2.assetCacheKey);
|
||||
return isPresent(rk) && rk == id2.runtimeCacheKey;
|
||||
}
|
||||
}
|
||||
|
||||
@ -233,19 +216,9 @@ export class CompileTokenMetadata implements CompileMetadataWithIdentifier {
|
||||
}
|
||||
}
|
||||
|
||||
get assetCacheKey(): any {
|
||||
if (isPresent(this.identifier)) {
|
||||
return this.identifier.assetCacheKey;
|
||||
} else {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
equalsTo(token2: CompileTokenMetadata): boolean {
|
||||
var rk = this.runtimeCacheKey;
|
||||
var ak = this.assetCacheKey;
|
||||
return (isPresent(rk) && rk == token2.runtimeCacheKey) ||
|
||||
(isPresent(ak) && ak == token2.assetCacheKey);
|
||||
return isPresent(rk) && rk == token2.runtimeCacheKey;
|
||||
}
|
||||
|
||||
get name(): string {
|
||||
@ -275,24 +248,17 @@ export class CompileIdentifierMap<KEY extends CompileMetadataWithIdentifier, VAL
|
||||
this._tokens.push(token);
|
||||
this._values.push(value);
|
||||
var rk = token.runtimeCacheKey;
|
||||
if (isPresent(rk)) {
|
||||
this._valueMap.set(rk, value);
|
||||
}
|
||||
var ak = token.assetCacheKey;
|
||||
if (isPresent(ak)) {
|
||||
this._valueMap.set(ak, value);
|
||||
if (!isPresent(rk)) {
|
||||
throw new Error(`Cannot find a key for Token: ${token.identifier.name}`);
|
||||
}
|
||||
this._valueMap.set(rk, value);
|
||||
}
|
||||
get(token: KEY): VALUE {
|
||||
var rk = token.runtimeCacheKey;
|
||||
var ak = token.assetCacheKey;
|
||||
var result: VALUE;
|
||||
if (isPresent(rk)) {
|
||||
result = this._valueMap.get(rk);
|
||||
}
|
||||
if (isBlank(result) && isPresent(ak)) {
|
||||
result = this._valueMap.get(ak);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
keys(): KEY[] { return this._tokens; }
|
||||
@ -547,8 +513,6 @@ export class CompileDirectiveMetadata implements CompileMetadataWithIdentifier {
|
||||
|
||||
get runtimeCacheKey(): any { return this.type.runtimeCacheKey; }
|
||||
|
||||
get assetCacheKey(): any { return this.type.assetCacheKey; }
|
||||
|
||||
equalsTo(other: CompileMetadataWithIdentifier): boolean {
|
||||
return this.type.equalsTo(other.identifier);
|
||||
}
|
||||
@ -568,6 +532,7 @@ export function createHostComponentMeta(compMeta: CompileDirectiveMetadata):
|
||||
isHost: true
|
||||
}),
|
||||
template: new CompileTemplateMetadata({
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
template: template,
|
||||
templateUrl: '',
|
||||
styles: [],
|
||||
@ -606,8 +571,6 @@ export class CompilePipeMetadata implements CompileMetadataWithIdentifier {
|
||||
get identifier(): CompileIdentifierMetadata { return this.type; }
|
||||
get runtimeCacheKey(): any { return this.type.runtimeCacheKey; }
|
||||
|
||||
get assetCacheKey(): any { return this.type.assetCacheKey; }
|
||||
|
||||
equalsTo(other: CompileMetadataWithIdentifier): boolean {
|
||||
return this.type.equalsTo(other.identifier);
|
||||
}
|
||||
@ -668,8 +631,6 @@ export class CompileNgModuleMetadata implements CompileMetadataWithIdentifier {
|
||||
get identifier(): CompileIdentifierMetadata { return this.type; }
|
||||
get runtimeCacheKey(): any { return this.type.runtimeCacheKey; }
|
||||
|
||||
get assetCacheKey(): any { return this.type.assetCacheKey; }
|
||||
|
||||
equalsTo(other: CompileMetadataWithIdentifier): boolean {
|
||||
return this.type.equalsTo(other.identifier);
|
||||
}
|
||||
|
Reference in New Issue
Block a user