Skip to content

Commit c411715

Browse files
fix JS crashing if loading taglist.js failed close #547
Use a default empty array if file cannot be loaded
1 parent 2c8a297 commit c411715

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/fn/fn.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ import Tagify from '@yaireo/tagify';
55
* @param {HTMLInputElement} inputTag
66
*/
77
export function initTagify(inputTag) {
8+
// taglist come from assets/js/taglist.js
9+
// if not successfully loaded: use empty array instead
10+
if (typeof taglist === 'undefined' || taglist === null) {
11+
var tags = [];
12+
console.log('use empty taglist');
13+
} else {
14+
var tags = taglist;
15+
}
16+
817
let tagify = new Tagify(inputTag, {
918
originalInputValueFormat: valuesArr =>
1019
valuesArr.map(item => item.value).join(', '),

0 commit comments

Comments
 (0)