Skip to content

Commit 4958961

Browse files
committed
Handle null being returned from createTag
The `createTag` option does allow for `null` to be returned if a tag should not be created. The tokenizer previously didn't support this, so the tokenizer should be able to handle this case. Previously it would trigger an exception, because the tokenizer would pass back a null value to the select function. This also fixes what would have been a potential bug where even if a tag was not created, the term would still have been sliced at the location of the token. This allows for tokenizers to have special cases when tokenizing the term, such as not splittting a token if it is in the middle of a quoted string. This closes select2#3593 This closes select2#3591
1 parent d9c1cbc commit 4958961

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/js/select2/data/tokenizer.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ define([
7272

7373
var data = createTag(partParams);
7474

75+
if (data == null) {
76+
i++;
77+
continue;
78+
}
79+
7580
callback(data);
7681

7782
// Reset the term to not include the tokenized portion

0 commit comments

Comments
 (0)