Browse Source

Optimize `Writer.prototype.escapedValue` for numbers (#754)

These changes optimizes the performance of escaping number
values, by not passing them through the ordinary HTML escaping
that is done on string values.
tags/v4.1.0
urain39 GitHub 4 years ago
parent
commit
4dc00b8a9c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions
  1. +1
    -1
      mustache.js
  2. +1
    -1
      mustache.min.js
  3. +1
    -1
      mustache.mjs

+ 1
- 1
mustache.js View File

@@ -657,7 +657,7 @@
Writer.prototype.escapedValue = function escapedValue (token, context) {
var value = context.lookup(token[1]);
if (value != null)
return mustache.escape(value);
return typeof value === 'number' ? String(value) : mustache.escape(value);
};

Writer.prototype.rawValue = function rawValue (token) {


+ 1
- 1
mustache.min.js
File diff suppressed because it is too large
View File


+ 1
- 1
mustache.mjs View File

@@ -650,7 +650,7 @@ Writer.prototype.unescapedValue = function unescapedValue (token, context) {
Writer.prototype.escapedValue = function escapedValue (token, context) {
var value = context.lookup(token[1]);
if (value != null)
return mustache.escape(value);
return typeof value === 'number' ? String(value) : mustache.escape(value);
};

Writer.prototype.rawValue = function rawValue (token) {


Loading…
Cancel
Save