1
0
mirror of synced 2024-11-26 06:46:04 +03:00

Handle translations like template options

Translations will now be passed through `escapeMarkup` and injected
into the results messages as HTML just like the templating options
for the the results and selections.  This fixes the regression from
3.x where the old formatters always supported HTML.

This closes https://github.com/select2/select2/issues/3008.
This commit is contained in:
Kevin Brown 2015-02-06 19:29:18 -05:00
parent 78b6faf13e
commit 1766e31447
7 changed files with 37 additions and 7 deletions

View File

@ -272,6 +272,8 @@ define('select2/results',[
}; };
Results.prototype.displayMessage = function (params) { Results.prototype.displayMessage = function (params) {
var escapeMarkup = this.options.get('escapeMarkup');
this.clear(); this.clear();
this.hideLoading(); this.hideLoading();
@ -281,7 +283,11 @@ define('select2/results',[
var message = this.options.get('translations').get(params.message); var message = this.options.get('translations').get(params.message);
$message.text(message(params.args)); $message.append(
escapeMarkup(
message(params.args)
)
);
this.$results.append($message); this.$results.append($message);
}; };

View File

@ -272,6 +272,8 @@ define('select2/results',[
}; };
Results.prototype.displayMessage = function (params) { Results.prototype.displayMessage = function (params) {
var escapeMarkup = this.options.get('escapeMarkup');
this.clear(); this.clear();
this.hideLoading(); this.hideLoading();
@ -281,7 +283,11 @@ define('select2/results',[
var message = this.options.get('translations').get(params.message); var message = this.options.get('translations').get(params.message);
$message.text(message(params.args)); $message.append(
escapeMarkup(
message(params.args)
)
);
this.$results.append($message); this.$results.append($message);
}; };

View File

@ -710,6 +710,8 @@ define('select2/results',[
}; };
Results.prototype.displayMessage = function (params) { Results.prototype.displayMessage = function (params) {
var escapeMarkup = this.options.get('escapeMarkup');
this.clear(); this.clear();
this.hideLoading(); this.hideLoading();
@ -719,7 +721,11 @@ define('select2/results',[
var message = this.options.get('translations').get(params.message); var message = this.options.get('translations').get(params.message);
$message.text(message(params.args)); $message.append(
escapeMarkup(
message(params.args)
)
);
this.$results.append($message); this.$results.append($message);
}; };

File diff suppressed because one or more lines are too long

8
dist/js/select2.js vendored
View File

@ -710,6 +710,8 @@ define('select2/results',[
}; };
Results.prototype.displayMessage = function (params) { Results.prototype.displayMessage = function (params) {
var escapeMarkup = this.options.get('escapeMarkup');
this.clear(); this.clear();
this.hideLoading(); this.hideLoading();
@ -719,7 +721,11 @@ define('select2/results',[
var message = this.options.get('translations').get(params.message); var message = this.options.get('translations').get(params.message);
$message.text(message(params.args)); $message.append(
escapeMarkup(
message(params.args)
)
);
this.$results.append($message); this.$results.append($message);
}; };

File diff suppressed because one or more lines are too long

View File

@ -31,6 +31,8 @@ define([
}; };
Results.prototype.displayMessage = function (params) { Results.prototype.displayMessage = function (params) {
var escapeMarkup = this.options.get('escapeMarkup');
this.clear(); this.clear();
this.hideLoading(); this.hideLoading();
@ -40,7 +42,11 @@ define([
var message = this.options.get('translations').get(params.message); var message = this.options.get('translations').get(params.message);
$message.text(message(params.args)); $message.append(
escapeMarkup(
message(params.args)
)
);
this.$results.append($message); this.$results.append($message);
}; };