Skip to content

Commit 1cd7d07

Browse files
Ruud-cbRuud-cb
Ruud-cb
authored and
Ruud-cb
committed
inside switch is nicer
1 parent f0a17f3 commit 1cd7d07

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/jquery.contextMenu.js

+9-13
Original file line numberDiff line numberDiff line change
@@ -1232,11 +1232,18 @@
12321232

12331233
case 'sub':
12341234
createNameNode(item).appendTo($t);
1235-
12361235
item.appendTo = item.$node;
1237-
//op.create(item, root); decide later, might be a promise.
12381236
$t.data('contextMenu', item).addClass('context-menu-submenu');
12391237
item.callback = null;
1238+
//if item contains items, and this is a promise, we should create it later
1239+
//check if subitems is of type promise. If it is a promise we need to create it later, after promise has been resolved
1240+
if ('function' === typeof item.items.then) {
1241+
// probably a promise, process it, when completed it will create the sub menu's.
1242+
op.processPromises(item, root, item.items);
1243+
} else {
1244+
// normal submenu.
1245+
op.create(item, root);
1246+
}
12401247
break;
12411248

12421249
case 'html':
@@ -1256,17 +1263,6 @@
12561263
break;
12571264
}
12581265

1259-
if (item.type === 'sub') {
1260-
//if item contains items, and this is a promise, we should create it later
1261-
//check if subitems is of type promise. If it is a promise we need to create it later, after promise has been resolved
1262-
if ('function' === typeof item.items.then) {
1263-
// probably a promise, process it, when completed it will create the sub menu's.
1264-
op.processPromises(item, root, item.items);
1265-
} else {
1266-
// normal submenu.
1267-
op.create(item, root);
1268-
}
1269-
}
12701266
// disable key listener in <input>
12711267
if (item.type && item.type !== 'sub' && item.type !== 'html' && item.type !== 'cm_seperator') {
12721268
$input

0 commit comments

Comments
 (0)