From 49589611ee0a0b3c7fac88218276a25bc8233146 Mon Sep 17 00:00:00 2001 From: Kevin Brown Date: Fri, 21 Aug 2015 19:12:13 -0400 Subject: [PATCH] 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 --- src/js/select2/data/tokenizer.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/js/select2/data/tokenizer.js b/src/js/select2/data/tokenizer.js index 456f9b2c..4a0faef6 100644 --- a/src/js/select2/data/tokenizer.js +++ b/src/js/select2/data/tokenizer.js @@ -72,6 +72,11 @@ define([ var data = createTag(partParams); + if (data == null) { + i++; + continue; + } + callback(data); // Reset the term to not include the tokenized portion