mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-15 05:36:39 +00:00
fix: fix the unit test failure problem caused by thisRequiredInJSE modification
This commit is contained in:
parent
7e5a919f93
commit
c2c59b7ff7
@ -226,7 +226,7 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
|
||||
nodeChildren: null,
|
||||
childrenInState: false,
|
||||
visible: !hidden,
|
||||
condition: __parseData(condition, scope),
|
||||
condition: __parseData?.(condition, scope),
|
||||
nodeCacheProps: {},
|
||||
nodeProps: {},
|
||||
};
|
||||
@ -396,7 +396,7 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
|
||||
|
||||
if (key === '___condition___') {
|
||||
const { condition = true } = this.leaf?.export(TransformStage.Render) || {};
|
||||
const conditionValue = __parseData(condition, scope);
|
||||
const conditionValue = __parseData?.(condition, scope);
|
||||
__debug(`key is ___condition___, change condition value to [${condition}]`);
|
||||
// 条件表达式改变
|
||||
this.setState({
|
||||
|
||||
@ -330,7 +330,11 @@ export function forEach(targetObj: any, fn: any, context?: any) {
|
||||
Object.keys(targetObj).forEach((key) => fn.call(context, targetObj[key], key));
|
||||
}
|
||||
|
||||
export function parseData(schema: unknown, self: any, options: any): any {
|
||||
interface IParseOptions {
|
||||
thisRequiredInJSE?: boolean;
|
||||
}
|
||||
|
||||
export function parseData(schema: unknown, self: any, options: IParseOptions = {}): any {
|
||||
if (isJSExpression(schema)) {
|
||||
return parseExpression(schema, self, options.thisRequiredInJSE);
|
||||
} else if (isI18nData(schema)) {
|
||||
|
||||
@ -5,6 +5,7 @@ import '../utils/react-env-init';
|
||||
import { leafWrapper } from '../../src/hoc/leaf';
|
||||
import components from '../utils/components';
|
||||
import Node from '../utils/node';
|
||||
import { parseData } from '../../src/utils';
|
||||
|
||||
let rerenderCount = 0;
|
||||
|
||||
@ -37,6 +38,9 @@ const baseRenderer: any = {
|
||||
}
|
||||
},
|
||||
documentId: '01'
|
||||
},
|
||||
__parseData (data, scope) {
|
||||
return parseData(data, scope, {});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -329,7 +329,7 @@ describe('JSExpression', () => {
|
||||
],
|
||||
loop: {
|
||||
type: "JSExpression",
|
||||
value: "state.content"
|
||||
value: "this.state.content"
|
||||
},
|
||||
loopArgs: [
|
||||
"item",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user