diff --git a/compiler/complex_attr.json b/compiler/complex_attr.json new file mode 100644 index 0000000000000000000000000000000000000000..bfa6301cc0da3a3d3dbea5d8df70724e2e4b1245 --- /dev/null +++ b/compiler/complex_attr.json @@ -0,0 +1,48 @@ +{ + "size": { + "width": "width", + "height": "height" + }, + "height": { + "height": "height" + }, + "width": { + "width": "width" + }, + "border": { + "width": "borderWidth", + "color": "borderColor", + "radius": "borderRadius", + "style": "borderStyle" + }, + "borderWidth": { + "borderWidth": "borderWidth" + }, + "borderColor": { + "borderColor": "borderColor" + }, + "borderRadius": { + "borderRadius": "borderRadius" + }, + "borderStyle": { + "borderStyle": "borderStyle" + }, + "font": { + "size": "fontSize", + "weight": "fontWeight", + "family": "fontFamily", + "style": "fontStyle" + }, + "fontSize": { + "fontSize": "fontSize" + }, + "fontWeight": { + "fontWeight": "fontWeight" + }, + "fontFamily": { + "fontFamily": "fontFamily" + }, + "fontStyle": { + "fontStyle": "fontStyle" + } +} diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index 9a88f6657bf3d162da2eba13c501899bc6ea27a7..96d6bd11fd7102108e6af1eb88b7d1427a0d8514 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -596,3 +596,90 @@ export const ARKTS_MODULE_PREFIX: string = '@arkts'; export const ARKTS_MODULE_NAME: string = 'arkts'; export const COLD_RELOAD_MODE: string = 'coldReload'; export const INTEGRATED_HSP: string = 'integratedHsp'; +export const ATTRS_MAPPING = { + "size": { + "width": "width", + "height": "height" + }, + "height": { + "height": "height" + }, + "width": { + "width": "width" + }, + "border": { + "width": "borderWidth", + "color": "borderColor", + "radius": "borderRadius", + "style": "borderStyle" + }, + "borderWidth": { + "borderWidth": "borderWidth" + }, + "borderColor": { + "borderColor": "borderColor" + }, + "borderRadius": { + "borderRadius": "borderRadius" + }, + "borderStyle": { + "borderStyle": "borderStyle" + }, + "font": { + "size": "fontSize", + "weight": "fontWeight", + "family": "fontFamily", + "style": "fontStyle" + }, + "fontSize": { + "fontSize": "fontSize" + }, + "fontWeight": { + "fontWeight": "fontWeight" + }, + "fontFamily": { + "fontFamily": "fontFamily" + }, + "fontStyle": { + "fontStyle": "fontStyle" + }, + "backgroundColor": { + "backgroundColor": "backgroundColor" + }, + "margin": { + "left": "marginLeft", + "right": "marginRight", + "top": "marginTop", + "bottom": "marginBottom" + }, + "marginLeft": { + "marginLeft": "marginLeft" + }, + "marginRight": { + "marginRight": "marginRight" + }, + "marginTop": { + "marginTop": "marginTop" + }, + "marginBottom": { + "marginBottom": "marginBottom" + }, + "padding": { + "left": "paddingLeft", + "right": "paddingRight", + "top": "paddingTop", + "bottom": "paddingBottom" + }, + "paddingLeft": { + "paddingLeft": "paddingLeft" + }, + "paddingRight": { + "paddingRight": "paddingRight" + }, + "paddingTop": { + "paddingTop": "paddingTop" + }, + "paddingBottom": { + "paddingBottom": "paddingBottom" + }, +}; \ No newline at end of file diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index eeaa9b01b83b641a24cf221d36aeae287aaff88a..dece941d22dc8f6a35a3b9a4f4db698b14f09a7c 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -15,6 +15,7 @@ import ts from 'typescript'; import path from 'path'; +import fs from 'fs'; import { COMPONENT_RENDER_FUNCTION, @@ -135,7 +136,8 @@ import { NAVIGATION, CREATE_ROUTER_COMPONENT_COLLECT, NAV_PATH_STACK, - IS_USER_CREATE_STACK + IS_USER_CREATE_STACK, + ATTRS_MAPPING, } from './pre_define'; import { INNER_COMPONENT_NAMES, @@ -185,9 +187,46 @@ import { builderTypeParameter, resourceFileName } from './process_ui_syntax'; +import { curPropMap } from './process_component_member'; import { regularCollection } from './validate_ui_syntax'; import { contextStackPushOrPop } from './process_component_class'; +export function isReuseMode() { + return partialUpdateConfig.partialUpdateMode && !storedFileInfo.processRepeat && (storedFileInfo.processStateStyles===0); +} + +function attrExpHasProp(temp: ts.CallExpression, expName : string, propName : string, attrArgs : ts.Expression[]): boolean { + + if(expName == propName) { + attrArgs.push(...temp.arguments); + return true; + } + + if(temp.arguments.length) { + let arg = temp.arguments[0]; + if(!ts.isObjectLiteralExpression(arg)) { + attrArgs.push(arg); + return true; + } + for(let prop of arg.properties as ts.NodeArray) { + if (prop.name.getText() == propName) { + attrArgs.push(prop.initializer); + return true; + } + } + } + return false; +} + +const HANDLE_COMPLEX_ATTRS : Map> = new Map( + Object.entries(ATTRS_MAPPING).map(([key, value]) => [ + key, + new Map(Object.entries(value)) + ]) +); + +const forEachPropMap : Map = new Map(); + export function processComponentBuild(node: ts.MethodDeclaration, log: LogInfo[]): ts.MethodDeclaration { let newNode: ts.MethodDeclaration; @@ -840,11 +879,8 @@ function processNormalComponent(node: ts.ExpressionStatement, nameResult: NameRe if (etsComponentResult.etsComponentNode.body && ts.isBlock(etsComponentResult.etsComponentNode.body)) { if (res.isButton) { checkButtonParamHasLabel(etsComponentResult.etsComponentNode, log); - if (projectConfig.isPreview || projectConfig.enableDebugLine) { - newStatements.splice(-2, 1, createComponent(node, COMPONENT_CREATE_CHILD_FUNCTION).newNode); - } else { - newStatements.splice(-1, 1, createComponent(node, COMPONENT_CREATE_CHILD_FUNCTION).newNode); - } + let removeIndex : number = (projectConfig.isPreview || projectConfig.enableDebugLine)? -2:-1; + newStatements.splice(removeIndex, 1, createComponent(node, COMPONENT_CREATE_CHILD_FUNCTION).newNode); } if (etsComponentResult.hasAttr) { bindComponentAttr(node, res.identifierNode, newStatements, log, true, false, immutableStatements); @@ -1043,6 +1079,8 @@ export function createComponentCreationStatement(node: ts.Statement, innerStatem } if (!isTransition) { createInitRenderStatement(node, immutableStatements, blockArr); + } else if (immutableStatements) { + blockArr.push(...immutableStatements); } if (!partialUpdateConfig.optimizeComponent) { blockArr.unshift(createViewStackProcessorStatement(STARTGETACCESSRECORDINGFOR, ELMTID)); @@ -1419,6 +1457,7 @@ function processTabAndNav(node: ts.ExpressionStatement, innerCompStatements: ts. tabAttrs.push(createCollectElmtIdNode()); } const immutableStatements: ts.Statement[] = []; + const newStatements: ts.Statement[] = []; let judgeIdStart: number; if (idName) { judgeIdStart = innerCompStatements.length; @@ -1438,9 +1477,11 @@ function processTabAndNav(node: ts.ExpressionStatement, innerCompStatements: ts. ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression( ts.factory.createIdentifier(name), ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION)), undefined, navDestinationCallback)); + newStatements.push(tabContentCreation); bindComponentAttr(node, ts.factory.createIdentifier(name), tabAttrs, log, true, false, immutableStatements); + newStatements.push(...tabAttrs); processInnerCompStatements( - innerCompStatements, [tabContentCreation, ...tabAttrs], node, isGlobalBuilder, false, + innerCompStatements, newStatements, node, isGlobalBuilder, false, nameResult, immutableStatements, name, builderParamsResult); storedFileInfo.lazyForEachInfo.isDependItem = false; } else { @@ -1448,9 +1489,11 @@ function processTabAndNav(node: ts.ExpressionStatement, innerCompStatements: ts. ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(name), ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION)), undefined, name === NAV_DESTINATION ? navigationCreateParam(NAV_DESTINATION, COMPONENT_CREATE_FUNCTION) : [])); + newStatements.push(tabContentCreation); bindComponentAttr(node, ts.factory.createIdentifier(name), tabAttrs, log, true, false, immutableStatements); + newStatements.push(...tabAttrs); processInnerCompStatements( - innerCompStatements, [tabContentCreation, ...tabAttrs], node, isGlobalBuilder, false, + innerCompStatements, newStatements, node, isGlobalBuilder, false, nameResult, immutableStatements, name, builderParamsResult); } innerCompStatements.push(tabContentPop); @@ -1546,6 +1589,22 @@ function processForEachComponentNew(node: ts.ExpressionStatement, newStatements: newNode.expression.expression as ts.Identifier, ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION)), undefined, [])); const newForEachArrowFunc: ts.ArrowFunction = processForEachFunctionBlock(newNode.expression); + if (newForEachArrowFunc.parameters[0] && + (!isReuseArgument(argumentsArray[0]) || name == COMPONENT_LAZYFOREACH)) { + // set arguments of + let arrowFunctionArg = newForEachArrowFunc.parameters[0]; + if (ts.isIdentifier(arrowFunctionArg.name)) { + forEachPropMap.set(arrowFunctionArg.name.escapedText.toString(), "@State"); + } else if (ts.isObjectBindingPattern(arrowFunctionArg.name)) { + arrowFunctionArg.name.elements.forEach((element)=>{ + let varName = element.name as ts.Identifier; + forEachPropMap.set(varName.escapedText.toString(), "@State"); + }); + } else{ + console.log("invalid arrow function args in ForEach!"); + } + } + const newArrowNode: ts.NodeArray = processForEachBlock(newNode.expression, log, newForEachArrowFunc, false, isGlobalBuilder, builderParamsResult) as ts.NodeArray; @@ -1570,6 +1629,7 @@ function processForEachComponentNew(node: ts.ExpressionStatement, newStatements: } else { storedFileInfo.processLazyForEach -= 1; } + forEachPropMap.clear(); } } @@ -1989,6 +2049,7 @@ interface CreateResult { isContainerComponent: boolean; isButton: boolean; needPop: boolean; + isReusable: boolean; } function createComponent(node: ts.ExpressionStatement, type: string): CreateResult { @@ -1997,7 +2058,8 @@ function createComponent(node: ts.ExpressionStatement, type: string): CreateResu identifierNode: null, isContainerComponent: false, isButton: false, - needPop: false + needPop: false, + isReusable: false, }; let identifierNode: ts.Identifier = ts.factory.createIdentifier(type); let temp: any = node.expression; @@ -2080,6 +2142,71 @@ function isXComponentContainer(item: ts.PropertyAssignment): boolean { item.initializer.name.getText() === XCOMPONENTTYPE_CONTAINER); } +function isReuseArgument(argument : ts.Expression): boolean { + + const mayChangedAnnotation : Set = new Set([ + "@State", "@ObjectLink", "@Prop", "@Link", "@Provide", "@Consume", + "@LocalStorageLink", "@LocalStorageProp", "@StorageLink", "@StorageProp" + ]); + if(ts.isObjectLiteralExpression(argument)) { + let props = argument.properties; + for(let prop of props as ts.NodeArray) { + if(!isReuseArgument(prop.initializer)) { + return false; + } + } + } else if(ts.isPropertyAccessExpression(argument)) { + //@State this.value + if(argument.expression.kind == ts.SyntaxKind.ThisKeyword && + mayChangedAnnotation.has(curPropMap.get(argument.name.getText()))) { + return false; + } + // $$this.value $$.val + if(ts.isIdentifier(argument.expression) && [$$_THIS,$$].includes(argument.expression.getText()) ) { + return false; + } + // $$.val + if(ts.isIdentifier(argument.expression) && argument.expression.getText() == $$) { + return false; + } + // this.a.c + if(ts.isPropertyAccessExpression(argument.expression)) + return isReuseArgument(argument.expression); + } else if(ts.isBinaryExpression(argument)) { + return isReuseArgument(argument.left) && isReuseArgument(argument.right); + } else if(ts.isCallExpression(argument) || ts.isEtsComponentExpression(argument)) { + return argument.arguments.every((arg)=>{ return isReuseArgument(arg);}); + } else if(ts.isIdentifier(argument)) { + if (argument.escapedText.toString().match(/^\$\$(.|\n)+/)) { + //start with $$ + return false; + } + if (mayChangedAnnotation.has(forEachPropMap.get(argument.escapedText.toString()))) { + return false; + } + } else if(ts.isConditionalExpression(argument)) { + if(!(isReuseArgument(argument.condition) && isReuseArgument(argument.whenTrue) + && isReuseArgument(argument.whenFalse))) + return false; + } else if(ts.isParenthesizedExpression(argument)) { + return isReuseArgument(argument.expression); + } else if(ts.isArrayLiteralExpression(argument)) { + return argument.elements.every((elem)=>{ return isReuseArgument(elem); }); + } else if(ts.isTemplateExpression(argument)) { + return argument.templateSpans.every((span)=>{ return isReuseArgument(span.expression); }); + } + // todo: template + return true; +} + +export function isReuseStatement(statement : ts.ExpressionStatement): boolean { + let callExp = statement.expression; + if(!ts.isCallExpression(callExp)) { + return false; + } + return isReuseArgument(callExp); +} + interface AnimationInfo { statement: ts.Statement, kind: boolean, @@ -2105,6 +2232,7 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: kind: false, hasAnimationAttr: false }; + const complexAttrMap: Map = new Map(); const isRecycleComponent: boolean = isRecycle(componentCollection.currentClassName); if (ts.isPropertyAccessExpression(temp)) { log.push({ @@ -2139,9 +2267,14 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: temp.expression.name && ts.isIdentifier(temp.expression.name) && (!componentCollection.customComponents.has(temp.expression.name.getText()) || STYLES_ATTRIBUTE.has(temp.expression.name.getText()))) { parseRecycleId(temp, temp.expression.name, isRecycleComponent, componentAttrInfo); - addComponentAttr(temp, temp.expression.name, lastStatement, statements, identifierNode, log, - isStylesAttr, immutableStatements, updateStatements, newImmutableStatements, - isRecycleComponent, isStyleFunction); + if (isReuseMode() && HANDLE_COMPLEX_ATTRS.has(temp.expression.name.getText())) { + collectComplextComponentAttr(temp, complexAttrMap, identifierNode, statements, immutableStatements, updateStatements); + lastStatement.kind = true; + } else { + addComponentAttr(temp, temp.expression.name, lastStatement, statements, identifierNode, log, + isStylesAttr, immutableStatements, updateStatements, newImmutableStatements, + isRecycleComponent, isStyleFunction, complexAttrMap); + } temp = temp.expression.expression; flag = true; } else if (ts.isIdentifier(temp.expression)) { @@ -2149,9 +2282,14 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: !GESTURE_TYPE_NAMES.has(temp.expression.getText()) && !componentCollection.customComponents.has(temp.expression.getText())) { parseRecycleId(temp, temp.expression.name, isRecycleComponent, componentAttrInfo); - addComponentAttr(temp, temp.expression, lastStatement, statements, identifierNode, log, - isStylesAttr, immutableStatements, updateStatements, newImmutableStatements, - isRecycleComponent, isStyleFunction); + if (isReuseMode() && HANDLE_COMPLEX_ATTRS.has(temp.expression.getText())) { + collectComplextComponentAttr(temp, complexAttrMap, identifierNode, statements, immutableStatements, updateStatements); + lastStatement.kind = true; + } else { + addComponentAttr(temp, temp.expression, lastStatement, statements, identifierNode, log, + isStylesAttr, immutableStatements, updateStatements, newImmutableStatements, + isRecycleComponent, isStyleFunction, complexAttrMap); + } } break; } @@ -2159,10 +2297,22 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: temp = temp.expression; } } + + if (complexAttrMap.size) { + for (let [ _ , statement] of complexAttrMap.entries()) { + if (!statement) continue; + statements.push(statement); + if(isReuseStatement(statement)) + immutableStatements.push(statement); + else + updateStatements.push(statement); + } + } if (lastStatement.statement && lastStatement.kind) { statements.push(lastStatement.statement); } - if (!isRecycleComponent || lastStatement.hasAnimationAttr) { + + if (!isReuseMode() || lastStatement.hasAnimationAttr || !newImmutableStatements) { if (statements.length) { reverse ? newStatements.push(...statements.reverse()) : newStatements.push(...statements); } @@ -2630,11 +2780,43 @@ function verifyComponentId(temp: any, node: ts.Identifier, propName: string, } } +function createAttrFunction(node : ts.Identifier, name: string, argumentsArr : ts.Expression[]) { + return ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression(node, ts.factory.createIdentifier(name)), + undefined, + argumentsArr); +} + +function collectComplextComponentAttr(temp : ts.CallExpression, complexAttrMap: Map, + identifierNode: ts.Identifier, statements: ts.Statement[],immutableStatements: ts.Statement[], updateStatements: ts.Statement[]): void { + let expName : string; + if (ts.isPropertyAccessExpression(temp.expression)) { + expName = temp.expression.name.getText(); + } else if(ts.isIdentifier(temp.expression)) { + expName = temp.expression.getText(); + } + + let map = HANDLE_COMPLEX_ATTRS.get(expName); + for(let [propName, attrName] of map.entries()) { + const attrArgs : ts.Expression[] = []; + if (!complexAttrMap.has(attrName) && attrExpHasProp(temp, expName, propName, attrArgs)) { + const attrStatement: ts.ExpressionStatement = ts.factory.createExpressionStatement( + createAttrFunction(identifierNode, attrName, attrArgs)); + complexAttrMap.set(attrName, null); + statements.push(attrStatement); + if(isReuseStatement(attrStatement)) + immutableStatements.push(attrStatement); + else + updateStatements.push(attrStatement); + } + } +} + function addComponentAttr(temp, node: ts.Identifier, lastStatement, statements: ts.Statement[], identifierNode: ts.Identifier, log: LogInfo[], isStylesAttr: boolean, immutableStatements: ts.Statement[], updateStatements: ts.Statement[], newImmutableStatements: ts.Statement[] = null, isRecycleComponent: boolean = false, - isStyleFunction: boolean = false): void { + isStyleFunction: boolean = false, complexAttrMap: Map): void { const propName: string = node.getText(); verifyComponentId(temp, node, propName, log); const extendType: ExtendType = {type: ''}; @@ -2688,11 +2870,12 @@ function addComponentAttr(temp, node: ts.Identifier, lastStatement, } else if (propName === ATTRIBUTE_STATESTYLES) { if (temp.arguments.length === 1 && ts.isObjectLiteralExpression(temp.arguments[0])) { statements.push(createViewStackProcessor(temp, true)); - if (isRecycleComponent) { - updateStatements.push(createViewStackProcessor(temp, true)); - } + updateStatements.push(createViewStackProcessor(temp, true)); + + storedFileInfo.processStateStyles += 1; traverseStateStylesAttr(temp, statements, identifierNode, log, updateStatements, newImmutableStatements, isRecycleComponent); + storedFileInfo.processStateStyles -= 1; lastStatement.kind = true; } else { validateStateStyleSyntax(temp, log); @@ -2701,12 +2884,53 @@ function addComponentAttr(temp, node: ts.Identifier, lastStatement, const styleBlock: ts.Block = INNER_STYLE_FUNCTION.get(propName) || GLOBAL_STYLE_FUNCTION.get(propName); if (styleBlock.statements.length > 0) { + let styleBlockStatements : ts.Statement[] = []; + let styleBlockImmutableStatements: ts.Statement[] = []; bindComponentAttr(styleBlock.statements[0] as ts.ExpressionStatement, identifierNode, - statements, log, false, true, newImmutableStatements); - if (isRecycleComponent) { - bindComponentAttr(styleBlock.statements[0] as ts.ExpressionStatement, identifierNode, - updateStatements, log, false, true, newImmutableStatements, true); - } + styleBlockStatements, log, false, true, styleBlockImmutableStatements); + + styleBlockStatements.forEach((statement)=>{ + let expStatement = statement as ts.ExpressionStatement; + if(!ts.isCallExpression(expStatement.expression)) { + console.log("fuck! style function output is not a call?"); + } + let callExp = expStatement.expression as ts.CallExpression; + if(!ts.isPropertyAccessExpression(callExp.expression)){ + console.log("fuck! style function output is not a call wrap property access?"); + } + let propAccessExp = callExp.expression as ts.PropertyAccessExpression; + let compExp = propAccessExp.expression as ts.Identifier; + if(!complexAttrMap.has(propAccessExp.name.escapedText.toString()) + || compExp.escapedText.toString() != identifierNode.escapedText.toString()) { + statements.push(statement); + updateStatements.push(statement); + if(compExp.escapedText.toString() == identifierNode.escapedText.toString()) + complexAttrMap.set(propAccessExp.name.escapedText.toString(), null); + } + }); + styleBlockImmutableStatements.forEach((statement)=>{ + let expStatement = statement as ts.ExpressionStatement; + if(!ts.isCallExpression(expStatement.expression)) { + console.log("fuck! style function output is not a call?"); + } + let callExp = expStatement.expression as ts.CallExpression; + if(!ts.isPropertyAccessExpression(callExp.expression)){ + console.log("fuck! style function output is not a call wrap property access?"); + } + let propAccessExp = callExp.expression as ts.PropertyAccessExpression; + let compExp = propAccessExp.expression as ts.Identifier; + if(!complexAttrMap.has(propAccessExp.name.escapedText.toString()) + || compExp.escapedText.toString()!= identifierNode.escapedText.toString()) { + statements.push(statement) + newImmutableStatements.push(statement); + if(compExp.escapedText.toString() == identifierNode.escapedText.toString()) + complexAttrMap.set(propAccessExp.name.escapedText.toString(), null); + } + }); + // if (isRecycleComponent) { + // bindComponentAttr(styleBlock.statements[0] as ts.ExpressionStatement, identifierNode, + // updateStatements, log, false, true, newImmutableStatements, true); + // } } lastStatement.kind = true; } else if (isDoubleDollarToChange(isStylesAttr, identifierNode, propName, temp)) { @@ -2728,8 +2952,8 @@ function addComponentAttr(temp, node: ts.Identifier, lastStatement, const attrStatement: ts.Statement = ts.factory.createExpressionStatement( createFunction(identifierNode, node, temp.arguments, isAttributeModifier)); statements.push(attrStatement); - if (isRecycleComponent && (!isStylesAttr || isStyleFunction) && - !isGestureType(identifierNode) && filterRegularAttrNode(temp.arguments)) { + if ((isReuseStatement(attrStatement as ts.ExpressionStatement)||filterRegularAttrNode(temp.arguments)) + && !isGestureType(identifierNode)) { immutableStatements.push(attrStatement); } else { updateStatements.push(attrStatement); @@ -2899,30 +3123,24 @@ function traverseStateStylesAttr(temp, statements: ts.Statement[], const name: string = item.initializer.name.getText(); bindComponentAttr(INNER_STYLE_FUNCTION.get(name).statements[0] as ts.ExpressionStatement, identifierNode, statements, log, false, true, newImmutableStatements); - if (isRecycleComponent) { - bindComponentAttr(INNER_STYLE_FUNCTION.get(name).statements[0] as ts.ExpressionStatement, - identifierNode, updateStatements, log, false, true, newImmutableStatements); - } + bindComponentAttr(INNER_STYLE_FUNCTION.get(name).statements[0] as ts.ExpressionStatement, + identifierNode, updateStatements, log, false, true, newImmutableStatements); } else if (ts.isIdentifier(item.initializer) && GLOBAL_STYLE_FUNCTION.get(item.initializer.getText())) { const name: string = item.initializer.getText(); bindComponentAttr(GLOBAL_STYLE_FUNCTION.get(name).statements[0] as ts.ExpressionStatement, identifierNode, statements, log, false, true, newImmutableStatements); - if (isRecycleComponent) { - bindComponentAttr(GLOBAL_STYLE_FUNCTION.get(name).statements[0] as ts.ExpressionStatement, - identifierNode, updateStatements, log, false, true, newImmutableStatements); - } + bindComponentAttr(GLOBAL_STYLE_FUNCTION.get(name).statements[0] as ts.ExpressionStatement, + identifierNode, updateStatements, log, false, true, newImmutableStatements); } else if (ts.isObjectLiteralExpression(item.initializer) && item.initializer.properties.length === 1 && ts.isPropertyAssignment(item.initializer.properties[0])) { bindComponentAttr(ts.factory.createExpressionStatement( item.initializer.properties[0].initializer), identifierNode, statements, log, false, true, newImmutableStatements); - if (isRecycleComponent) { - bindComponentAttr(ts.factory.createExpressionStatement( - item.initializer.properties[0].initializer), identifierNode, updateStatements, log, false, true, - newImmutableStatements); - } + bindComponentAttr(ts.factory.createExpressionStatement( + item.initializer.properties[0].initializer), identifierNode, updateStatements, log, false, true, + newImmutableStatements); } else { if (!(ts.isObjectLiteralExpression(item.initializer) && item.initializer.properties.length === 0)) { validateStateStyleSyntax(temp, log); @@ -2931,9 +3149,7 @@ function traverseStateStylesAttr(temp, statements: ts.Statement[], if (item.name) { const viewNode: ts.Statement = createViewStackProcessor(item, false); statements.push(viewNode); - if (isRecycleComponent) { - updateStatements.push(viewNode); - } + updateStatements.push(viewNode); } }); } diff --git a/compiler/src/process_component_class.ts b/compiler/src/process_component_class.ts index 281c76b6c75406576ded4c24eb8c806226be64f9..92dcf7a4b77c7c169d44bef77315ab1e1b799001 100644 --- a/compiler/src/process_component_class.ts +++ b/compiler/src/process_component_class.ts @@ -197,6 +197,7 @@ function processMembers(members: ts.NodeArray, parentComponentN const purgeVariableDepStatements: ts.Statement[] = []; const rerenderStatements: ts.Statement[] = []; const deleteParamsStatements: ts.PropertyDeclaration[] = []; + const methodMembers: ts.MethodDeclaration[] = []; const checkController: ControllerType = { hasController: !componentCollection.customDialogs.has(parentComponentName.getText()) }; const interfaceNode = ts.factory.createInterfaceDeclaration(undefined, @@ -241,13 +242,20 @@ function processMembers(members: ts.NodeArray, parentComponentN } } if (ts.isMethodDeclaration(item) && item.name) { - updateItem = - processComponentMethod(item, context, log, buildCount); + methodMembers.push(item); } if (updateItem) { newMembers.push(updateItem); } }); + + methodMembers.forEach((item : ts.MethodDeclaration) => { + let updateItem: ts.ClassElement; + updateItem = processComponentMethod(item, context, log, buildCount); + if (updateItem) { + newMembers.push(updateItem); + } + }); INTERFACE_NODE_SET.add(interfaceNode); validateBuildMethodCount(buildCount, parentComponentName, log); validateHasController(parentComponentName, checkController, log); diff --git a/compiler/src/process_custom_component.ts b/compiler/src/process_custom_component.ts index a48707b959221f6db856957730967b51fabe6785..8612133d70ca57878843516c92a463697caa37dd 100644 --- a/compiler/src/process_custom_component.ts +++ b/compiler/src/process_custom_component.ts @@ -101,7 +101,8 @@ import { transferBuilderCall, createCollectElmtIdNode, createViewStackProcessorStatement, - BuilderParamsResult + BuilderParamsResult, + isReuseStatement } from './process_component_build'; import { partialUpdateConfig, @@ -167,15 +168,17 @@ export function processCustomComponent(node: ts.ExpressionStatement, newStatemen let needCommon: boolean = false; if (hasChainCall) { if (partialUpdateConfig.partialUpdateMode) { - const commomComponentNode: ts.Statement[] = [ts.factory.createExpressionStatement( + let createStatment = ts.factory.createExpressionStatement( createFunction(ts.factory.createIdentifier(COMPONENT_COMMON), - ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), null))]; + ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), null)); + const commomComponentNode: ts.Statement[] = []; const immutableStatements: ts.Statement[] = []; + commomComponentNode.push(createStatment); bindComponentAttr(node, ts.factory.createIdentifier(COMPONENT_COMMON), commomComponentNode, log, true, false, immutableStatements, false, componentAttrInfo); needCommon = commomComponentNode.length > 1 || immutableStatements.length > 0; if (componentAttrInfo.hasIdAttr && componentAttrInfo.attrCount === 1) { - commomComponentNode[0] = createCommonIdAttrNode(); + commomComponentNode[0] = createCommonIdAttrNode(); } if (needCommon) { newStatements.push(createComponentCreationStatement(componentAttributes(COMPONENT_COMMON), diff --git a/compiler/src/utils.ts b/compiler/src/utils.ts index 62b57588a5721bd7b2bea946399da99cfa0f9259..e482587818d55595800977817790b02dc8314d69 100644 --- a/compiler/src/utils.ts +++ b/compiler/src/utils.ts @@ -758,6 +758,7 @@ export class ProcessFileInfo { processForEach: number = 0; processLazyForEach: number = 0; processRepeat: boolean = false; + processStateStyles: number = 0; isAsPageImport: boolean = false; overallObjectLinkCollection: Map> = new Map(); overallLinkCollection: Map> = new Map(); diff --git a/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts b/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts index 05e616286891afc59561c18f484a6df05b3a89f8..4af2c44ab6c782b404100525fc9c078a7035e975 100644 --- a/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts +++ b/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts @@ -151,15 +151,19 @@ class CustomDialogUser extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.width('100%'); - Column.margin({ top: 5 }); + if (isInitialRender) { + Column.width('100%'); + Column.marginTop(5); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.inputValue); - Button.onClick(() => { - this.dialogController.open(); - }); - Button.backgroundColor(0x317aff); + if (isInitialRender) { + Button.onClick(() => { + this.dialogController.open(); + }); + Button.backgroundColor(0x317aff); + } }, Button); Button.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/import/import@Observed.ts b/compiler/test/utForPartialUpdate/import/import@Observed.ts index 6cb1a2e04e0e9cb198a70f301b771b6d3fbf57c0..e1fadb4ce931ba52dc9a6312fe536fb1bc5776c6 100644 --- a/compiler/test/utForPartialUpdate/import/import@Observed.ts +++ b/compiler/test/utForPartialUpdate/import/import@Observed.ts @@ -104,13 +104,17 @@ class ViewA extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.margin({ top: 10 }); + if (isInitialRender) { + Row.marginTop(10); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel('ViewA' + JSON.stringify(this.label) + 'this.a.c=' + JSON.stringify(this.a.c)); - Button.onClick(() => { - this.a.c += 1; - }); + if (isInitialRender) { + Button.onClick(() => { + this.a.c += 1; + }); + } }, Button); Button.pop(); Row.pop(); @@ -153,7 +157,9 @@ class ViewB extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.width('100%'); + if (isInitialRender) { + Column.width('100%'); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); @@ -225,26 +231,32 @@ class ViewB extends ViewPU { } this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel('ViewB: reset array'); - Button.margin({ top: 10 }); - Button.onClick(() => { - this.arrA = [new import_Observed_1.ClassB(0), new import_Observed_1.ClassB(0)]; - }); + if (isInitialRender) { + Button.marginTop(10); + Button.onClick(() => { + this.arrA = [new import_Observed_1.ClassB(0), new import_Observed_1.ClassB(0)]; + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel('ViewB: push'); - Button.margin({ top: 10 }); - Button.onClick(() => { - this.arrA.push(new import_Observed_1.ClassB(0)); - }); + if (isInitialRender) { + Button.marginTop(10); + Button.onClick(() => { + this.arrA.push(new import_Observed_1.ClassB(0)); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel('ViewB: shift'); - Button.margin({ top: 10 }); - Button.onClick(() => { - this.arrA.shift(); - }); + if (isInitialRender) { + Button.marginTop(10); + Button.onClick(() => { + this.arrA.shift(); + }); + } }, Button); Button.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/import/importAllEts.ts b/compiler/test/utForPartialUpdate/import/importAllEts.ts index c773c74d9469ad89dbd696436a8e455fee5838ba..9fc43af04f96b75aee32f288b0a8f635c69a17cf 100644 --- a/compiler/test/utForPartialUpdate/import/importAllEts.ts +++ b/compiler/test/utForPartialUpdate/import/importAllEts.ts @@ -202,7 +202,9 @@ class ImportTest extends ViewPU { } this.observeComponentCreation2((elmtId, isInitialRender) => { __Common__.create(); - __Common__.width(100); + if (isInitialRender) { + __Common__.width(100); + } }, __Common__); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -265,7 +267,9 @@ class ImportTest extends ViewPU { } this.observeComponentCreation2((elmtId, isInitialRender) => { __Common__.create(); - __Common__.height(200); + if (isInitialRender) { + __Common__.height(200); + } }, __Common__); { this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/import/importEts.ts b/compiler/test/utForPartialUpdate/import/importEts.ts index 8f49623403309e9c518243aedce4cc1f1f6f6311..c0617a48ba364e1491cba1c66fd9a4f4822139b5 100644 --- a/compiler/test/utForPartialUpdate/import/importEts.ts +++ b/compiler/test/utForPartialUpdate/import/importEts.ts @@ -240,8 +240,10 @@ class ImportTest extends ViewPU { } this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('space'); - Text.fontSize(20); - Text.fontColor(Color.Red); + if (isInitialRender) { + Text.fontSize(20); + Text.fontColor(Color.Red); + } }, Text); Text.pop(); { diff --git a/compiler/test/utForPartialUpdate/import/importExportNest.ts b/compiler/test/utForPartialUpdate/import/importExportNest.ts index e78eef6dc36d39063693ba8f0b69902df82daa9b..ea729a34377c5ee87a2e612e3af7d2d7cd975a1e 100644 --- a/compiler/test/utForPartialUpdate/import/importExportNest.ts +++ b/compiler/test/utForPartialUpdate/import/importExportNest.ts @@ -195,7 +195,9 @@ class ImportTest extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.testText1); - Text.fontSize(50); + if (isInitialRender) { + Text.fontSize(50); + } }, Text); Text.pop(); ImportNestAll_1.tExtend.bind(this)(20); @@ -210,7 +212,9 @@ class ImportTest extends ViewPU { Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.testText4); - Text.fontSize(50); + if (isInitialRender) { + Text.fontSize(50); + } }, Text); Text.pop(); { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_component.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_component.ts index 1aa178f8741457c92d16c9375535f041d94906d8..c48658a46444f44979bbb9235c5d9b208eae08c4 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_component.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_component.ts @@ -140,7 +140,9 @@ class HomeComponent extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.height(500); + if (isInitialRender) { + Column.height(500); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); @@ -156,13 +158,17 @@ class HomeComponent extends ViewPU { Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.width(20); + if (isInitialRender) { + Row.width(20); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithChild(); Button.bindPopup({ value: this.value4, changeEvent: newValue => { this.value4 = newValue; } }, { message: "This is $$ for regular" }); - Button.width(100); - Button.height(20); + if (isInitialRender) { + Button.width(100); + Button.height(20); + } }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.value1); @@ -172,8 +178,10 @@ class HomeComponent extends ViewPU { Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.value2); - Text.fontSize(100); Text.bindPopup({ value: value6.item1, changeEvent: newValue => { value6.item1 = newValue; } }, { message: "This is $$ for Obj" }); + if (isInitialRender) { + Text.fontSize(100); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -195,23 +203,29 @@ class HomeComponent extends ViewPU { TextTimer.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel("start"); - Button.onClick(() => { - this.myTimeController.start(); - }); + if (isInitialRender) { + Button.onClick(() => { + this.myTimeController.start(); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel("pause"); - Button.onClick(() => { - this.myTimeController.pause(); - }); + if (isInitialRender) { + Button.onClick(() => { + this.myTimeController.pause(); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel("reset"); - Button.onClick(() => { - this.myTimeController.reset(); - }); + if (isInitialRender) { + Button.onClick(() => { + this.myTimeController.reset(); + }); + } }, Button); Button.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts index de9e61b49d3c6d22dca1e6909a83a6b5b154a29a..41481290d0a6026b2ee5de6a1430603909eed200 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts @@ -147,76 +147,76 @@ class TabsExample extends ViewPU { tabBuilder(index, name, parent = null) { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.width('100%'); + if (isInitialRender) { + Column.width('100%'); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(name); Text.fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor); - Text.fontSize(16); Text.fontWeight(this.currentIndex === index ? 500 : 400); - Text.lineHeight(22); - Text.margin({ top: 17, bottom: 7 }); + if (isInitialRender) { + Text.fontSize(16); + Text.lineHeight(22); + Text.marginBottom(7); + Text.marginTop(17); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Divider.create(); - Divider.strokeWidth(2); - Divider.color('#007DFF'); Divider.opacity(this.currentIndex === index ? 1 : 0); + if (isInitialRender) { + Divider.strokeWidth(2); + Divider.color('#007DFF'); + } }, Divider); Column.pop(); } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.width('100%'); + if (isInitialRender) { + Column.width('100%'); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Tabs.create({ barPosition: BarPosition.Start, index: { value: this.currentIndex, changeEvent: newValue => { this.currentIndex = newValue; } }, controller: this.controller }); - Tabs.vertical(false); - Tabs.width(150); - Tabs.height(100); - Tabs.backgroundColor(Color.Pink); - Tabs.width(150); - Tabs.height(100); - Tabs.backgroundColor(Color.Pink); - Tabs.barMode(BarMode.Fixed); - Tabs.barWidth(360); - Tabs.barHeight(56); - Tabs.animationDuration(400); - Tabs.onChange((index) => { - this.currentIndex = index; - }); - Tabs.width(360); - Tabs.height(296); - Tabs.margin({ top: 52 }); - Tabs.backgroundColor('#F1F3F5'); + if (isInitialRender) { + Tabs.vertical(false); + Tabs.barMode(BarMode.Fixed); + Tabs.barWidth(360); + Tabs.barHeight(56); + Tabs.animationDuration(400); + Tabs.onChange((index) => { + this.currentIndex = index; + }); + Tabs.width(360); + Tabs.height(296); + Tabs.marginTop(52); + Tabs.backgroundColor('#F1F3F5'); + } }, Tabs); this.observeComponentCreation2((elmtId, isInitialRender) => { TabContent.create(() => { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.width('100%'); - Column.height('100%'); - Column.backgroundColor('#00CB87'); - Column.width(150); - Column.height(100); - Column.backgroundColor(Color.Pink); - Column.width(150); - Column.height(100); - Column.backgroundColor(Color.Pink); + if (isInitialRender) { + Column.backgroundColor(Color.Pink); + Column.height(100); + Column.width(150); + } }, Column); Column.pop(); }); - TabContent.tabBar({ builder: () => { - this.tabBuilder.call(this, 0, 'green'); - } }); - TabContent.width(150); - TabContent.height(100); - TabContent.backgroundColor(Color.Pink); - TabContent.width(150); - TabContent.height(100); - TabContent.backgroundColor(Color.Pink); + if (isInitialRender) { + TabContent.backgroundColor(Color.Pink); + TabContent.height(100); + TabContent.width(150); + TabContent.tabBar({ builder: () => { + this.tabBuilder.call(this, 0, 'green'); + } }); + } }, TabContent); TabContent.pop(); Tabs.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck2.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck2.ts index 54c737cef4f24ad3cba30e8183ee0f101b26902c..1e03c3eed198fb7f6f616a1b3179ffcf905aec7a 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck2.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck2.ts @@ -85,9 +85,11 @@ class TextInputExample extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create({ space: 20 }); - Column.width('100%'); - Column.height('100%'); - Column.justifyContent(FlexAlign.Center); + if (isInitialRender) { + Column.width('100%'); + Column.height('100%'); + Column.justifyContent(FlexAlign.Center); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.text); @@ -95,16 +97,14 @@ class TextInputExample extends ViewPU { Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { TextInput.create({ text: { value: this.text, changeEvent: newValue => { this.text = newValue; } } }); - TextInput.placeholderColor(Color.Grey); - TextInput.placeholderFont({ size: 14, weight: 400 }); - TextInput.width(150); - TextInput.height(100); - TextInput.backgroundColor(Color.Pink); - TextInput.width(150); - TextInput.height(100); - TextInput.backgroundColor(Color.Pink); - TextInput.caretColor(Color.Blue); - TextInput.width(300); + if (isInitialRender) { + TextInput.backgroundColor(Color.Pink); + TextInput.height(100); + TextInput.placeholderColor(Color.Grey); + TextInput.placeholderFont({ size: 14, weight: 400 }); + TextInput.caretColor(Color.Blue); + TextInput.width(300); + } }, TextInput); Column.pop(); } diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck3.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck3.ts index 39c763f5d076f24da222da40ff0bf4bd843943a6..9dbab4ebd358d7506ac66f082effa1338c85ea3c 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck3.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck3.ts @@ -102,20 +102,17 @@ class Index extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Checkbox.create(); Checkbox.select(this.applyToAll, newValue => { this.applyToAll = newValue; }); - Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); - Checkbox.selectedColor('red'); - Checkbox.unselectedColor('red'); - Checkbox.width(150); - Checkbox.height(100); - Checkbox.backgroundColor(Color.Pink); - Checkbox.width(150); - Checkbox.height(100); - Checkbox.backgroundColor(Color.Pink); - Checkbox.mark({ - strokeColor: 'red' - }); - Checkbox.width(30); - Checkbox.height(30); + if (isInitialRender) { + Checkbox.backgroundColor(Color.Pink); + Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); + Checkbox.selectedColor('red'); + Checkbox.unselectedColor('red'); + Checkbox.mark({ + strokeColor: 'red' + }); + Checkbox.width(30); + Checkbox.height(30); + } }, Checkbox); Checkbox.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck4.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck4.ts index 74169c7a60c0e9df30d162ed8f0ba327908fa8f6..4f6ccf270f0c694c9e62c4f0666362f393c56ac1 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck4.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck4.ts @@ -101,20 +101,17 @@ class Index extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Checkbox.create(); Checkbox.select(this.applyToAll, newValue => { this.applyToAll = newValue; }); - Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); - Checkbox.selectedColor('red'); - Checkbox.unselectedColor('red'); - Checkbox.width(150); - Checkbox.height(100); - Checkbox.backgroundColor(Color.Pink); - Checkbox.width(150); - Checkbox.height(100); - Checkbox.backgroundColor(Color.Pink); - Checkbox.mark({ - strokeColor: 'red' - }); - Checkbox.width(30); - Checkbox.height(30); + if (isInitialRender) { + Checkbox.backgroundColor(Color.Pink); + Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); + Checkbox.selectedColor('red'); + Checkbox.unselectedColor('red'); + Checkbox.mark({ + strokeColor: 'red' + }); + Checkbox.width(30); + Checkbox.height(30); + } }, Checkbox); Checkbox.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck5.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck5.ts index a87333c3d742f5520281531d3138a0dcb1861e72..5b51e44c15f1e8e511e68208f6fbea44e4068211 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck5.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck5.ts @@ -85,9 +85,11 @@ class TextInputExample extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create({ space: 20 }); - Column.width('100%'); - Column.height('100%'); - Column.justifyContent(FlexAlign.Center); + if (isInitialRender) { + Column.width('100%'); + Column.height('100%'); + Column.justifyContent(FlexAlign.Center); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.text); @@ -95,16 +97,14 @@ class TextInputExample extends ViewPU { Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { TextInput.create({ text: { value: this.text, changeEvent: newValue => { this.text = newValue; } } }); - TextInput.placeholderColor(Color.Grey); - TextInput.placeholderFont({ size: 14, weight: 400 }); - TextInput.width(150); - TextInput.height(100); - TextInput.backgroundColor(Color.Pink); - TextInput.width(150); - TextInput.height(100); - TextInput.backgroundColor(Color.Pink); - TextInput.caretColor(Color.Blue); - TextInput.width(300); + if (isInitialRender) { + TextInput.backgroundColor(Color.Pink); + TextInput.height(100); + TextInput.placeholderColor(Color.Grey); + TextInput.placeholderFont({ size: 14, weight: 400 }); + TextInput.caretColor(Color.Blue); + TextInput.width(300); + } }, TextInput); Column.pop(); } diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck6.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck6.ts index 57c813d603320bd66004f8ad5b22938c72690d92..bdf0673d4f735992bc2e8db99f63a63affacd452 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck6.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck6.ts @@ -147,76 +147,76 @@ class TabsExample extends ViewPU { tabBuilder(index, name, parent = null) { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.width('100%'); + if (isInitialRender) { + Column.width('100%'); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(name); Text.fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor); - Text.fontSize(16); Text.fontWeight(this.currentIndex === index ? 500 : 400); - Text.lineHeight(22); - Text.margin({ top: 17, bottom: 7 }); + if (isInitialRender) { + Text.fontSize(16); + Text.lineHeight(22); + Text.marginBottom(7); + Text.marginTop(17); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Divider.create(); - Divider.strokeWidth(2); - Divider.color('#007DFF'); Divider.opacity(this.currentIndex === index ? 1 : 0); + if (isInitialRender) { + Divider.strokeWidth(2); + Divider.color('#007DFF'); + } }, Divider); Column.pop(); } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.width('100%'); + if (isInitialRender) { + Column.width('100%'); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Tabs.create({ barPosition: BarPosition.Start, index: { value: this.currentIndex, changeEvent: newValue => { this.currentIndex = newValue; } }, controller: this.controller }); - Tabs.vertical(false); - Tabs.width(150); - Tabs.height(100); - Tabs.backgroundColor(Color.Pink); - Tabs.width(150); - Tabs.height(100); - Tabs.backgroundColor(Color.Pink); - Tabs.barMode(BarMode.Fixed); - Tabs.barWidth(360); - Tabs.barHeight(56); - Tabs.animationDuration(400); - Tabs.onChange((index) => { - this.currentIndex = index; - }); - Tabs.width(360); - Tabs.height(296); - Tabs.margin({ top: 52 }); - Tabs.backgroundColor('#F1F3F5'); + if (isInitialRender) { + Tabs.vertical(false); + Tabs.barMode(BarMode.Fixed); + Tabs.barWidth(360); + Tabs.barHeight(56); + Tabs.animationDuration(400); + Tabs.onChange((index) => { + this.currentIndex = index; + }); + Tabs.width(360); + Tabs.height(296); + Tabs.marginTop(52); + Tabs.backgroundColor('#F1F3F5'); + } }, Tabs); this.observeComponentCreation2((elmtId, isInitialRender) => { TabContent.create(() => { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.width('100%'); - Column.height('100%'); - Column.backgroundColor('#00CB87'); - Column.width(150); - Column.height(100); - Column.backgroundColor(Color.Pink); - Column.width(150); - Column.height(100); - Column.backgroundColor(Color.Pink); + if (isInitialRender) { + Column.backgroundColor(Color.Pink); + Column.height(100); + Column.width(150); + } }, Column); Column.pop(); }); - TabContent.tabBar({ builder: () => { - this.tabBuilder.call(this, 0, 'green'); - } }); - TabContent.width(150); - TabContent.height(100); - TabContent.backgroundColor(Color.Pink); - TabContent.width(150); - TabContent.height(100); - TabContent.backgroundColor(Color.Pink); + if (isInitialRender) { + TabContent.backgroundColor(Color.Pink); + TabContent.height(100); + TabContent.width(150); + TabContent.tabBar({ builder: () => { + this.tabBuilder.call(this, 0, 'green'); + } }); + } }, TabContent); TabContent.pop(); Tabs.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck7.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck7.ts index 5a1b066b0798eb0b11279f22a8b55854ead41bcc..fef668ad78fe4e9110b45840f7d89b3996b8d0e3 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck7.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck7.ts @@ -130,23 +130,20 @@ class Index extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Checkbox.create(); Checkbox.select(this.applyToAll, newValue => { this.applyToAll = newValue; }); - Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); - Checkbox.selectedColor(xx()); - Checkbox.unselectedColor(bb().cc); - Checkbox.mark({ - strokeColor: aa() - }); - Checkbox.width(150); - Checkbox.height(100); - Checkbox.backgroundColor(Color.Pink); - Checkbox.width(150); - Checkbox.height(100); - Checkbox.backgroundColor(Color.Pink); - Checkbox.mark({ - strokeColor: 'red' - }); - Checkbox.width(dd().ee); - Checkbox.height(30); + if (isInitialRender) { + Checkbox.backgroundColor(Color.Pink); + Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); + Checkbox.selectedColor(xx()); + Checkbox.unselectedColor(bb().cc); + Checkbox.mark({ + strokeColor: aa() + }); + Checkbox.mark({ + strokeColor: 'red' + }); + Checkbox.width(dd().ee); + Checkbox.height(30); + } }, Checkbox); Checkbox.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck8.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck8.ts index 5a1b066b0798eb0b11279f22a8b55854ead41bcc..fef668ad78fe4e9110b45840f7d89b3996b8d0e3 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck8.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck8.ts @@ -130,23 +130,20 @@ class Index extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Checkbox.create(); Checkbox.select(this.applyToAll, newValue => { this.applyToAll = newValue; }); - Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); - Checkbox.selectedColor(xx()); - Checkbox.unselectedColor(bb().cc); - Checkbox.mark({ - strokeColor: aa() - }); - Checkbox.width(150); - Checkbox.height(100); - Checkbox.backgroundColor(Color.Pink); - Checkbox.width(150); - Checkbox.height(100); - Checkbox.backgroundColor(Color.Pink); - Checkbox.mark({ - strokeColor: 'red' - }); - Checkbox.width(dd().ee); - Checkbox.height(30); + if (isInitialRender) { + Checkbox.backgroundColor(Color.Pink); + Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); + Checkbox.selectedColor(xx()); + Checkbox.unselectedColor(bb().cc); + Checkbox.mark({ + strokeColor: aa() + }); + Checkbox.mark({ + strokeColor: 'red' + }); + Checkbox.width(dd().ee); + Checkbox.height(30); + } }, Checkbox); Checkbox.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck9.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck9.ts index e5d063316496590333c2fadaeff645680c8e12fe..d95ed6be0890d1c574033a1d25bb3bc23884c383 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck9.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck9.ts @@ -112,7 +112,9 @@ class SheetSizeExample1 extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.justifyContent(FlexAlign.Start); + if (isInitialRender) { + Column.justifyContent(FlexAlign.Start); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel("transition modal 1"); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/custom_component/custom_component.ts b/compiler/test/utForPartialUpdate/inner_component_transform/custom_component/custom_component.ts index 38b6280a0319f9d26f5af59705a0b430efc8fa05..48ffa4dda11233473ed76773b35e5fb6c0c3e34f 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/custom_component/custom_component.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/custom_component/custom_component.ts @@ -90,7 +90,9 @@ class MyComponent extends ViewPU { } this.observeComponentCreation2((elmtId, isInitialRender) => { __Common__.create(); - __Common__.width(100); + if (isInitialRender) { + __Common__.width(100); + } }, __Common__); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -110,8 +112,10 @@ class MyComponent extends ViewPU { __Common__.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { __Common__.create(); - __Common__.width(100); - __Common__.height(200); + if (isInitialRender) { + __Common__.width(100); + __Common__.height(200); + } }, __Common__); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -148,7 +152,9 @@ class MyComponent extends ViewPU { } this.observeComponentCreation2((elmtId, isInitialRender) => { __Common__.create(); - __Common__.width(100); + if (isInitialRender) { + __Common__.width(100); + } }, __Common__); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -170,8 +176,10 @@ class MyComponent extends ViewPU { __Common__.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { __Common__.create(); - __Common__.width(100); - __Common__.height(200); + if (isInitialRender) { + __Common__.width(100); + __Common__.height(200); + } }, __Common__); { this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/longPressGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/longPressGesture.ts index e5e70abfe83039ae6ae0d8fa83599f9f41decbbe..ced2ffbe7e228a7184fbaba9ea78f3950d1e2ffe 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/longPressGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/longPressGesture.ts @@ -75,11 +75,6 @@ class LongPressGestureExample extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); - Flex.height(200); - Flex.width(300); - Flex.padding(60); - Flex.border({ width: 1 }); - Flex.margin(30); Gesture.create(GesturePriority.Low); LongPressGesture.create({ repeat: true }); LongPressGesture.onAction((event) => { @@ -92,6 +87,19 @@ class LongPressGestureExample extends ViewPU { }); LongPressGesture.pop(); Gesture.pop(); + if (isInitialRender) { + Flex.height(200); + Flex.width(300); + Flex.paddingBottom(60); + Flex.paddingTop(60); + Flex.paddingRight(60); + Flex.paddingLeft(60); + Flex.borderWidth(1); + Flex.marginBottom(30); + Flex.marginTop(30); + Flex.marginRight(30); + Flex.marginLeft(30); + } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('LongPress onAction:' + this.count); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/panGestrue.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/panGestrue.ts index b42ca935e148e57e083b55dc0c92e87ceab60ccf..39798abbeb72e15957d04aade3750f6c53e04eaf 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/panGestrue.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/panGestrue.ts @@ -95,11 +95,6 @@ class PanGestureExample extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); - Flex.height(100); - Flex.width(200); - Flex.padding(20); - Flex.border({ width: 1 }); - Flex.margin(80); Flex.translate({ x: this.offsetX, y: this.offsetY, z: 5 }); Gesture.create(GesturePriority.Low); PanGesture.create({}); @@ -115,6 +110,19 @@ class PanGestureExample extends ViewPU { }); PanGesture.pop(); Gesture.pop(); + if (isInitialRender) { + Flex.height(100); + Flex.width(200); + Flex.paddingBottom(20); + Flex.paddingTop(20); + Flex.paddingRight(20); + Flex.paddingLeft(20); + Flex.borderWidth(1); + Flex.marginBottom(80); + Flex.marginTop(80); + Flex.marginRight(80); + Flex.marginLeft(80); + } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('PanGesture offset X: ' + this.offsetX); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/pinchGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/pinchGesture.ts index 57a22fae59111d6b1bc74d704b8f6639407e1b39..7b24b5c5cba490a77749d09a7f2c1b3aa3a9f8b9 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/pinchGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/pinchGesture.ts @@ -79,11 +79,6 @@ class PinchGestureExample extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); - Flex.height(100); - Flex.width(200); - Flex.padding(20); - Flex.border({ width: 1 }); - Flex.margin(80); Flex.scale({ x: this.scale2, y: this.scale2, z: this.scale2 }); Gesture.create(GesturePriority.Low); PinchGesture.create(); @@ -98,6 +93,19 @@ class PinchGestureExample extends ViewPU { }); PinchGesture.pop(); Gesture.pop(); + if (isInitialRender) { + Flex.height(100); + Flex.width(200); + Flex.paddingBottom(20); + Flex.paddingTop(20); + Flex.paddingRight(20); + Flex.paddingLeft(20); + Flex.borderWidth(1); + Flex.marginBottom(80); + Flex.marginTop(80); + Flex.marginRight(80); + Flex.marginLeft(80); + } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('PinchGesture scale:' + this.scale2); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/rotationGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/rotationGesture.ts index 41b224b56388ac926637fc05f7734718766da4a1..193712e862e11ca2e764e6cea45df3300df56742 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/rotationGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/rotationGesture.ts @@ -79,11 +79,6 @@ class RotationGestureExample extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); - Flex.height(100); - Flex.width(200); - Flex.padding(20); - Flex.border({ width: 1 }); - Flex.margin(80); Flex.rotate({ x: 1, y: 2, z: 3, angle: this.angle }); Gesture.create(GesturePriority.Low); RotationGesture.create(); @@ -98,6 +93,19 @@ class RotationGestureExample extends ViewPU { }); RotationGesture.pop(); Gesture.pop(); + if (isInitialRender) { + Flex.height(100); + Flex.width(200); + Flex.paddingBottom(20); + Flex.paddingTop(20); + Flex.paddingRight(20); + Flex.paddingLeft(20); + Flex.borderWidth(1); + Flex.marginBottom(80); + Flex.marginTop(80); + Flex.marginRight(80); + Flex.marginLeft(80); + } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('RotationGesture angle:' + this.angle); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/swipeGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/swipeGesture.ts index c2fe439a465bbd8647806b9fef30f2419015fd4c..c662ff6fdbb4bedaf2af841976fc616ea72e3d9c 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/swipeGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/swipeGesture.ts @@ -89,9 +89,6 @@ class SwipeGestureExample extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.border({ width: 2 }); - Column.width(260); - Column.height(260); Column.rotate({ x: 0, y: 0, z: 1, angle: this.rotateAngle }); Gesture.create(GesturePriority.Low); SwipeGesture.create({ fingers: 1, direction: SwipeDirection.Vertical }); @@ -101,6 +98,11 @@ class SwipeGestureExample extends ViewPU { }); SwipeGesture.pop(); Gesture.pop(); + if (isInitialRender) { + Column.borderWidth(2); + Column.width(260); + Column.height(260); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("SwipGesture speed : " + this.speed); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/tapGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/tapGesture.ts index be082149e6b7f27432cc498c442ebb742423e235..48208f39f6367deb1d1a2a17b432dac1fb7ee14d 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/tapGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/tapGesture.ts @@ -73,11 +73,6 @@ class TapGestureExample extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); - Flex.height(200); - Flex.width(300); - Flex.padding(60); - Flex.border({ width: 1 }); - Flex.margin(30); Gesture.create(GesturePriority.Low); TapGesture.create({ count: 2 }); TapGesture.onAction(() => { @@ -85,6 +80,19 @@ class TapGestureExample extends ViewPU { }); TapGesture.pop(); Gesture.pop(); + if (isInitialRender) { + Flex.height(200); + Flex.width(300); + Flex.paddingBottom(60); + Flex.paddingTop(60); + Flex.paddingRight(60); + Flex.paddingLeft(60); + Flex.borderWidth(1); + Flex.marginBottom(30); + Flex.marginTop(30); + Flex.marginRight(30); + Flex.marginLeft(30); + } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('Click twice'); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachSecondFunction.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachSecondFunction.ts index 49aaa968c0b6c4c32ecb9c05c8288ef03cdba93c..10ac9aae770a16ed6ee18586000b2cd2a6884385 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachSecondFunction.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachSecondFunction.ts @@ -71,14 +71,18 @@ class MyComponent extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create({ space: 5 }); - Column.width("100%"); - Column.height("100%"); + if (isInitialRender) { + Column.width("100%"); + Column.height("100%"); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel('Reverse Array'); - Button.onClick(() => { - this.arr.reverse(); - }); + if (isInitialRender) { + Button.onClick(() => { + this.arr.reverse(); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -87,12 +91,16 @@ class MyComponent extends ViewPU { const item = _item; this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('item'); - Text.fontSize(18); + if (isInitialRender) { + Text.fontSize(18); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Divider.create(); - Divider.strokeWidth(2); + if (isInitialRender) { + Divider.strokeWidth(2); + } }, Divider); }; this.forEachUpdateFunction(elmtId, this.arr, forEachItemGenFunction, (item) => item.toString(), false, false); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachTwo.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachTwo.ts index 2631ef098b7144efe176a373380663411789dec4..9edee32dbf3ad65f59f5abfa6ad96dde47152a0d 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachTwo.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachTwo.ts @@ -84,11 +84,15 @@ class Index extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.height('100%'); + if (isInitialRender) { + Row.height('100%'); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.width('100%'); + if (isInitialRender) { + Column.width('100%'); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts index c03aab1c2a78d79432ec413b6e102d88414661a8..dc5581721259ca9647ca974d9a3e85ba208e51b7 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts @@ -160,8 +160,10 @@ class MyComponent extends ViewPU { if (!If.canRetake('id1')) { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('count is negative'); - Text.fontSize(32); - Text.id('id1'); + if (isInitialRender) { + Text.fontSize(32); + Text.id('id1'); + } }, Text); Text.pop(); } @@ -172,14 +174,18 @@ class MyComponent extends ViewPU { if (!If.canRetake('id2')) { this.observeComponentCreation2((elmtId, isInitialRender) => { Divider.create(); - Divider.id('id2'); + if (isInitialRender) { + Divider.id('id2'); + } }, Divider); } if (!If.canRetake('id3')) { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('even'); - Text.fontSize(32); - Text.id('id3'); + if (isInitialRender) { + Text.fontSize(32); + Text.id('id3'); + } }, Text); Text.pop(); } @@ -190,18 +196,24 @@ class MyComponent extends ViewPU { if (!If.canRetake('id4')) { this.observeComponentCreation2((elmtId, isInitialRender) => { Divider.create(); - Divider.id('id4'); + if (isInitialRender) { + Divider.id('id4'); + } }, Divider); } if (!If.canRetake('id10')) { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.id('id10'); + if (isInitialRender) { + Column.id('id10'); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('odd'); - Text.fontSize(32); - Text.id('id5'); + if (isInitialRender) { + Text.fontSize(32); + Text.id('id5'); + } }, Text); Text.pop(); Column.pop(); @@ -217,8 +229,10 @@ class MyComponent extends ViewPU { if (!If.canRetake('id6')) { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('fail'); - Text.id('id6'); - Text.fontSize(32); + if (isInitialRender) { + Text.id('id6'); + Text.fontSize(32); + } }, Text); Text.pop(); } @@ -233,8 +247,10 @@ class MyComponent extends ViewPU { if (!If.canRetake('id7')) { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('odd2'); - Text.fontSize(32); - Text.id('id7'); + if (isInitialRender) { + Text.fontSize(32); + Text.id('id7'); + } }, Text); Text.pop(); } @@ -265,19 +281,26 @@ class MyComponent extends ViewPU { }; const itemCreation2 = (elmtId, isInitialRender) => { ListItem.create(deepRenderFunction, true); - ListItem.id('id8'); + if (isInitialRender) { + ListItem.id('id8'); + } }; const deepRenderFunction = (elmtId, isInitialRender) => { itemCreation(elmtId, isInitialRender); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.margin({ left: 10, right: 10 }); - Row.id('id11'); + if (isInitialRender) { + Row.marginRight(10); + Row.marginLeft(10); + Row.id('id11'); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(); - Text.fontSize(20); - Text.margin({ left: 10 }); + if (isInitialRender) { + Text.fontSize(20); + Text.marginLeft(10); + } }, Text); Text.pop(); Row.pop(); @@ -308,14 +331,18 @@ class MyComponent extends ViewPU { TabContent.create(() => { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('111'); - Text.width('100%'); - Text.height('20'); - Text.backgroundColor(Color.Pink); + if (isInitialRender) { + Text.width('100%'); + Text.height('20'); + Text.backgroundColor(Color.Pink); + } }, Text); Text.pop(); }); - TabContent.tabBar('pink'); - TabContent.id('id9'); + if (isInitialRender) { + TabContent.tabBar('pink'); + TabContent.id('id9'); + } }, TabContent); TabContent.pop(); } @@ -347,13 +374,17 @@ class MyComponent extends ViewPU { if (!If.canRetake('id12')) { this.observeComponentCreation2((elmtId, isInitialRender) => { XComponent.create({ id: 'special', type: '' }); - XComponent.id('id12'); + if (isInitialRender) { + XComponent.id('id12'); + } }, XComponent); } if (!If.canRetake('id13')) { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.id('id13'); + if (isInitialRender) { + Column.id('id13'); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('11'); @@ -392,7 +423,9 @@ class MyComponent extends ViewPU { if (!If.canRetake('id14')) { this.observeComponentCreation2((elmtId, isInitialRender) => { __Common__.create(true); - __Common__.id('id14'); + if (isInitialRender) { + __Common__.id('id14'); + } }, __Common__); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -454,7 +487,9 @@ class Child extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('Child'); - Text.fontSize(50); + if (isInitialRender) { + Text.fontSize(50); + } }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/GridItem.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/GridItem.ts index 5eba7135442d92092b22786eee1b256724b98c9c..83df16b5336ff2aea998b814114f088b3e7fb4f3 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/GridItem.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/GridItem.ts @@ -57,14 +57,18 @@ class ParentView extends ViewPU { { const itemCreation2 = (elmtId, isInitialRender) => { GridItem.create(() => { }, false, 'true'); - GridItem.width(200); - GridItem.height(100); + if (isInitialRender) { + GridItem.width(200); + GridItem.height(100); + } }; const observedDeepRender = () => { this.observeComponentCreation2(itemCreation2, GridItem); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('xx'); - Text.width(100); + if (isInitialRender) { + Text.width(100); + } }, Text); Text.pop(); GridItem.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/ListItem.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/ListItem.ts index 67520dff14665ffa45d02e81e8229b73b86c7519..81ee833dc41b46b2867dae1e197e35c01b1da24f 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/ListItem.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/ListItem.ts @@ -65,14 +65,18 @@ class ParentView extends ViewPU { }; const itemCreation2 = (elmtId, isInitialRender) => { ListItem.create(deepRenderFunction, true, 'true'); - ListItem.width(200); - ListItem.height(100); + if (isInitialRender) { + ListItem.width(200); + ListItem.height(100); + } }; const deepRenderFunction = (elmtId, isInitialRender) => { itemCreation(elmtId, isInitialRender); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('xx'); - Text.width(100); + if (isInitialRender) { + Text.width(100); + } }, Text); Text.pop(); ListItem.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam.ts index 70547fc093056fbb3e8ca72b2a3615aa742a6067..940e8cbeb1c638084e5747e5ca1aba79671edbeb 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam.ts @@ -257,7 +257,9 @@ class lazyforEachThreeParam extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { List.create({ space: 3 }); - List.cachedCount(5); + if (isInitialRender) { + List.cachedCount(5); + } }, List); { const __lazyForEachItemGenFunction = _item => { @@ -270,14 +272,19 @@ class lazyforEachThreeParam extends ViewPU { this.observeComponentCreation2(itemCreation2, ListItem); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.margin({ left: 10, right: 10 }); + if (isInitialRender) { + Row.marginRight(10); + Row.marginLeft(10); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(item); - Text.fontSize(50); - Text.onAppear(() => { - console.info("appear:" + item); - }); + if (isInitialRender) { + Text.fontSize(50); + Text.onAppear(() => { + console.info("appear:" + item); + }); + } }, Text); Text.pop(); Row.pop(); @@ -301,14 +308,19 @@ class lazyforEachThreeParam extends ViewPU { this.observeComponentCreation2(itemCreation2, ListItem); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.margin({ left: 10, right: 10 }); + if (isInitialRender) { + Row.marginRight(10); + Row.marginLeft(10); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(item); - Text.fontSize(50); - Text.onAppear(() => { - console.info("appear:" + item); - }); + if (isInitialRender) { + Text.fontSize(50); + Text.onAppear(() => { + console.info("appear:" + item); + }); + } }, Text); Text.pop(); Row.pop(); @@ -332,14 +344,19 @@ class lazyforEachThreeParam extends ViewPU { this.observeComponentCreation2(itemCreation2, ListItem); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.margin({ left: 10, right: 10 }); + if (isInitialRender) { + Row.marginRight(10); + Row.marginLeft(10); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(item); - Text.fontSize(50); - Text.onAppear(() => { - console.info("appear:" + item); - }); + if (isInitialRender) { + Text.fontSize(50); + Text.onAppear(() => { + console.info("appear:" + item); + }); + } }, Text); Text.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeat.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeat.ts index 894ab0ddd973225fcecb6b2d53dc4f191567cdfd..e2bd781a22e3c69c78cb39505615dd444cefbb48 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeat.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeat.ts @@ -119,7 +119,9 @@ class HomeComponent extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.height(500); + if (isInitialRender) { + Column.height(500); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Repeat(this.arr, this).each((obj) => { @@ -187,7 +189,9 @@ class ChildComponent extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.height(500); + if (isInitialRender) { + Column.height(500); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Repeat(this.arr, this).onMove((from, to) => { @@ -244,7 +248,9 @@ class ChildComponent2 extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { List.create(); - List.height(500); + if (isInitialRender) { + List.height(500); + } }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { Repeat(this.arr, this).each((obj) => { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeatVirtualScroll.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeatVirtualScroll.ts index a8533218d48e207a83cd5794d1a1355a7d2827f0..e79535d14c2740b66cd8f0683326114f6d59ba21 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeatVirtualScroll.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeatVirtualScroll.ts @@ -99,7 +99,9 @@ class ChildComponent extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { List.create(); - List.height(500); + if (isInitialRender) { + List.height(500); + } }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { Repeat(this.arr, this).each((obj) => { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/tab/tab.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/tab/tab.ts index ccdae0985d8fb0eaf24b3fce209b48ef4e10d641..68a6f7d5ce164eb89e8ef1136c6060fcda3649d0 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/tab/tab.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/tab/tab.ts @@ -90,32 +90,42 @@ class TabSimple extends ViewPU { TabContent.create(() => { this.observeComponentCreation2((elmtId, isInitialRender) => { Flex.create(); - Flex.height(100); - Flex.width(200); + if (isInitialRender) { + Flex.height(100); + Flex.width(200); + } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.height(100); - Column.width(200); + if (isInitialRender) { + Column.height(100); + Column.width(200); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('text1'); - Text.height(100); - Text.width(200); + if (isInitialRender) { + Text.height(100); + Text.width(200); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('xxx'); - Text.height(100); - Text.width(200); + if (isInitialRender) { + Text.height(100); + Text.width(200); + } }, Text); Text.pop(); Column.pop(); Flex.pop(); }); - TabContent.tabBar("TabBar"); - TabContent.height(100); - TabContent.width(200); + if (isInitialRender) { + TabContent.tabBar("TabBar"); + TabContent.height(100); + TabContent.width(200); + } }, TabContent); TabContent.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -125,9 +135,11 @@ class TabSimple extends ViewPU { }, Text); Text.pop(); }); - TabContent.tabBar("TabBar 2"); - TabContent.height(100); - TabContent.width(200); + if (isInitialRender) { + TabContent.tabBar("TabBar 2"); + TabContent.height(100); + TabContent.width(200); + } }, TabContent); TabContent.pop(); Tabs.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts b/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts index 1e2ee909b40ffc18f0e126670f85af0a69d3ef94..891978784d90de04a5999de65171e13de61b38a6 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts @@ -66,36 +66,47 @@ class ButtonExample extends ViewPU { }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel('Ok', { type: ButtonType.Normal, stateEffect: true }); - Button.borderRadius(8); - Button.backgroundColor(0x317aff); - Button.width(90); + if (isInitialRender) { + Button.borderRadius(8); + Button.backgroundColor(0x317aff); + Button.width(90); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithChild({ type: ButtonType.Normal, stateEffect: true }); - Button.borderRadius(8); - Button.backgroundColor(0x317aff); - Button.width(90); + if (isInitialRender) { + Button.borderRadius(8); + Button.backgroundColor(0x317aff); + Button.width(90); + } }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.alignItems(VerticalAlign.Center); + if (isInitialRender) { + Row.alignItems(VerticalAlign.Center); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('loading'); - Text.fontSize(12); - Text.fontColor(0xffffff); - Text.margin({ left: 5, right: 12 }); + if (isInitialRender) { + Text.fontSize(12); + Text.fontColor(0xffffff); + Text.marginRight(12); + Text.marginLeft(5); + } }, Text); Text.pop(); Row.pop(); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel('Disable', { type: ButtonType.Normal, stateEffect: false }); - Button.opacity(0.5); - Button.borderRadius(8); - Button.backgroundColor(0x317aff); - Button.width(90); + if (isInitialRender) { + Button.opacity(0.5); + Button.borderRadius(8); + Button.backgroundColor(0x317aff); + Button.width(90); + } }, Button); Button.pop(); Flex.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/animateTo/animateTo.ts b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/animateTo/animateTo.ts index c5569b795d8a8641bcf9542bf4b53c87541a4409..0efcc1c367a0f56a2c3fe235836d7c4b65e17b33 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/animateTo/animateTo.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/animateTo/animateTo.ts @@ -217,23 +217,27 @@ class TransitionExample extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, }); - Flex.height(400); - Flex.width("100%"); - Flex.padding({ top: 100 }); + if (isInitialRender) { + Flex.height(400); + Flex.width("100%"); + Flex.paddingTop(100); + } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.show); - Button.onClick(() => { - Context.animateTo({ duration: 1000 }, () => { - this.btn1 = !this.btn1; - if (this.btn1) { - this.show = "hide"; - } - else { - this.show = "show"; - } + if (isInitialRender) { + Button.onClick(() => { + Context.animateTo({ duration: 1000 }, () => { + this.btn1 = !this.btn1; + if (this.btn1) { + this.show = "hide"; + } + else { + this.show = "show"; + } + }); }); - }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -242,10 +246,12 @@ class TransitionExample extends ViewPU { this.ifElseBranchUpdateFunction(0, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(); - Button.width("80%"); - Button.height(30); - Button.transition({ type: TransitionType.Insert, scale: { x: 0, y: 1.0 } }); - Button.transition({ type: TransitionType.Delete, scale: { x: 1.0, y: 0.0 } }); + if (isInitialRender) { + Button.width("80%"); + Button.height(30); + Button.transition({ type: TransitionType.Insert, scale: { x: 0, y: 1.0 } }); + Button.transition({ type: TransitionType.Delete, scale: { x: 1.0, y: 0.0 } }); + } }, Button); Button.pop(); }); @@ -275,8 +281,10 @@ class TransitionExample extends ViewPU { Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create({ space: 5 }); - Column.width("100%"); - Column.height("100%"); + if (isInitialRender) { + Column.width("100%"); + Column.height("100%"); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navDestination_component/navDestination_component.ts b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navDestination_component/navDestination_component.ts index b9b83cf64a6e3104da149fc11d54c6a8197e3f66..ae3878bb0b1bd4be649bd7756ebd1f519bdfe37b 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navDestination_component/navDestination_component.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navDestination_component/navDestination_component.ts @@ -67,12 +67,16 @@ class PageOne extends ViewPU { NavDestination.create(() => { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.width('100%'); - Column.height('100%'); + if (isInitialRender) { + Column.width('100%'); + Column.height('100%'); + } }, Column); Column.pop(); }, { moduleName: "", pagePath: "navDestination_component" }); - NavDestination.title('pageOne'); + if (isInitialRender) { + NavDestination.title('pageOne'); + } }, NavDestination); NavDestination.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navigation/navigation_component.ts b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navigation/navigation_component.ts index 2b5c49ede3f2dec3958fc42e038a14813bca21ca..f8a67489213a761c7bdaf9638ce9ae712dbeae6a 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navigation/navigation_component.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navigation/navigation_component.ts @@ -65,12 +65,16 @@ class Index extends ViewPU { }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Navigation.create(this.pageStack, { moduleName: "", pagePath: "navigation_component", isUserCreateStack: true }); - Navigation.title('Main'); + if (isInitialRender) { + Navigation.title('Main'); + } }, Navigation); Navigation.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Navigation.create(new NavPathStack(), { moduleName: "", pagePath: "navigation_component", isUserCreateStack: false }); - Navigation.title('Main'); + if (isInitialRender) { + Navigation.title('Main'); + } }, Navigation); Navigation.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/pageTransition/pageTransition.ts b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/pageTransition/pageTransition.ts index 98e41637d8e1d8d008d3cba5f5318d8f99c48d56..6109f4dfafb9a1659c3435c361afc727a3b1bd16 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/pageTransition/pageTransition.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/pageTransition/pageTransition.ts @@ -113,14 +113,18 @@ class PageTransitionExample1 extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Navigator.create({ target: 'pages/page1', type: NavigationType.Push }); - Navigator.onClick(() => { - this.active = true; - }); + if (isInitialRender) { + Navigator.onClick(() => { + this.active = true; + }); + } }, Navigator); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('page transition'); - Text.width("100%"); - Text.height("100%"); + if (isInitialRender) { + Text.width("100%"); + Text.height("100%"); + } }, Text); Text.pop(); Navigator.pop(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@AnimatableExtend/animatableExtend.ts b/compiler/test/utForPartialUpdate/render_decorator/@AnimatableExtend/animatableExtend.ts index 4d7656b282fe018067d18338775f8195345a3bfb..da8c00ff9ec29c61828f2cd9d2c3560b361ccf2e 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@AnimatableExtend/animatableExtend.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@AnimatableExtend/animatableExtend.ts @@ -110,9 +110,11 @@ class HomeComponent extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Polyline.create(); animatablePoints(this.points, elmtId, isInitialRender, this); - Polyline.strokeWidth(3); - Polyline.height(100); - Polyline.width(100); + if (isInitialRender) { + Polyline.strokeWidth(3); + Polyline.height(100); + Polyline.width(100); + } }, Polyline); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("hello"); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builder.ts b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builder.ts index c9c04f248e835c2c70952d89b6ac5e3bcff44eca..c0a6ff5c56fd0db4c7f6dc0fe9ebfd00826a98bc 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builder.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builder.ts @@ -245,7 +245,9 @@ class MyComponent extends ViewPU { textBuilder(parent = null) { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("文本"); - Text.fontSize(30); + if (isInitialRender) { + Text.fontSize(30); + } }, Text); Text.pop(); } @@ -255,8 +257,10 @@ class MyComponent extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(label); - Text.width(80); - Text.bindMenu({ builder: this.textBuilder.bind(this) }); + if (isInitialRender) { + Text.width(80); + Text.bindMenu({ builder: this.textBuilder.bind(this) }); + } }, Text); Text.pop(); Column.pop(); @@ -264,20 +268,28 @@ class MyComponent extends ViewPU { MenuBuilder(parent = null) { this.observeComponentCreation2((elmtId, isInitialRender) => { Flex.create({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }); - Flex.width(100); + if (isInitialRender) { + Flex.width(100); + } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('Test menu item 1'); - Text.fontSize(20); + if (isInitialRender) { + Text.fontSize(20); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Divider.create(); - Divider.height(10); + if (isInitialRender) { + Divider.height(10); + } }, Divider); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('Test menu item 2'); - Text.fontSize(20); + if (isInitialRender) { + Text.fontSize(20); + } }, Text); Text.pop(); Flex.pop(); @@ -291,31 +303,43 @@ class MyComponent extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.padding(10); - Row.bindMenu({ builder: () => { - this.NavigationTitlePara.call(this, "111"); - } }); + if (isInitialRender) { + Row.paddingBottom(10); + Row.paddingTop(10); + Row.paddingRight(10); + Row.paddingLeft(10); + Row.bindMenu({ builder: () => { + this.NavigationTitlePara.call(this, "111"); + } }); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("Drag Me"); - Text.onDragStart((event, extraParams) => { - console.log('Text onDragStarts, ' + extraParams); - }); + if (isInitialRender) { + Text.onDragStart((event, extraParams) => { + console.log('Text onDragStarts, ' + extraParams); + }); + } }, Text); Text.pop(); specificParam.bind(this)('test1', 'test2'); Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.padding(10); - Row.bindPopup(false, { - builder: { builder: this.MenuBuilder.bind(this) }, - onStateChange: (e) => { - if (!e.isVisible) { - console.warn(JSON.stringify(e.isVisible)); + if (isInitialRender) { + Row.paddingBottom(10); + Row.paddingTop(10); + Row.paddingRight(10); + Row.paddingLeft(10); + Row.bindPopup(false, { + builder: { builder: this.MenuBuilder.bind(this) }, + onStateChange: (e) => { + if (!e.isVisible) { + console.warn(JSON.stringify(e.isVisible)); + } } - } - }); + }); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('Test Text'); @@ -324,8 +348,13 @@ class MyComponent extends ViewPU { Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.padding(10); - Row.bindContextMenu({ builder: this.MenuBuilder.bind(this) }, ResponseType.RightClick); + if (isInitialRender) { + Row.paddingBottom(10); + Row.paddingTop(10); + Row.paddingRight(10); + Row.paddingLeft(10); + Row.bindContextMenu({ builder: this.MenuBuilder.bind(this) }, ResponseType.RightClick); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('rightclick for menu'); @@ -334,31 +363,41 @@ class MyComponent extends ViewPU { Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.padding(10); + if (isInitialRender) { + Row.paddingBottom(10); + Row.paddingTop(10); + Row.paddingRight(10); + Row.paddingLeft(10); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Navigation.create(new NavPathStack(), { moduleName: "", pagePath: "@builder", isUserCreateStack: false }); - Navigation.title({ builder: noParam.bind(this) }); - Navigation.menus({ builder: this.textBuilder.bind(this) }); - Navigation.toolBar({ items: [ - { value: 'app', text: 'Grid', action: () => { - console.log("app"); - } }, - { value: 'add', text: 'Add', action: () => { - console.log("add"); - } }, - { value: 'collect', text: 'Collect', action: () => { - console.log("collect"); - } } - ] }); Navigation.hideToolBar(this.hideBar); + if (isInitialRender) { + Navigation.title({ builder: noParam.bind(this) }); + Navigation.menus({ builder: this.textBuilder.bind(this) }); + Navigation.toolBar({ items: [ + { value: 'app', text: 'Grid', action: () => { + console.log("app"); + } }, + { value: 'add', text: 'Add', action: () => { + console.log("add"); + } }, + { value: 'collect', text: 'Collect', action: () => { + console.log("collect"); + } } + ] }); + } }, Navigation); this.observeComponentCreation2((elmtId, isInitialRender) => { List.create({ space: 5, initialIndex: 0 }); - List.listDirection(Axis.Vertical); - List.height(300); - List.margin({ top: 10, left: 18 }); - List.width('100%'); + if (isInitialRender) { + List.listDirection(Axis.Vertical); + List.height(300); + List.marginTop(10); + List.marginLeft(18); + List.width('100%'); + } }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); @@ -375,18 +414,22 @@ class MyComponent extends ViewPU { }; const itemCreation2 = (elmtId, isInitialRender) => { ListItem.create(deepRenderFunction, true); - ListItem.editable(true); + if (isInitialRender) { + ListItem.editable(true); + } }; const deepRenderFunction = (elmtId, isInitialRender) => { itemCreation(elmtId, isInitialRender); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('' + item); - Text.width('90%'); - Text.height(80); - Text.backgroundColor('#3366CC'); - Text.borderRadius(15); - Text.fontSize(16); - Text.textAlign(TextAlign.Center); + if (isInitialRender) { + Text.width('90%'); + Text.height(80); + Text.backgroundColor('#3366CC'); + Text.borderRadius(15); + Text.fontSize(16); + Text.textAlign(TextAlign.Center); + } }, Text); Text.pop(); ListItem.pop(); @@ -401,17 +444,25 @@ class MyComponent extends ViewPU { List.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.hideBar ? "tool bar" : "hide bar"); - Button.onClick(() => { - this.hideBar = !this.hideBar; - }); - Button.margin({ left: 135, top: 60 }); + if (isInitialRender) { + Button.onClick(() => { + this.hideBar = !this.hideBar; + }); + Button.marginTop(60); + Button.marginLeft(135); + } }, Button); Button.pop(); Navigation.pop(); Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.padding(10); + if (isInitialRender) { + Row.paddingBottom(10); + Row.paddingTop(10); + Row.paddingRight(10); + Row.paddingLeft(10); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Tabs.create({ barPosition: BarPosition.Start, controller: this.controller }); @@ -420,39 +471,51 @@ class MyComponent extends ViewPU { TabContent.create(() => { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('111'); - Text.width('100%'); - Text.height('20'); - Text.backgroundColor(Color.Pink); + if (isInitialRender) { + Text.width('100%'); + Text.height('20'); + Text.backgroundColor(Color.Pink); + } }, Text); Text.pop(); }); - TabContent.tabBar('pink'); + if (isInitialRender) { + TabContent.tabBar('pink'); + } }, TabContent); TabContent.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { TabContent.create(() => { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('222'); - Text.width('100%'); - Text.height('20'); - Text.backgroundColor(Color.Yellow); + if (isInitialRender) { + Text.width('100%'); + Text.height('20'); + Text.backgroundColor(Color.Yellow); + } }, Text); Text.pop(); }); - TabContent.tabBar('yellow'); + if (isInitialRender) { + TabContent.tabBar('yellow'); + } }, TabContent); TabContent.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { TabContent.create(() => { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('333'); - Text.width('100%'); - Text.height('20'); - Text.backgroundColor(Color.Blue); + if (isInitialRender) { + Text.width('100%'); + Text.height('20'); + Text.backgroundColor(Color.Blue); + } }, Text); Text.pop(); }); - TabContent.tabBar('blue'); + if (isInitialRender) { + TabContent.tabBar('blue'); + } }, TabContent); TabContent.pop(); Tabs.pop(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderDynamicUsage$$.ts b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderDynamicUsage$$.ts index 20e8307e708736a17829a2d21840046e88a562ea..93f89aecce4db389b979a5e9dbdbe1acb7de5870 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderDynamicUsage$$.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderDynamicUsage$$.ts @@ -136,17 +136,22 @@ class VideoPlayer extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('Hello' + $$.playedTimeNumber); - Text.fontSize(13); - Text.margin({ left: 4, bottom: 12 }); - Text.id("played_time"); + if (isInitialRender) { + Text.fontSize(13); + Text.marginBottom(12); + Text.marginLeft(4); + Text.id("played_time"); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { TextInput.create({ text: $$.totalTime, placeholder: 'builder test' }); - TextInput.placeholderColor(Color.Grey); - TextInput.placeholderFont({ size: 14, weight: 400 }); - TextInput.caretColor(Color.Blue); - TextInput.width(300); + if (isInitialRender) { + TextInput.placeholderColor(Color.Grey); + TextInput.placeholderFont({ size: 14, weight: 400 }); + TextInput.caretColor(Color.Blue); + TextInput.width(300); + } }, TextInput); this.observeComponentCreation2((elmtId, isInitialRender) => { Slider.create({ @@ -156,11 +161,14 @@ class VideoPlayer extends ViewPU { step: 1, style: SliderStyle.OutSet }); - Slider.width('100%'); - Slider.margin({ left: 8, right: 8 }); - Slider.trackColor(Color.Gray); - Slider.showSteps(true); - Slider.id("slider"); + if (isInitialRender) { + Slider.width('100%'); + Slider.marginRight(8); + Slider.marginLeft(8); + Slider.trackColor(Color.Gray); + Slider.showSteps(true); + Slider.id("slider"); + } }, Slider); Column.pop(); } diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormFirst.ts b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormFirst.ts index 1121ea1e4df3c89752398f78dcd69fe4ea744789..49162d74f5486361bcd2c0712205c703576cd9fb 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormFirst.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormFirst.ts @@ -159,7 +159,9 @@ function testIfIdComponent(value, parent = null) { if (!If.canRetake('id14')) { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { __Common__.create(true); - __Common__.id('id14'); + if (isInitialRender) { + __Common__.id('id14'); + } }, __Common__); { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormFourth.ts b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormFourth.ts index e92f1458a9f1015034a5f0af52d8fc7cf5c1b0f5..404f9b1dd8f33004f31fb92ee1423ac240b44f98 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormFourth.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormFourth.ts @@ -502,8 +502,10 @@ function testIfIdComponent(value, parent = null) { if (!If.canRetake('id1')) { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Text.create('count is negative'); - Text.fontSize(32); - Text.id('id1'); + if (isInitialRender) { + Text.fontSize(32); + Text.id('id1'); + } }, Text); Text.pop(); } @@ -514,14 +516,18 @@ function testIfIdComponent(value, parent = null) { if (!If.canRetake('id2')) { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Divider.create(); - Divider.id('id2'); + if (isInitialRender) { + Divider.id('id2'); + } }, Divider); } if (!If.canRetake('id3')) { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Text.create('even'); - Text.fontSize(32); - Text.id('id3'); + if (isInitialRender) { + Text.fontSize(32); + Text.id('id3'); + } }, Text); Text.pop(); } @@ -532,18 +538,24 @@ function testIfIdComponent(value, parent = null) { if (!If.canRetake('id4')) { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Divider.create(); - Divider.id('id4'); + if (isInitialRender) { + Divider.id('id4'); + } }, Divider); } if (!If.canRetake('id10')) { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Column.create(); - Column.id('id10'); + if (isInitialRender) { + Column.id('id10'); + } }, Column); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Text.create('odd'); - Text.fontSize(32); - Text.id('id5'); + if (isInitialRender) { + Text.fontSize(32); + Text.id('id5'); + } }, Text); Text.pop(); Column.pop(); @@ -559,8 +571,10 @@ function testIfIdComponent(value, parent = null) { if (!If.canRetake('id6')) { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Text.create('fail'); - Text.id('id6'); - Text.fontSize(32); + if (isInitialRender) { + Text.id('id6'); + Text.fontSize(32); + } }, Text); Text.pop(); } @@ -575,8 +589,10 @@ function testIfIdComponent(value, parent = null) { if (!If.canRetake('id7')) { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Text.create('odd2'); - Text.fontSize(32); - Text.id('id7'); + if (isInitialRender) { + Text.fontSize(32); + Text.id('id7'); + } }, Text); Text.pop(); } @@ -607,19 +623,26 @@ function testIfIdComponent(value, parent = null) { }; const itemCreation2 = (elmtId, isInitialRender, value = __value__) => { ListItem.create(deepRenderFunction, true); - ListItem.id('id8'); + if (isInitialRender) { + ListItem.id('id8'); + } }; const deepRenderFunction = (elmtId, isInitialRender, value = __value__) => { itemCreation(elmtId, isInitialRender, value); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Row.create(); - Row.margin({ left: 10, right: 10 }); - Row.id('id11'); + if (isInitialRender) { + Row.marginRight(10); + Row.marginLeft(10); + Row.id('id11'); + } }, Row); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Text.create(); - Text.fontSize(20); - Text.margin({ left: 10 }); + if (isInitialRender) { + Text.fontSize(20); + Text.marginLeft(10); + } }, Text); Text.pop(); Row.pop(); @@ -650,14 +673,18 @@ function testIfIdComponent(value, parent = null) { TabContent.create(() => { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Text.create('111'); - Text.width('100%'); - Text.height('20'); - Text.backgroundColor(Color.Pink); + if (isInitialRender) { + Text.width('100%'); + Text.height('20'); + Text.backgroundColor(Color.Pink); + } }, Text); Text.pop(); }); - TabContent.tabBar('pink'); - TabContent.id('id9'); + if (isInitialRender) { + TabContent.tabBar('pink'); + TabContent.id('id9'); + } }, TabContent); TabContent.pop(); } @@ -689,13 +716,17 @@ function testIfIdComponent(value, parent = null) { if (!If.canRetake('id12')) { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { XComponent.create({ id: 'special', type: '' }); - XComponent.id('id12'); + if (isInitialRender) { + XComponent.id('id12'); + } }, XComponent); } if (!If.canRetake('id13')) { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Column.create(); - Column.id('id13'); + if (isInitialRender) { + Column.id('id13'); + } }, Column); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Text.create('11'); @@ -833,32 +864,42 @@ function testTabComponent(value, parent = null) { TabContent.create(() => { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Flex.create(); - Flex.height(100); - Flex.width(200); + if (isInitialRender) { + Flex.height(100); + Flex.width(200); + } }, Flex); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Column.create(); - Column.height(100); - Column.width(200); + if (isInitialRender) { + Column.height(100); + Column.width(200); + } }, Column); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Text.create('text1'); - Text.height(100); - Text.width(200); + if (isInitialRender) { + Text.height(100); + Text.width(200); + } }, Text); Text.pop(); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Text.create(value.toString()); - Text.height(100); - Text.width(200); + if (isInitialRender) { + Text.height(100); + Text.width(200); + } }, Text); Text.pop(); Column.pop(); Flex.pop(); }); - TabContent.tabBar("TabBar"); - TabContent.height(100); - TabContent.width(200); + if (isInitialRender) { + TabContent.tabBar("TabBar"); + TabContent.height(100); + TabContent.width(200); + } }, TabContent); TabContent.pop(); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { @@ -868,9 +909,11 @@ function testTabComponent(value, parent = null) { }, Text); Text.pop(); }); - TabContent.tabBar("TabBar 2"); - TabContent.height(100); - TabContent.width(200); + if (isInitialRender) { + TabContent.tabBar("TabBar 2"); + TabContent.height(100); + TabContent.width(200); + } }, TabContent); TabContent.pop(); Tabs.pop(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormSecond.ts b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormSecond.ts index fb057ec0b9664d5d4fe0eecb36c244019c6cc0dd..1bb2d2dbb99303739d2de7661557bf5086d6385f 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormSecond.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormSecond.ts @@ -174,7 +174,9 @@ function testInnerComponent(value, parent = null) { } (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { __Common__.create(); - __Common__.width(value); + if (isInitialRender) { + __Common__.width(value); + } }, __Common__); { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormThird.ts b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormThird.ts index 03b32654599e1ed5a9478b634f8e695191f656fd..43bd083eb1e1592a888e8c6a7a78214126e848c4 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormThird.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormThird.ts @@ -186,7 +186,9 @@ function testInnerComponent(value, parent = null) { __Recycle__.pop(); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender) => { __Common__.create(); - __Common__.height(value); + if (isInitialRender) { + __Common__.height(value); + } }, __Common__); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender) => { __Recycle__.create(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderVisilibity$$.ts b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderVisilibity$$.ts index eaeae4b59fb647114164735bbf4a4717dabb5351..5815400c5000f2066e227bf28d70a7555fcf151c 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderVisilibity$$.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderVisilibity$$.ts @@ -180,7 +180,9 @@ class visibility$$Demo extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.height('100%'); + if (isInitialRender) { + Column.height('100%'); + } }, Column); comp.bind(this)(makeBuilderParameterProxy("comp", { vis: () => (this["__vis"] ? this["__vis"] : this["vis"]), data: () => (this["__data"] ? this["__data"] : this["data"]), width: () => (this["__w"] ? this["__w"] : this["w"]) })); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderWithForEach.ts b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderWithForEach.ts index c24ed42a296aa84127588a29d7ee373688a8cea4..0920ad02da9766ebe12d16d3e1aa14299082e661 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderWithForEach.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderWithForEach.ts @@ -56,7 +56,9 @@ function ComB(param, parent = null) { const item = _item; (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, param = __param__) => { __Common__.create(); - __Common__.backgroundColor('red'); + if (isInitialRender) { + __Common__.backgroundColor('red'); + } }, __Common__); { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, param = __param__) => { @@ -146,7 +148,9 @@ class ComA extends ViewPU { }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('自定义组件'); - Text.fontSize(30); + if (isInitialRender) { + Text.fontSize(30); + } }, Text); Text.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builder/handleCustomBuilder.ts b/compiler/test/utForPartialUpdate/render_decorator/@builder/handleCustomBuilder.ts index aed6b8850839e8ad40400110bb38e54d70f93ab7..ebd026cc2823fb3c7a4e85b1445ccba4fef84b8b 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builder/handleCustomBuilder.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builder/handleCustomBuilder.ts @@ -101,20 +101,24 @@ class Index extends ViewPU { inner(param, parent = null) { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('Inner Builder Text'); - Text.bindPopup(false, { - onStateChange: (e) => { }, - builder: { builder: () => { - global.call(this); - } } - }); + if (isInitialRender) { + Text.bindPopup(false, { + onStateChange: (e) => { }, + builder: { builder: () => { + global.call(this); + } } + }); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('Inner Builder Text2'); - Text.bindPopup(false, { - onStateChange: (e) => { }, - builder: this.judge ? { builder: global.bind(this) } : undefined - }); + if (isInitialRender) { + Text.bindPopup(false, { + onStateChange: (e) => { }, + builder: this.judge ? { builder: global.bind(this) } : undefined + }); + } }, Text); Text.pop(); } @@ -124,44 +128,54 @@ class Index extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.bindMenu({ builder: () => { - this.inner.call(this, "111"); - } }); + if (isInitialRender) { + Row.bindMenu({ builder: () => { + this.inner.call(this, "111"); + } }); + } }, Row); Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.bindMenu(this.judge ? { builder: () => { - this.inner.call(this, "111"); - } } : { builder: global.bind(this) }); + if (isInitialRender) { + Row.bindMenu(this.judge ? { builder: () => { + this.inner.call(this, "111"); + } } : { builder: global.bind(this) }); + } }, Row); Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.onDragStart((event, extraParams) => { - console.log('Text onDragStarts, ' + extraParams); - return this.judge ? { builder: this.inner.bind(this) } : { builder: () => { - global.call(this); - } }; - }); + if (isInitialRender) { + Row.onDragStart((event, extraParams) => { + console.log('Text onDragStarts, ' + extraParams); + return this.judge ? { builder: this.inner.bind(this) } : { builder: () => { + global.call(this); + } }; + }); + } }, Row); Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.onDragStart((event, extraParams) => { - console.log('Text onDragStarts, ' + extraParams); - return { builder: this.judge ? { builder: () => { - this.inner.call(this); - } } : undefined }; - }); + if (isInitialRender) { + Row.onDragStart((event, extraParams) => { + console.log('Text onDragStarts, ' + extraParams); + return { builder: this.judge ? { builder: () => { + this.inner.call(this); + } } : undefined }; + }); + } }, Row); Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('Text'); - Text.bindPopup(false, { - onStateChange: (e) => { }, - builder: undefined - }); + if (isInitialRender) { + Text.bindPopup(false, { + onStateChange: (e) => { }, + builder: undefined + }); + } }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builderParam/@builderParam.ts b/compiler/test/utForPartialUpdate/render_decorator/@builderParam/@builderParam.ts index eedf9babf6d18d256c9824b4863700159a35ada5..f9b100dab9c142192757f8ac4b4b8b27e6f4f852 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builderParam/@builderParam.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builderParam/@builderParam.ts @@ -210,12 +210,16 @@ function specificWithParam(label1, label2, parent = null) { }, Column); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender) => { Text.create(label1); - Text.fontSize(50); + if (isInitialRender) { + Text.fontSize(50); + } }, Text); Text.pop(); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender) => { Text.create(label2); - Text.fontSize(50); + if (isInitialRender) { + Text.fontSize(50); + } }, Text); Text.pop(); Column.pop(); @@ -257,7 +261,9 @@ class CustomContainerUser extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("content"); - Text.fontSize(50); + if (isInitialRender) { + Text.fontSize(50); + } }, Text); Text.pop(); Column.pop(); @@ -268,12 +274,16 @@ class CustomContainerUser extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(label1); - Text.fontSize(50); + if (isInitialRender) { + Text.fontSize(50); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(label2); - Text.fontSize(50); + if (isInitialRender) { + Text.fontSize(50); + } }, Text); Text.pop(); Column.pop(); @@ -290,9 +300,11 @@ class CustomContainerUser extends ViewPU { closer: () => { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.onClick(() => { - this.text = "changeHeader"; - }); + if (isInitialRender) { + Column.onClick(() => { + this.text = "changeHeader"; + }); + } }, Column); specificWithParam.bind(this)("111", "22"); Column.pop(); @@ -305,9 +317,11 @@ class CustomContainerUser extends ViewPU { closer: () => { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.onClick(() => { - this.text = "changeHeader"; - }); + if (isInitialRender) { + Column.onClick(() => { + this.text = "changeHeader"; + }); + } }, Column); specificWithParam.bind(this)("111", "22"); Column.pop(); @@ -361,9 +375,11 @@ class CustomContainerUser extends ViewPU { content: () => { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.onClick(() => { - this.text = "changeHeader"; - }); + if (isInitialRender) { + Column.onClick(() => { + this.text = "changeHeader"; + }); + } }, Column); this.callSpecificParam.bind(this)("111", '222'); Column.pop(); @@ -376,9 +392,11 @@ class CustomContainerUser extends ViewPU { content: () => { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.onClick(() => { - this.text = "changeHeader"; - }); + if (isInitialRender) { + Column.onClick(() => { + this.text = "changeHeader"; + }); + } }, Column); this.callSpecificParam.bind(this)("111", '222'); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builderParam/@builderParamQuestionMark.ts b/compiler/test/utForPartialUpdate/render_decorator/@builderParam/@builderParamQuestionMark.ts index fb8babe11f4a24d6115837064dd63c284486712b..5b4d97a68efd844d416b794b6fa258aa33f97ce6 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builderParam/@builderParamQuestionMark.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builderParam/@builderParamQuestionMark.ts @@ -118,16 +118,22 @@ class Index extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.height('100%'); + if (isInitialRender) { + Row.height('100%'); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.width('100%'); + if (isInitialRender) { + Column.width('100%'); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.message); - Text.fontSize(50); - Text.fontWeight(FontWeight.Bold); + if (isInitialRender) { + Text.fontSize(50); + Text.fontWeight(FontWeight.Bold); + } }, Text); Text.pop(); { diff --git a/compiler/test/utForPartialUpdate/render_decorator/@customDialog/@customDialog.ts b/compiler/test/utForPartialUpdate/render_decorator/@customDialog/@customDialog.ts index 5daf057e1356268ddcdf6b4f4883af9ac7249422..d58acb757cd69288408885014cdf3d974a4acdb3 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@customDialog/@customDialog.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@customDialog/@customDialog.ts @@ -169,9 +169,11 @@ class DialogExample extends ViewPU { }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel('current count is: ' + this.count); - Button.onClick(() => { - this.count++; - }); + if (isInitialRender) { + Button.onClick(() => { + this.count++; + }); + } }, Button); Button.pop(); Row.pop(); @@ -180,9 +182,11 @@ class DialogExample extends ViewPU { }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.isPlaying ? 'play' : 'pause'); - Button.onClick(() => { - this.isPlaying = !this.isPlaying; - }); + if (isInitialRender) { + Button.onClick(() => { + this.isPlaying = !this.isPlaying; + }); + } }, Button); Button.pop(); Row.pop(); @@ -191,18 +195,22 @@ class DialogExample extends ViewPU { }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel("Option A"); - Button.onClick(() => { - this.controller.close(); - this.action1(); - }); + if (isInitialRender) { + Button.onClick(() => { + this.controller.close(); + this.action1(); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel("Option B"); - Button.onClick(() => { - this.controller.close(); - this.action2(47, "Option B is great choice"); - }); + if (isInitialRender) { + Button.onClick(() => { + this.controller.close(); + this.action2(47, "Option B is great choice"); + }); + } }, Button); Button.pop(); Row.pop(); @@ -295,28 +303,36 @@ class CustomDialogUser extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('current countInitValue is: ' + this.countInitValue); - Text.fontSize(20); + if (isInitialRender) { + Text.fontSize(20); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('current playingInitValue is: ' + this.playingInitValue); - Text.fontSize(20); + if (isInitialRender) { + Text.fontSize(20); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel("Click to open Dialog -1"); - Button.onClick(() => { - this.countInitValue--; - this.dialogController.open(); - }); + if (isInitialRender) { + Button.onClick(() => { + this.countInitValue--; + this.dialogController.open(); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel("Click to close Dialog +1"); - Button.onClick(() => { - this.countInitValue++; - this.dialogController.close(); - }); + if (isInitialRender) { + Button.onClick(() => { + this.countInitValue++; + this.dialogController.close(); + }); + } }, Button); Button.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@preview/@preview.ts b/compiler/test/utForPartialUpdate/render_decorator/@preview/@preview.ts index 1c584409c46be13519d6a21a51a6391443dda5aa..ff2e9868311318dde353ab3b696178a3a96367d2 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@preview/@preview.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@preview/@preview.ts @@ -71,7 +71,9 @@ class HomePreviewComponent extends ViewPU { PUV2ViewBase.contextStack && PUV2ViewBase.contextStack.push(this); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.value); - Text.fontSize(50); + if (isInitialRender) { + Text.fontSize(50); + } }, Text); Text.pop(); PUV2ViewBase.contextStack && PUV2ViewBase.contextStack.pop(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle.ts b/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle.ts index deafe22402a19c6969c59e37695f4f5649a38a53..7e88da080d885d8e661e25747c87fa3d4de000c3 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle.ts @@ -191,12 +191,17 @@ class HomeComponent extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); Column.width(this.state_value); - Column.height(100); + if (isInitialRender) { + Column.height(100); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { __Common__.create(); - __Common__.border({ width: 3, color: Color.Red }); __Common__.width(this.state_value); + if (isInitialRender) { + __Common__.borderColor(Color.Red); + __Common__.borderWidth(3); + } }, __Common__); this.observeComponentCreation2((elmtId, isInitialRender) => { __Recycle__.create(); @@ -238,7 +243,9 @@ class HomeComponent extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("aa"); Text.width(this.state_value); - Text.height(100); + if (isInitialRender) { + Text.height(100); + } }, Text); Text.pop(); Column.pop(); @@ -346,8 +353,11 @@ class child extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { __Common__.create(); - __Common__.border({ width: 3, color: Color.Red }); __Common__.height(this.heightValue); + if (isInitialRender) { + __Common__.borderColor(Color.Red); + __Common__.borderWidth(3); + } }, __Common__); this.observeComponentCreation2((elmtId, isInitialRender) => { __Recycle__.create(); @@ -384,17 +394,23 @@ class child extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("hello"); Text.width(this.propvalue); - Text.fontColor(Color.Red); - Text.border({ width: this.propvalue, color: Color.Red, radius: 100 }); + Text.borderWidth(this.propvalue); if (isInitialRender) { Text.fontSize(this.reguar_value); Text.height(100); + Text.fontColor(Color.Red); + Text.borderRadius(100); + Text.borderColor(Color.Red); } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithChild(); - Button.border({ width: this.reguar_value, color: Color.Red, radius: 100 }); + if (isInitialRender) { + Button.borderRadius(100); + Button.borderColor(Color.Red); + Button.borderWidth(this.reguar_value); + } }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("hhhhhhhhhhhhh"); @@ -575,7 +591,9 @@ class NormalComponent extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("hello"); Text.width(this.width_value); - Text.height(100); + if (isInitialRender) { + Text.height(100); + } }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_extend_styles.ts b/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_extend_styles.ts index a4d01eec064f8120e6b0689c8eaea11103498564..22386b047cdbaefef5549796974cb5f6c7d7797a 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_extend_styles.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_extend_styles.ts @@ -213,26 +213,25 @@ class StylesComponent extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("Fancy"); - Text.backgroundColor(Color.Red); Text.width(this.width_value); if (isInitialRender) { + Text.backgroundColor(Color.Red); Text.height(100); } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("Fancy"); - Text.backgroundColor(Color.Blue); Text.width(this.width_value); Text.fontSize(this.size_value); if (isInitialRender) { + Text.backgroundColor(Color.Blue); Text.height(100); } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithChild(); - Button.backgroundColor(Color.Blue); Button.width(this.width_value); ViewStackProcessor.visualState("normal"); Button.backgroundColor(Color.Green); @@ -244,6 +243,7 @@ class StylesComponent extends ViewPU { Button.backgroundColor(Color.Red); ViewStackProcessor.visualState(); if (isInitialRender) { + Button.backgroundColor(Color.Blue); Button.enabled(this.enable); Button.onClick(() => { this.enable = false; @@ -253,9 +253,9 @@ class StylesComponent extends ViewPU { }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("Fancy"); - Text.backgroundColor(Color.Red); Text.fontSize(this.size_value); if (isInitialRender) { + Text.backgroundColor(Color.Red); Text.height(100); } }, Text); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_gesture.ts b/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_gesture.ts index 186df77f9dbeb878379cf67cd03f72fae527ea3f..75b1174733b4271794d6ebf25f305a59f5d46d4c 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_gesture.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_gesture.ts @@ -24,7 +24,7 @@ struct GestureTest { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { Text('LongPress onAction:' + this.count) .height(100) - .width(width_value) + .width(this.width_value) } .height(100).width(this.width_value).padding(60).border({ width:1 }).margin(30) .gesture( @@ -113,14 +113,20 @@ class GestureTest extends ViewPU { Gesture.pop(); if (isInitialRender) { Flex.height(100); - Flex.padding(60); - Flex.border({ width: 1 }); - Flex.margin(30); + Flex.paddingBottom(60); + Flex.paddingTop(60); + Flex.paddingRight(60); + Flex.paddingLeft(60); + Flex.borderWidth(1); + Flex.marginBottom(30); + Flex.marginTop(30); + Flex.marginRight(30); + Flex.marginLeft(30); } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('LongPress onAction:' + this.count); - Text.width(width_value); + Text.width(this.width_value); if (isInitialRender) { Text.height(100); } diff --git a/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_reuseId.ts b/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_reuseId.ts index 9962efb7546fbf816b9dae84c2f878b5753620f3..553ac28c3ac7b8dfd3149e1697efca36ec1c025c 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_reuseId.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_reuseId.ts @@ -111,8 +111,11 @@ class HomeComponent extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { __Common__.create(); - __Common__.border({ width: 3, color: Color.Red }); __Common__.width(this.state_value); + if (isInitialRender) { + __Common__.borderColor(Color.Red); + __Common__.borderWidth(3); + } }, __Common__); this.observeComponentCreation2((elmtId, isInitialRender) => { __Recycle__.create(); @@ -153,7 +156,10 @@ class HomeComponent extends ViewPU { __Recycle__.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { __Common__.create(); - __Common__.border({ width: 3, color: Color.Red }); + if (isInitialRender) { + __Common__.borderColor(Color.Red); + __Common__.borderWidth(3); + } }, __Common__); this.observeComponentCreation2((elmtId, isInitialRender) => { __Recycle__.create(); @@ -230,8 +236,11 @@ class HomeComponent extends ViewPU { __Recycle__.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { __Common__.create(); - __Common__.border({ width: 3, color: Color.Red }); __Common__.width(this.state_value); + if (isInitialRender) { + __Common__.borderColor(Color.Red); + __Common__.borderWidth(3); + } }, __Common__); this.observeComponentCreation2((elmtId, isInitialRender) => { __Recycle__.create(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@styles/@styles.ts b/compiler/test/utForPartialUpdate/render_decorator/@styles/@styles.ts index 965341f7c90c920d4c6072ea3c212d3a7f0cf0f9..962dd8745c14da32bb74d3f07ebd8816c73e00ac 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@styles/@styles.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@styles/@styles.ts @@ -109,24 +109,25 @@ class FancyUse extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("Fancy"); - Text.backgroundColor(Color.Red); - Text.width(100); - Text.height(100); + if (isInitialRender) { + Text.backgroundColor(Color.Red); + Text.width(100); + Text.height(100); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("Fancy"); - Text.backgroundColor(Color.Blue); - Text.width(100); - Text.height(100); + if (isInitialRender) { + Text.backgroundColor(Color.Blue); + Text.width(100); + Text.height(100); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithChild(); Button.enabled(this.enable); - Button.onClick(() => { - this.enable = false; - }); ViewStackProcessor.visualState("normal"); Button.backgroundColor(Color.Green); ViewStackProcessor.visualState("disabled"); @@ -134,6 +135,11 @@ class FancyUse extends ViewPU { ViewStackProcessor.visualState("pressed"); Button.backgroundColor(Color.Red); ViewStackProcessor.visualState(); + if (isInitialRender) { + Button.onClick(() => { + this.enable = false; + }); + } }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("Fancy"); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@styles/@stylesExport.ts b/compiler/test/utForPartialUpdate/render_decorator/@styles/@stylesExport.ts index f3a737d33948d6498a6818aaae27788e819a5c23..f3207e789fa086db35e25adedba10b4f990e14fb 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@styles/@stylesExport.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@styles/@stylesExport.ts @@ -102,24 +102,25 @@ class FancyUseExp extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("Fancy"); - Text.backgroundColor(Color.Red); - Text.width(100); - Text.height(100); + if (isInitialRender) { + Text.backgroundColor(Color.Red); + Text.width(100); + Text.height(100); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("Fancy"); - Text.backgroundColor(Color.Blue); - Text.width(100); - Text.height(100); + if (isInitialRender) { + Text.backgroundColor(Color.Blue); + Text.width(100); + Text.height(100); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithChild(); Button.enabled(this.enable); - Button.onClick(() => { - this.enable = false; - }); ViewStackProcessor.visualState("normal"); Button.backgroundColor(Color.Green); ViewStackProcessor.visualState("disabled"); @@ -127,6 +128,11 @@ class FancyUseExp extends ViewPU { ViewStackProcessor.visualState("pressed"); Button.backgroundColor(Color.Red); ViewStackProcessor.visualState(); + if (isInitialRender) { + Button.onClick(() => { + this.enable = false; + }); + } }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("Fancy"); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@styles/@stylesOrComponentAsName.ts b/compiler/test/utForPartialUpdate/render_decorator/@styles/@stylesOrComponentAsName.ts index e0faece03fb3791ee7c9daadb53d9d2a17278ee7..af0f9014709b7864cbf480856fd4b298b400f2e2 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@styles/@stylesOrComponentAsName.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@styles/@stylesOrComponentAsName.ts @@ -116,9 +116,11 @@ class Index extends ViewPU { }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('111'); - Text.width(30); - Text.backgroundColor(Color.Blue); - Text.height(30); + if (isInitialRender) { + Text.backgroundColor(Color.Blue); + Text.width(30); + Text.height(30); + } }, Text); Text.pop(); { @@ -201,9 +203,11 @@ class ComA extends ViewPU { }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('111'); - Text.backgroundColor(Color.Blue); - Text.width(30); - Text.height(30); + if (isInitialRender) { + Text.backgroundColor(Color.Blue); + Text.width(30); + Text.height(30); + } }, Text); Text.pop(); Row.pop(); @@ -241,9 +245,11 @@ class ComB extends ViewPU { }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('111'); - Text.width(30); - Text.height(30); - Text.backgroundColor(Color.Blue); + if (isInitialRender) { + Text.backgroundColor(Color.Blue); + Text.width(30); + Text.height(30); + } }, Text); Text.pop(); Row.pop(); @@ -281,11 +287,13 @@ class MyComponent extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('Text1'); - Text.fontSize(50); - Text.fontColor(Color.White); ViewStackProcessor.visualState("normal"); Text.backgroundColor(Color.Gray); ViewStackProcessor.visualState(); + if (isInitialRender) { + Text.fontSize(50); + Text.fontColor(Color.White); + } }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageLink/@storageLink.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageLink/@storageLink.ts index e2b09491681b7af50b531460f43518dc07f49e13..fe2ee0e3b63dbb36689daa60c97c3116ec0b3089 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageLink/@storageLink.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageLink/@storageLink.ts @@ -108,22 +108,26 @@ class MyComponent extends ViewPU { }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.label + ': ' + this.varA); - Button.onClick(() => { - AppStorage.Set('varA', AppStorage.Get('varA') + 1); - }); + if (isInitialRender) { + Button.onClick(() => { + AppStorage.Set('varA', AppStorage.Get('varA') + 1); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel('lang: ' + this.lang); - Button.onClick(() => { - if (this.lang === 'zh') { - AppStorage.Set('languageCode', 'en'); - } - else { - AppStorage.Set('languageCode', 'zh'); - } - this.label = (this.lang === 'zh') ? '数' : 'Count'; - }); + if (isInitialRender) { + Button.onClick(() => { + if (this.lang === 'zh') { + AppStorage.Set('languageCode', 'en'); + } + else { + AppStorage.Set('languageCode', 'zh'); + } + this.label = (this.lang === 'zh') ? '数' : 'Count'; + }); + } }, Button); Button.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageProp/@storageProp.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageProp/@storageProp.ts index e2b09491681b7af50b531460f43518dc07f49e13..fe2ee0e3b63dbb36689daa60c97c3116ec0b3089 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageProp/@storageProp.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageProp/@storageProp.ts @@ -108,22 +108,26 @@ class MyComponent extends ViewPU { }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.label + ': ' + this.varA); - Button.onClick(() => { - AppStorage.Set('varA', AppStorage.Get('varA') + 1); - }); + if (isInitialRender) { + Button.onClick(() => { + AppStorage.Set('varA', AppStorage.Get('varA') + 1); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel('lang: ' + this.lang); - Button.onClick(() => { - if (this.lang === 'zh') { - AppStorage.Set('languageCode', 'en'); - } - else { - AppStorage.Set('languageCode', 'zh'); - } - this.label = (this.lang === 'zh') ? '数' : 'Count'; - }); + if (isInitialRender) { + Button.onClick(() => { + if (this.lang === 'zh') { + AppStorage.Set('languageCode', 'en'); + } + else { + AppStorage.Set('languageCode', 'zh'); + } + this.label = (this.lang === 'zh') ? '数' : 'Count'; + }); + } }, Button); Button.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/appStorage/appStorage.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/appStorage/appStorage.ts index e2b09491681b7af50b531460f43518dc07f49e13..fe2ee0e3b63dbb36689daa60c97c3116ec0b3089 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/appStorage/appStorage.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/appStorage/appStorage.ts @@ -108,22 +108,26 @@ class MyComponent extends ViewPU { }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.label + ': ' + this.varA); - Button.onClick(() => { - AppStorage.Set('varA', AppStorage.Get('varA') + 1); - }); + if (isInitialRender) { + Button.onClick(() => { + AppStorage.Set('varA', AppStorage.Get('varA') + 1); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel('lang: ' + this.lang); - Button.onClick(() => { - if (this.lang === 'zh') { - AppStorage.Set('languageCode', 'en'); - } - else { - AppStorage.Set('languageCode', 'zh'); - } - this.label = (this.lang === 'zh') ? '数' : 'Count'; - }); + if (isInitialRender) { + Button.onClick(() => { + if (this.lang === 'zh') { + AppStorage.Set('languageCode', 'en'); + } + else { + AppStorage.Set('languageCode', 'zh'); + } + this.label = (this.lang === 'zh') ? '数' : 'Count'; + }); + } }, Button); Button.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorage.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorage.ts index 4b16ba7481bdf08d4e50264054b980f011f128a3..f9328559b2ddc1ed848e187495deea598d060253 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorage.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorage.ts @@ -100,14 +100,18 @@ class LocalStorageComponent extends ViewPU { PUV2ViewBase.contextStack && PUV2ViewBase.contextStack.push(this); this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.height(500); + if (isInitialRender) { + Column.height(500); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.objectName.a); - Text.onClick(() => { - this.simpleVarName += 1; - this.objectName.a = this.objectName.a === 'x' ? 'yex' : 'no'; - }); + if (isInitialRender) { + Text.onClick(() => { + this.simpleVarName += 1; + this.objectName.a = this.objectName.a === 'x' ? 'yex' : 'no'; + }); + } }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForBoth.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForBoth.ts index 17ef7bbe8f962a7df488eff572300a0370e2d43c..d6be2afdd365d23302b835e770084a96e5405703 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForBoth.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForBoth.ts @@ -105,14 +105,18 @@ class LocalStorageComponent extends ViewPU { PUV2ViewBase.contextStack && PUV2ViewBase.contextStack.push(this); this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.height(500); + if (isInitialRender) { + Column.height(500); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.objectName.a); - Text.onClick(() => { - this.simpleVarName += 1; - this.objectName.a = this.objectName.a === 'x' ? 'yex' : 'no'; - }); + if (isInitialRender) { + Text.onClick(() => { + this.simpleVarName += 1; + this.objectName.a = this.objectName.a === 'x' ? 'yex' : 'no'; + }); + } }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForRoute.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForRoute.ts index 8ca817822eb8767cf22ad2338187df16eb3caa80..ae2f4f4febf67a0851019b3df3265bb75ddd8b41 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForRoute.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForRoute.ts @@ -60,7 +60,9 @@ class LocalStorageComponent extends ViewPU { PUV2ViewBase.contextStack && PUV2ViewBase.contextStack.push(this); this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.height(500); + if (isInitialRender) { + Column.height(500); + } }, Column); Column.pop(); PUV2ViewBase.contextStack && PUV2ViewBase.contextStack.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForStorage.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForStorage.ts index 9c135566b7418c81d27c869c1affea9151c49aa7..e214e6f198aa3044376e4b551e154b454cab9d74 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForStorage.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForStorage.ts @@ -102,14 +102,18 @@ class LocalStorageComponent extends ViewPU { PUV2ViewBase.contextStack && PUV2ViewBase.contextStack.push(this); this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.height(500); + if (isInitialRender) { + Column.height(500); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.objectName.a); - Text.onClick(() => { - this.simpleVarName += 1; - this.objectName.a = this.objectName.a === 'x' ? 'yex' : 'no'; - }); + if (isInitialRender) { + Text.onClick(() => { + this.simpleVarName += 1; + this.objectName.a = this.objectName.a === 'x' ? 'yex' : 'no'; + }); + } }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_@provide.ts b/compiler/test/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_@provide.ts index 71f2517fa4b5ad3a40cb0c937c94b86f224db4f7..b08f5a3f779b104214d7a9419582cd58a6f4c937 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_@provide.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_@provide.ts @@ -136,13 +136,17 @@ class CompA extends ViewPU { } this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithChild(); - Button.onClick(() => { - this.reviewVotes += 1; - }); + if (isInitialRender) { + Button.onClick(() => { + this.reviewVotes += 1; + }); + } }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('' + this.reviewVotes); - Text.fontSize(30); + if (isInitialRender) { + Text.fontSize(30); + } }, Text); Text.pop(); Button.pop(); @@ -238,13 +242,17 @@ class CompC extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithChild(); - Button.onClick(() => { - this.reviewVotes += 1; - }); + if (isInitialRender) { + Button.onClick(() => { + this.reviewVotes += 1; + }); + } }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('' + this.reviewVotes); - Text.fontSize(30); + if (isInitialRender) { + Text.fontSize(30); + } }, Text); Text.pop(); Button.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/others/@watch/@watch.ts b/compiler/test/utForPartialUpdate/ui_state_management/others/@watch/@watch.ts index d422faa8577613281785a95bb9a521b52a8d1374..e7d14e26504da8fb1077f456ce1bf1cfa53ce6f1 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/others/@watch/@watch.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/others/@watch/@watch.ts @@ -170,28 +170,36 @@ class CompA extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel("add to basket"); - Button.onClick(() => { - this.shopBasket.push(Math.round(100 * Math.random())); - }); + if (isInitialRender) { + Button.onClick(() => { + this.shopBasket.push(Math.round(100 * Math.random())); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('totalPurchase: ' + this.totalPurchase); - Text.fontSize(20); + if (isInitialRender) { + Text.fontSize(20); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel("put item"); - Button.onClick(() => { - let alList = 'abcdefghijklmnopqrstuvwxyz'; - let ranItem = alList[Math.floor(Math.random() * 26)]; - this.defArray.push(ranItem); - }); + if (isInitialRender) { + Button.onClick(() => { + let alList = 'abcdefghijklmnopqrstuvwxyz'; + let ranItem = alList[Math.floor(Math.random() * 26)]; + this.defArray.push(ranItem); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('tips: ' + this.resultTip); - Text.fontSize(20); + if (isInitialRender) { + Text.fontSize(20); + } }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/v2_component_decorator/builderParamStyles.ts b/compiler/test/utForPartialUpdate/v2_component_decorator/builderParamStyles.ts index 2fa6d405cbec1402c3b6600e63dadb12eaf357f2..98e1845b8d880f7ba245d87b408c7678bf9e8330 100644 --- a/compiler/test/utForPartialUpdate/v2_component_decorator/builderParamStyles.ts +++ b/compiler/test/utForPartialUpdate/v2_component_decorator/builderParamStyles.ts @@ -98,8 +98,10 @@ class HomeComponent extends ViewV2 { }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("hello HomeComponent"); - Text.fontSize(30); - Text.backgroundColor(Color.Red); + if (isInitialRender) { + Text.backgroundColor(Color.Red); + Text.fontSize(30); + } }, Text); Text.pop(); Button.pop();