From 30dac9a40b6ed9c2d31293ca7be81203d79fe71d Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Tue, 4 Jun 2013 08:42:46 -0700 Subject: [PATCH] export default escapeMarkup function so it can be easily accessed. #1222 --- select2.js | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/select2.js b/select2.js index 6b03c579..8db94e4d 100644 --- a/select2.js +++ b/select2.js @@ -356,6 +356,22 @@ the specific language governing permissions and limitations under the Apache Lic markup.push(escapeMarkup(text.substring(match + tl, text.length))); } + function defaultEscapeMarkup(markup) { + var replace_map = { + '\\': '\', + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + "/": '/' + }; + + return String(markup).replace(/[&<>"'\/\\]/g, function (match) { + return replace_map[match]; + }); + } + /** * Produces an ajax-based query function * @@ -3091,21 +3107,7 @@ the specific language governing permissions and limitations under the Apache Lic separator: ",", tokenSeparators: [], tokenizer: defaultTokenizer, - escapeMarkup: function (markup) { - var replace_map = { - '\\': '\', - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''', - "/": '/' - }; - - return String(markup).replace(/[&<>"'\/\\]/g, function (match) { - return replace_map[match]; - }); - }, + escapeMarkup: defaultEscapeMarkup, blurOnChange: false, selectOnBlur: false, adaptContainerCssClass: function(c) { return c; }, @@ -3129,7 +3131,8 @@ the specific language governing permissions and limitations under the Apache Lic tags: tags }, util: { debounce: debounce, - markMatch: markMatch + markMatch: markMatch, + escapeMarkup: defaultEscapeMarkup }, "class": { "abstract": AbstractSelect2, "single": SingleSelect2,