Fix `promise.then` inside `if`

This commit is contained in:
jos 2019-08-15 10:29:49 +02:00
parent 16e46878ba
commit b05af3dd44
1 changed files with 13 additions and 9 deletions

View File

@ -1499,15 +1499,19 @@ treemode._showAutoComplete = function (element) {
self.autocomplete.hideDropDown();
} else if (typeof result.then === 'function') {
// probably a promise
if (result.then(function (obj) {
if (obj === null) {
self.autocomplete.hideDropDown();
} else if (obj.options) {
self.autocomplete.show(element, obj.startFrom, obj.options);
} else {
self.autocomplete.show(element, 0, obj);
}
}.bind(self)));
result
.then(function (obj) {
if (obj === null) {
self.autocomplete.hideDropDown();
} else if (obj.options) {
self.autocomplete.show(element, obj.startFrom, obj.options);
} else {
self.autocomplete.show(element, 0, obj);
}
})
.catch(function (err) {
console.error(err);
});
} else {
// definitely not a promise
if (result.options)