diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-12-20 21:51:34 -0500 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-12-20 21:51:34 -0500 |
commit | d7bf12833318e51c04b47ae3a6fa0379bd060406 (patch) | |
tree | cd4dda07c66867e5ebfe7a4bf63b39e88e001b5c | |
parent | 2519f99f54412933beed8b2c753c76662099f8e0 (diff) |
Update handlebars cache
-rw-r--r-- | ext/bg/js/handlebars.js | 11 |
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(); |