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 https://github.com/select2/select2/issues/3593 This closes https://github.com/select2/select2/pull/3591
This commit is contained in:
parent
d9c1cbc976
commit
49589611ee
5
src/js/select2/data/tokenizer.js
vendored
5
src/js/select2/data/tokenizer.js
vendored
@ -72,6 +72,11 @@ define([
|
|||||||
|
|
||||||
var data = createTag(partParams);
|
var data = createTag(partParams);
|
||||||
|
|
||||||
|
if (data == null) {
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
callback(data);
|
callback(data);
|
||||||
|
|
||||||
// Reset the term to not include the tokenized portion
|
// Reset the term to not include the tokenized portion
|
||||||
|
Loading…
Reference in New Issue
Block a user