From 9b86f2ddd7169a6d84a1b56db27410cebfde00ce Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 26 Nov 2024 10:05:18 +0100 Subject: [PATCH] fix: refs #8113 ensure data is an array before assignment and optimize data processing loop --- src/composables/useArrayData.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index 2ddedd7c8..030b4b49c 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -289,10 +289,10 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { store.map = new Map(); } - if (!map && !append) store.data = data; + if (!Array.isArray(data) || (!map && !append)) store.data = data; else if (!map && append) for (const row of data) store.data.push(row); else - data.forEach((row) => { + for (const row of data) { const key = row[store.mapKey]; const val = { ...row, key }; if (store.map.has(key)) { @@ -305,7 +305,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { store.map.set(key, val); store.data.push(val); } - }); + } } const totalRows = computed(() => (store.data && store.data.length) || 0);