Skip to content

Commit ef13673

Browse files
committed
move markup escaping of selection into the formatSelection callback. fixes select2#1417. fixes select2#1420
1 parent 1415567 commit ef13673

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

select2.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,7 @@ the specific language governing permissions and limitations under the Apache Lic
19111911
|| (e.which == KEY.ENTER && this.opts.openOnEnter)) {
19121912

19131913
if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) return;
1914-
1914+
19151915
this.open();
19161916
killEvent(e);
19171917
return;
@@ -2174,9 +2174,9 @@ the specific language governing permissions and limitations under the Apache Lic
21742174
this.selection.data("select2-data", data);
21752175

21762176
container.empty();
2177-
formatted=this.opts.formatSelection(data, container);
2177+
formatted=this.opts.formatSelection(data, container, this.opts.escapeMarkup);
21782178
if (formatted !== undefined) {
2179-
container.append(this.opts.escapeMarkup(formatted));
2179+
container.append(formatted);
21802180
}
21812181
cssClass=this.opts.formatSelectionCssClass(data, container);
21822182
if (cssClass !== undefined) {
@@ -2722,9 +2722,9 @@ the specific language governing permissions and limitations under the Apache Lic
27222722
formatted,
27232723
cssClass;
27242724

2725-
formatted=this.opts.formatSelection(data, choice.find("div"));
2725+
formatted=this.opts.formatSelection(data, choice.find("div"), this.opts.escapeMarkup);
27262726
if (formatted != undefined) {
2727-
choice.find("div").replaceWith("<div>"+this.opts.escapeMarkup(formatted)+"</div>");
2727+
choice.find("div").replaceWith("<div>"+formatted+"</div>");
27282728
}
27292729
cssClass=this.opts.formatSelectionCssClass(data, choice.find("div"));
27302730
if (cssClass != undefined) {
@@ -3085,8 +3085,8 @@ the specific language governing permissions and limitations under the Apache Lic
30853085
markMatch(result.text, query.term, markup, escapeMarkup);
30863086
return markup.join("");
30873087
},
3088-
formatSelection: function (data, container) {
3089-
return data ? data.text : undefined;
3088+
formatSelection: function (data, container, escapeMarkup) {
3089+
return data ? escapeMarkup(data.text) : undefined;
30903090
},
30913091
sortResults: function (results, container, query) {
30923092
return results;

0 commit comments

Comments
 (0)