mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-17 23:32:49 +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,
|
nodeChildren: null,
|
||||||
childrenInState: false,
|
childrenInState: false,
|
||||||
visible: !hidden,
|
visible: !hidden,
|
||||||
condition: __parseData(condition, scope),
|
condition: __parseData?.(condition, scope),
|
||||||
nodeCacheProps: {},
|
nodeCacheProps: {},
|
||||||
nodeProps: {},
|
nodeProps: {},
|
||||||
};
|
};
|
||||||
@ -396,7 +396,7 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
|
|||||||
|
|
||||||
if (key === '___condition___') {
|
if (key === '___condition___') {
|
||||||
const { condition = true } = this.leaf?.export(TransformStage.Render) || {};
|
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}]`);
|
__debug(`key is ___condition___, change condition value to [${condition}]`);
|
||||||
// 条件表达式改变
|
// 条件表达式改变
|
||||||
this.setState({
|
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));
|
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)) {
|
if (isJSExpression(schema)) {
|
||||||
return parseExpression(schema, self, options.thisRequiredInJSE);
|
return parseExpression(schema, self, options.thisRequiredInJSE);
|
||||||
} else if (isI18nData(schema)) {
|
} else if (isI18nData(schema)) {
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import '../utils/react-env-init';
|
|||||||
import { leafWrapper } from '../../src/hoc/leaf';
|
import { leafWrapper } from '../../src/hoc/leaf';
|
||||||
import components from '../utils/components';
|
import components from '../utils/components';
|
||||||
import Node from '../utils/node';
|
import Node from '../utils/node';
|
||||||
|
import { parseData } from '../../src/utils';
|
||||||
|
|
||||||
let rerenderCount = 0;
|
let rerenderCount = 0;
|
||||||
|
|
||||||
@ -37,6 +38,9 @@ const baseRenderer: any = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
documentId: '01'
|
documentId: '01'
|
||||||
|
},
|
||||||
|
__parseData (data, scope) {
|
||||||
|
return parseData(data, scope, {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -329,7 +329,7 @@ describe('JSExpression', () => {
|
|||||||
],
|
],
|
||||||
loop: {
|
loop: {
|
||||||
type: "JSExpression",
|
type: "JSExpression",
|
||||||
value: "state.content"
|
value: "this.state.content"
|
||||||
},
|
},
|
||||||
loopArgs: [
|
loopArgs: [
|
||||||
"item",
|
"item",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user