Skip to content

Commit 66b371b

Browse files
authored
fix: change iteration method in items container that may return undefined
1 parent 7c7b711 commit 66b371b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

ui/js/c-preview.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// IPREVIEW
1+
// CPREVIEW v0.2.2
22
// A JS library to display data from input type=file
33
const cPreview = {
44
/**
@@ -198,14 +198,14 @@ const cPreview = {
198198
// console.log('no valid file template, using default');
199199
}
200200
// Mark each file item with a specific class
201-
el_target_container.childNodes.forEach(function(el_target_item, item_index) {
201+
Object.keys(el_target_container.children).forEach(function(index) {
202202
// Avoid first child which is always the remove all files button
203-
if (item_index == 0) {
204-
el_target_item.classList.add('cpreview-remove');
203+
if (index == '0') {
204+
el_target_container.children[index].classList.add('cpreview-remove');
205205
} else {
206-
el_target_item.classList.add('cpreview-item');
206+
el_target_container.children[index].classList.add('cpreview-item');
207207
}
208-
});
208+
})
209209
}
210210
// Convert to base64 string
211211
reader.readAsDataURL(el_file);
@@ -218,4 +218,4 @@ const cPreview = {
218218
});
219219
}
220220
}
221-
cPreview.update();
221+
cPreview.update();

0 commit comments

Comments
 (0)