Skip to content

Commit 30dac9a

Browse files
committed
export default escapeMarkup function so it can be easily accessed. select2#1222
1 parent 4e7a8b0 commit 30dac9a

1 file changed

Lines changed: 19 additions & 16 deletions

File tree

select2.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,22 @@ the specific language governing permissions and limitations under the Apache Lic
356356
markup.push(escapeMarkup(text.substring(match + tl, text.length)));
357357
}
358358

359+
function defaultEscapeMarkup(markup) {
360+
var replace_map = {
361+
'\\': '\',
362+
'&': '&',
363+
'<': '&lt;',
364+
'>': '&gt;',
365+
'"': '&quot;',
366+
"'": '&#39;',
367+
"/": '&#47;'
368+
};
369+
370+
return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
371+
return replace_map[match];
372+
});
373+
}
374+
359375
/**
360376
* Produces an ajax-based query function
361377
*
@@ -3091,21 +3107,7 @@ the specific language governing permissions and limitations under the Apache Lic
30913107
separator: ",",
30923108
tokenSeparators: [],
30933109
tokenizer: defaultTokenizer,
3094-
escapeMarkup: function (markup) {
3095-
var replace_map = {
3096-
'\\': '&#92;',
3097-
'&': '&amp;',
3098-
'<': '&lt;',
3099-
'>': '&gt;',
3100-
'"': '&quot;',
3101-
"'": '&#39;',
3102-
"/": '&#47;'
3103-
};
3104-
3105-
return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
3106-
return replace_map[match];
3107-
});
3108-
},
3110+
escapeMarkup: defaultEscapeMarkup,
31093111
blurOnChange: false,
31103112
selectOnBlur: false,
31113113
adaptContainerCssClass: function(c) { return c; },
@@ -3129,7 +3131,8 @@ the specific language governing permissions and limitations under the Apache Lic
31293131
tags: tags
31303132
}, util: {
31313133
debounce: debounce,
3132-
markMatch: markMatch
3134+
markMatch: markMatch,
3135+
escapeMarkup: defaultEscapeMarkup
31333136
}, "class": {
31343137
"abstract": AbstractSelect2,
31353138
"single": SingleSelect2,

0 commit comments

Comments
 (0)