perf: parse filenames in parse() insteadof render()

This commit is contained in:
harttle
2021-09-30 22:15:09 +08:00
committed by Jun Yang
parent 24f5346084
commit 8273c17dab
13 changed files with 80 additions and 68 deletions
+1 -2
View File
@@ -47,10 +47,9 @@ export function evalToken (token: Token | undefined, ctx: Context, lenient = fal
}
function evalPropertyAccessToken (token: PropertyAccessToken, ctx: Context, lenient: boolean) {
const variable = token.getVariableAsText()
const props: string[] = token.props.map(prop => evalToken(prop, ctx, false))
try {
return ctx.get([variable, ...props])
return ctx.get([token.propertyName, ...props])
} catch (e) {
if (lenient && e.name === 'InternalUndefinedVariableError') return null
throw (new UndefinedVariableError(e, token))