Procházet zdrojové kódy

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.
Kevin Brown před 10 roky
rodič
revize
1766e31447

+ 7 - 1
dist/js/select2.amd.full.js

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

+ 7 - 1
dist/js/select2.amd.js

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

+ 7 - 1
dist/js/select2.full.js

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

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
dist/js/select2.full.min.js


+ 7 - 1
dist/js/select2.js

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

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
dist/js/select2.min.js


+ 7 - 1
src/js/select2/results.js

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

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů