Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
Merge pull request #985 from delcroip/patch-1
Browse files Browse the repository at this point in the history
use map instead of object
  • Loading branch information
eyelidlessness committed Aug 4, 2023
2 parents d1197cc + 64a73f9 commit f37eed2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/js/form-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const FormModel = function (data, options) {
options.full = typeof options.full !== 'undefined' ? options.full : true;

this.events = document.createElement('div');
this.convertedExpressions = {};
this.convertedExpressions = new Map();
this.templates = {};
this.loadErrors = [];

Expand Down Expand Up @@ -1424,7 +1424,9 @@ FormModel.prototype.evaluate = function (
cacheable = original === expr;

// if no cached conversion exists
if (!this.convertedExpressions[cacheKey]) {
const cachedExpr = this.convertedExpressions.get(cacheKey);

if (cachedExpr === undefined) {
expr = expr.trim();
expr = this.replaceInstanceFn(expr);
expr = this.replaceVersionFn(expr);
Expand All @@ -1439,11 +1441,12 @@ FormModel.prototype.evaluate = function (
expr = expr.replace(/&lt;/g, '<');
expr = expr.replace(/&gt;/g, '>');
expr = expr.replace(/&quot;/g, '"');

if (cacheable) {
this.convertedExpressions[cacheKey] = expr;
this.convertedExpressions.set(cacheKey, expr);
}
} else {
expr = this.convertedExpressions[cacheKey];
expr = cachedExpr;
}

resultTypes = {
Expand Down

0 comments on commit f37eed2

Please sign in to comment.