mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-11 18:42:56 +00:00
fix: replace the top-level context only
This commit is contained in:
parent
df8a750746
commit
37e07bb238
@ -271,7 +271,7 @@ export function parseExpressionConvertThis2Context(
|
|||||||
|
|
||||||
const localVariablesSet = new Set(localVariables);
|
const localVariablesSet = new Set(localVariables);
|
||||||
|
|
||||||
let thisScopeLevel = CROSS_THIS_SCOPE_TYPE_NODE[exprAst.type] ? -1 : 0;
|
let thisScopeLevel = -1;
|
||||||
traverse(fileAst, {
|
traverse(fileAst, {
|
||||||
enter(path) {
|
enter(path) {
|
||||||
if (CROSS_THIS_SCOPE_TYPE_NODE[path.node.type]) {
|
if (CROSS_THIS_SCOPE_TYPE_NODE[path.node.type]) {
|
||||||
@ -303,7 +303,7 @@ export function parseExpressionConvertThis2Context(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 替换 this (只在顶层替换)
|
// 替换 this (只在顶层替换)
|
||||||
if (thisScopeLevel <= 0) {
|
if (thisScopeLevel === 0) {
|
||||||
obj.replaceWith(t.identifier(contextName));
|
obj.replaceWith(t.identifier(contextName));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -317,7 +317,7 @@ export function parseExpressionConvertThis2Context(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thisScopeLevel <= 0) {
|
if (thisScopeLevel === 0) {
|
||||||
path.replaceWith(t.identifier(contextName));
|
path.replaceWith(t.identifier(contextName));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user