From d7bf12833318e51c04b47ae3a6fa0379bd060406 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Fri, 20 Dec 2019 21:51:34 -0500 Subject: [PATCH] Update handlebars cache --- ext/bg/js/handlebars.js | 11 ++++++----- 1 file 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();