summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-20 21:51:34 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-20 21:51:34 -0500
commitd7bf12833318e51c04b47ae3a6fa0379bd060406 (patch)
treecd4dda07c66867e5ebfe7a4bf63b39e88e001b5c /ext
parent2519f99f54412933beed8b2c753c76662099f8e0 (diff)
Update handlebars cache
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/handlebars.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/ext/bg/js/handlebars.js b/ext/bg/js/handlebars.js
index 8f43cf9a..b57ba738 100644
--- a/ext/bg/js/handlebars.js
+++ b/ext/bg/js/handlebars.js
@@ -141,12 +141,13 @@ function handlebarsRenderStatic(name, data) {
function handlebarsRenderDynamic(template, data) {
handlebarsRegisterHelpers();
-
- Handlebars.yomichan_cache = Handlebars.yomichan_cache || {};
- let instance = Handlebars.yomichan_cache[template];
- if (!instance) {
- instance = Handlebars.yomichan_cache[template] = Handlebars.compile(template);
+ const cache = handlebarsRenderDynamic._cache;
+ let instance = cache.get(template);
+ if (typeof instance === 'undefined') {
+ instance = Handlebars.compile(template);
+ cache.set(template, instance);
}
return instance(data).trim();
}
+handlebarsRenderDynamic._cache = new Map();