From afc99ebf0268f45f7d2a244f2b06b192d17dcf8e Mon Sep 17 00:00:00 2001 From: hutongfei Date: Sat, 6 Sep 2025 14:50:15 +0800 Subject: [PATCH] cherry-pick !70948 Issue:https://gitee.com/openharmony/arkcompiler_runtime_core/issues/ICWORH Signed-off-by: hutongfei --- .../@ohos.arkui.advanced.TabTitleBar.ets | 8 ++--- .../@ohos.arkui.advanced.ToolBarV2.ets | 6 ++-- .../arkoala-arkts/arkui-ohos/src/FrameNode.ts | 2 +- .../arkui-ohos/src/handwritten/theme/index.ts | 2 +- .../base/observeWrappedArray.ts | 30 +++++++++---------- .../incremental/runtime/src/tree/TreeNode.ts | 6 ++-- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/advanced_ui_component_static/tabtitlebar/@ohos.arkui.advanced.TabTitleBar.ets b/advanced_ui_component_static/tabtitlebar/@ohos.arkui.advanced.TabTitleBar.ets index 277b5183143..9a535516a0c 100644 --- a/advanced_ui_component_static/tabtitlebar/@ohos.arkui.advanced.TabTitleBar.ets +++ b/advanced_ui_component_static/tabtitlebar/@ohos.arkui.advanced.TabTitleBar.ets @@ -150,10 +150,10 @@ export struct TabTitleBar { this.tabOffsets.push(tabOffset); tabOffset += TabContentItem.marginFirst; - this.tabItems.forEach((tabItem: TabTitleBarTabItem, index: number) => { + this.tabItems.forEach((tabItem: TabTitleBarTabItem, index: int) => { if (tabItem.icon !== undefined || tabItem.symbolStyle !== undefined) { - if (Math.abs(this.imageWidths[Math.floor(index).toInt()]) > TabContentItem.imageHotZoneWidth) { - tabOffset += this.imageWidths[Math.floor(index).toInt()]; + if (Math.abs(this.imageWidths[index]) > TabContentItem.imageHotZoneWidth) { + tabOffset += this.imageWidths[index]; } else { tabOffset += TabContentItem.imageHotZoneWidth; } @@ -1088,4 +1088,4 @@ class Util { } return true; } -} \ No newline at end of file +} diff --git a/advanced_ui_component_static/toolbarv2/@ohos.arkui.advanced.ToolBarV2.ets b/advanced_ui_component_static/toolbarv2/@ohos.arkui.advanced.ToolBarV2.ets index 83ff2fbfd3c..71369fa5255 100644 --- a/advanced_ui_component_static/toolbarv2/@ohos.arkui.advanced.ToolBarV2.ets +++ b/advanced_ui_component_static/toolbarv2/@ohos.arkui.advanced.ToolBarV2.ets @@ -296,10 +296,10 @@ export struct ToolBarV2 { @Computed get getMenus(): MenuElement[] { let menuContent: MenuElement[] = [] as MenuElement[]; - this.toolBarList.forEach((value: ToolBarV2Item, index: number) => { + this.toolBarList.forEach((value: ToolBarV2Item, index: int) => { if (index >= TOOLBAR_MAX_LENGTH - 1) { menuContent.push({ - value: this.toolBarList[Double.toInt(index)].content.text, + value: this.toolBarList[index].content.text, action: () => { let callback: ToolBarV2ItemAction | undefined = this.toolBarList[Double.toInt(index)].action; if (callback) { @@ -813,4 +813,4 @@ export struct ToolBarV2 { } .attributeModifier(this.toolBarModifier) } -} \ No newline at end of file +} diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/FrameNode.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/FrameNode.ts index 079db9d32a8..1213cc6b2ec 100644 --- a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/FrameNode.ts +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/FrameNode.ts @@ -2130,7 +2130,7 @@ export class NodeAdapter implements MaterializedBase { let result = new Array(); let nodes = ArkUIAniModule._NodeAdapter_GetAllItems(this.peer!.ptr!); if (nodes !== undefined) { - nodes.forEach((nodeId: number, index: number, arr: Array) => { + nodes.forEach((nodeId: number, index: int, arr: Array) => { if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) { let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId); result.push(frameNode!); diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/handwritten/theme/index.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/handwritten/theme/index.ts index 28e1a4b2f01..356d66fab18 100644 --- a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/handwritten/theme/index.ts +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/handwritten/theme/index.ts @@ -301,7 +301,7 @@ export function makeRecordfromObj(obj: Object): Record { let record: Record = {}; const keys = Object.keys(obj); const values = Object.values(obj); - keys.forEach((key: string, index: number) => { + keys.forEach((key: string, index: int) => { record[key] = values[index as int32]; }) return record; diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/stateManagement/base/observeWrappedArray.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/stateManagement/base/observeWrappedArray.ts index e3a718dc3a0..eb4ee187f36 100755 --- a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/stateManagement/base/observeWrappedArray.ts +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/stateManagement/base/observeWrappedArray.ts @@ -432,7 +432,7 @@ export class WrappedArray extends Array implements IObservedObject, Observ * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. * @returns New `Array` instance constructed from `this` with elements filtered using test function `predicate`. */ - public override filter(predicate: (value: T, index: number, array: Array) => boolean): Array { + public override filter(predicate: (value: T, index: int, array: Array) => boolean): Array { this.meta_.addRef(CONSTANT.OB_ARRAY_ANY_KEY); return this.store_.filter(predicate); } @@ -475,7 +475,7 @@ export class WrappedArray extends Array implements IObservedObject, Observ * @param fn a function to apply * @return new Array after map and than flat */ - public override flatMap(fn: (v: T, k: number, arr: Array) => U): Array { + public override flatMap(fn: (v: T, k: int, arr: Array) => U): Array { this.meta_.addRef(CONSTANT.OB_ARRAY_ANY_KEY); return this.store_.flatMap(fn); } @@ -635,7 +635,7 @@ export class WrappedArray extends Array implements IObservedObject, Observ * immediately returns that element value. Otherwise, find returns undefined. * @returns the value of the first element in the array or undefined */ - public override find(predicate: (value: T, index: number, array: Array) => boolean): T | undefined { + public override find(predicate: (value: T, index: int, array: Array) => boolean): T | undefined { this.meta_.addRef(CONSTANT.OB_ARRAY_ANY_KEY); return this.store_.find(predicate); } @@ -649,7 +649,7 @@ export class WrappedArray extends Array implements IObservedObject, Observ * findIndex immediately returns that element index. Otherwise, findIndex returns -1. * @returns found element index or -1 otherwise */ - public override findIndex(predicate: (value: T, index: number, array: Array) => boolean): number { + public override findIndex(predicate: (value: T, index: int, array: Array) => boolean): number { this.meta_.addRef(CONSTANT.OB_ARRAY_ANY_KEY); return this.store_.findIndex(predicate); } @@ -661,7 +661,7 @@ export class WrappedArray extends Array implements IObservedObject, Observ * @param predicate testing function * @returns found element or undefined otherwise */ - public override findLast(predicate: (elem: T, index: number, array: Array) => boolean): T | undefined { + public override findLast(predicate: (elem: T, index: int, array: Array) => boolean): T | undefined { this.meta_.addRef(CONSTANT.OB_ARRAY_ANY_KEY); return this.store_.findLast(predicate); } @@ -674,7 +674,7 @@ export class WrappedArray extends Array implements IObservedObject, Observ * which is coercible to the Boolean value false, or until the end of the array. * @returns `true` if `predicate` returns a `true` value for every array element. Otherwise, `false`. */ - public override every(predicate: (value: T, index: number, array: Array) => boolean): boolean { + public override every(predicate: (value: T, index: int, array: Array) => boolean): boolean { this.meta_.addRef(CONSTANT.OB_ARRAY_ANY_KEY); return this.store_.every(predicate); } @@ -687,7 +687,7 @@ export class WrappedArray extends Array implements IObservedObject, Observ * which is coercible to the Boolean value true, or until the end of the array. * @returns `true` if `predicate` returns a `true` value for at least one array element. Otherwise, `false`. */ - public override some(predicate: (value: T, index: number, array: Array) => boolean): boolean { + public override some(predicate: (value: T, index: int, array: Array) => boolean): boolean { this.meta_.addRef(CONSTANT.OB_ARRAY_ANY_KEY); return this.store_.some(predicate); } @@ -700,7 +700,7 @@ export class WrappedArray extends Array implements IObservedObject, Observ * @param predicate testing function * @returns index of first element satisfying to predicate, -1 if no such element */ - public override findLastIndex(predicate: (element: T, index: number, array: Array) => boolean): number { + public override findLastIndex(predicate: (element: T, index: int, array: Array) => boolean): number { this.meta_.addRef(CONSTANT.OB_ARRAY_ANY_KEY); return this.store_.findLastIndex(predicate); } @@ -711,7 +711,7 @@ export class WrappedArray extends Array implements IObservedObject, Observ * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. * @returns a result after applying callbackfn over all elements of the Array */ - public override reduce(callbackfn: (previousValue: T, currentValue: T, index: number, array: Array) => T): T { + public override reduce(callbackfn: (previousValue: T, currentValue: T, index: int, array: Array) => T): T { this.meta_.addRef(CONSTANT.OB_ARRAY_ANY_KEY); return this.store_.reduce(callbackfn); } @@ -724,7 +724,7 @@ export class WrappedArray extends Array implements IObservedObject, Observ * @returns a result after applying callbackfn over all elements of the Array */ public override reduce( - callbackfn: (previousValue: U, currentValue: T, index: number, array: Array) => U, + callbackfn: (previousValue: U, currentValue: T, index: int, array: Array) => U, initialValue: U ): U { this.meta_.addRef(CONSTANT.OB_ARRAY_ANY_KEY); @@ -738,7 +738,7 @@ export class WrappedArray extends Array implements IObservedObject, Observ * @returns a result after applying callbackfn over all elements of the Array */ public override reduceRight( - callbackfn: (previousValue: T, currentValue: T, index: number, array: Array) => T + callbackfn: (previousValue: T, currentValue: T, index: int, array: Array) => T ): T { this.meta_.addRef(CONSTANT.OB_ARRAY_ANY_KEY); return this.store_.reduceRight(callbackfn); @@ -752,7 +752,7 @@ export class WrappedArray extends Array implements IObservedObject, Observ * @returns a result after applying callbackfn over all elements of the Array */ public override reduceRight( - callbackfn: (previousValue: U, currentValue: T, index: number, array: Array) => U, + callbackfn: (previousValue: U, currentValue: T, index: int, array: Array) => U, initialValue: U ): U { this.meta_.addRef(CONSTANT.OB_ARRAY_ANY_KEY); @@ -764,14 +764,14 @@ export class WrappedArray extends Array implements IObservedObject, Observ * * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. */ - public override forEach(callbackfn: (value: T, index: number, array: Array) => void): void { + public override forEach(callbackfn: (value: T, index: int, array: Array) => void): void { // same V2, forEach triggers this addRef! const shouldAddRef = this.shouldAddRef(); if (shouldAddRef) { this.meta_.addRef(CONSTANT.OB_LENGTH); } // Similar to V2! - const observedCb = (value: T, index: number, array: Array) => { + const observedCb = (value: T, index: int, array: Array) => { if (shouldAddRef) { this.meta_.addRef(String(index as Object | undefined | null)); } @@ -1100,7 +1100,7 @@ export class WrappedArray extends Array implements IObservedObject, Observ * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @returns `Array` instance, constructed from `this` and given function. */ - public override map(callbackfn: (value: T, index: number, array: Array) => U): Array { + public override map(callbackfn: (value: T, index: int, array: Array) => U): Array { if (this.shouldAddRef()) { this.meta_.addRef(CONSTANT.OB_ARRAY_ANY_KEY); } diff --git a/frameworks/bridge/arkts_frontend/koala_projects/incremental/runtime/src/tree/TreeNode.ts b/frameworks/bridge/arkts_frontend/koala_projects/incremental/runtime/src/tree/TreeNode.ts index 634f682f170..1ce56bb6c67 100644 --- a/frameworks/bridge/arkts_frontend/koala_projects/incremental/runtime/src/tree/TreeNode.ts +++ b/frameworks/bridge/arkts_frontend/koala_projects/incremental/runtime/src/tree/TreeNode.ts @@ -136,7 +136,7 @@ export class TreeNode implements Disposable, ReadonlyTreeNode { */ forEach(action: (node: TreeNode, index: float64) => void): void { // must be int32, but ArkTS array.forEach requires index to be float64 - this.myChildren.forEach(action) + this.myChildren.forEach((n, i) => action(n, i)) } /** @@ -144,7 +144,7 @@ export class TreeNode implements Disposable, ReadonlyTreeNode { */ every(predicate: (node: TreeNode, index: float64) => boolean): boolean { // must be int32, but ArkTS array.every requires index to be float64 - return this.myChildren.every(predicate) + return this.myChildren.every((n, i) => predicate(n, i)) } /** @@ -152,7 +152,7 @@ export class TreeNode implements Disposable, ReadonlyTreeNode { */ some(predicate: (node: TreeNode, index: float64) => boolean): boolean { // must be int32, but ArkTS array.some requires index to be float64 - return this.myChildren.some(predicate) + return this.myChildren.some((n, i) => predicate(n, i)) } /** -- Gitee