Skip to content

Commit f3c6c05

Browse files
authored
Merge pull request #12 from scottnath/hotfix/file-get
Hotfix/file get
2 parents af05726 + 5b0dd27 commit f3c6c05

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ module.exports = {
2929
function: 'fileValidation',
3030
on: 'change',
3131
},
32+
script: {
33+
function: 'fileScript',
34+
on: 'change',
35+
},
3236
type: 'file',
3337
label: 'Upload a file',
3438
settings: {

lib/script.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,23 @@ module.exports = function fileScript(input, settings) {
100100

101101
if (target.checked) {
102102
link.style.display = 'none';
103+
if (upload.value) {
104+
upload.value = '';
105+
link = clear(link);
106+
}
103107
}
104108
else {
105109
link.style.display = '';
106110
}
107111
}
108112

109-
// actions on the file input element
110-
upload.addEventListener('change', uploadHandler);
113+
if (upload) {
114+
// actions on the file input element
115+
upload.addEventListener('change', uploadHandler);
116+
}
111117

112-
// actions on the checkbox element
113-
checkbox.addEventListener('change', checkboxHandler);
118+
if (checkbox) {
119+
// actions on the checkbox element
120+
checkbox.addEventListener('change', checkboxHandler);
121+
}
114122
};

0 commit comments

Comments
 (0)