refactor(compiler): move host properties into DirectiveWrapper
Part of #11683
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
|
||||
import {CompileTokenMetadata} from '../compile_metadata';
|
||||
import {isPresent} from '../facade/lang';
|
||||
import {Identifiers, resolveIdentifier} from '../identifiers';
|
||||
import {IdentifierSpec, Identifiers, resolveEnumIdentifier, resolveIdentifier} from '../identifiers';
|
||||
import * as o from '../output/output_ast';
|
||||
|
||||
export function createDiTokenExpression(token: CompileTokenMetadata): o.Expression {
|
||||
@ -49,3 +49,12 @@ export function createPureProxy(
|
||||
.set(o.importExpr(resolveIdentifier(pureProxyId)).callFn([fn]))
|
||||
.toStmt());
|
||||
}
|
||||
|
||||
export function createEnumExpression(enumType: IdentifierSpec, enumValue: any): o.Expression {
|
||||
const enumName =
|
||||
Object.keys(enumType.runtime).find((propName) => enumType.runtime[propName] === enumValue);
|
||||
if (!enumName) {
|
||||
throw new Error(`Unknown enum value ${enumValue} in ${enumType.name}`);
|
||||
}
|
||||
return o.importExpr(resolveEnumIdentifier(resolveIdentifier(enumType), enumName));
|
||||
}
|
||||
|
Reference in New Issue
Block a user