mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-14 04:43:14 +00:00
fix: do not parse props when condition is false or loop data is empty (#2477)
* fix: do not parse children props when condition is falsy * fix: skip parsing children when loop data is empty
This commit is contained in:
parent
1072ff36fb
commit
cf2f5c29bc
@ -545,6 +545,7 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
|||||||
|
|
||||||
if (schema.loop != null) {
|
if (schema.loop != null) {
|
||||||
const loop = this.__parseData(schema.loop, scope);
|
const loop = this.__parseData(schema.loop, scope);
|
||||||
|
if (Array.isArray(loop) && loop.length === 0) return null;
|
||||||
const useLoop = isUseLoop(loop, this.__designModeIsDesign);
|
const useLoop = isUseLoop(loop, this.__designModeIsDesign);
|
||||||
if (useLoop) {
|
if (useLoop) {
|
||||||
return this.__createLoopVirtualDom(
|
return this.__createLoopVirtualDom(
|
||||||
@ -649,7 +650,7 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
|||||||
props.key = props.__id;
|
props.key = props.__id;
|
||||||
}
|
}
|
||||||
|
|
||||||
let child = this.__getSchemaChildrenVirtualDom(schema, scope, Comp);
|
let child = this.__getSchemaChildrenVirtualDom(schema, scope, Comp, condition);
|
||||||
const renderComp = (innerProps: any) => engine.createElement(Comp, innerProps, child);
|
const renderComp = (innerProps: any) => engine.createElement(Comp, innerProps, child);
|
||||||
// 设计模式下的特殊处理
|
// 设计模式下的特殊处理
|
||||||
if (engine && [DESIGN_MODE.EXTEND, DESIGN_MODE.BORDER].includes(engine.props.designMode)) {
|
if (engine && [DESIGN_MODE.EXTEND, DESIGN_MODE.BORDER].includes(engine.props.designMode)) {
|
||||||
@ -709,8 +710,8 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
__getSchemaChildrenVirtualDom = (schema: IPublicTypeNodeSchema | undefined, scope: any, Comp: any) => {
|
__getSchemaChildrenVirtualDom = (schema: IPublicTypeNodeSchema | undefined, scope: any, Comp: any, condition = true) => {
|
||||||
let children = getSchemaChildren(schema);
|
let children = condition ? getSchemaChildren(schema) : null;
|
||||||
|
|
||||||
// @todo 补完这里的 Element 定义 @承虎
|
// @todo 补完这里的 Element 定义 @承虎
|
||||||
let result: any = [];
|
let result: any = [];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user