Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 1193c63

Browse files
committed
Check that items exist and are an array before looping
1 parent ca0a78b commit 1193c63

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

resources/js/components/Importer.vue

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ export default {
104104
duplicateCount: function (items) {
105105
let count = 0;
106106
107-
Object.keys(items).forEach((key) => {
108-
if (!items[key].exists) {
107+
if (!items || !Array.isArray(items)) return count;
108+
109+
items.forEach((item) => {
110+
if (!item.exists) {
109111
return;
110112
}
111113
@@ -116,24 +118,28 @@ export default {
116118
},
117119
118120
uncheckDuplicates: function (items) {
119-
Object.keys(items).forEach((key) => {
120-
if (!items[key].exists) {
121+
if (!items || !Array.isArray(items)) return;
122+
123+
items.forEach((item) => {
124+
if (!item.exists) {
121125
return;
122126
}
123127
124-
items[key]._checked = false;
128+
item._checked = false;
125129
});
126130
},
127131
128132
uncheckAll: function (items) {
129-
Object.keys(items).forEach((key) => {
130-
items[key]._checked = false;
133+
if (!items || !Array.isArray(items)) return;
134+
items.forEach((item) => {
135+
item._checked = false;
131136
});
132137
},
133138
134139
checkAll: function (items) {
135-
Object.keys(items).forEach((key) => {
136-
items[key]._checked = true;
140+
if (!items || !Array.isArray(items)) return;
141+
items.forEach((item) => {
142+
item._checked = true;
137143
});
138144
},
139145

0 commit comments

Comments
 (0)