Skip to content

Commit c36b53a

Browse files
committed
fix select2#1404 allow formatnomatches to be null in multiselects
1 parent 48294f2 commit c36b53a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

select2.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ the specific language governing permissions and limitations under the Apache Lic
543543
function checkFormatter(formatter, formatterName) {
544544
if ($.isFunction(formatter)) return true;
545545
if (!formatter) return false;
546-
throw new Error("formatterName must be a function or a falsy value");
546+
throw new Error(formatterName +" must be a function or a falsy value");
547547
}
548548

549549
function evaluate(val) {
@@ -2814,7 +2814,9 @@ the specific language governing permissions and limitations under the Apache Lic
28142814
//If all results are chosen render formatNoMAtches
28152815
if(!this.opts.createSearchChoice && !choices.filter('.select2-result:not(.select2-selected)').length > 0){
28162816
if(!data || data && !data.more && this.results.find(".select2-no-results").length === 0) {
2817-
this.results.append("<li class='select2-no-results'>" + self.opts.formatNoMatches(self.search.val()) + "</li>");
2817+
if (checkFormatter(self.opts.formatNoMatches, "formatNoMatches")) {
2818+
this.results.append("<li class='select2-no-results'>" + self.opts.formatNoMatches(self.search.val()) + "</li>");
2819+
}
28182820
}
28192821
}
28202822

0 commit comments

Comments
 (0)