Permalink
Browse files

fix(templateCache): Changed templateCache to a WeakMap

  • Loading branch information...
calebdwilliams committed Jan 11, 2018
1 parent 48d6e92 commit d184288face5707bdd49c9815ea6f1d34cc972f5
@@ -208,20 +208,19 @@ class Template {
}
}

const templateCache = new Map();
const templateCache = new WeakMap();

function templiteral(location = this, context = this) {
location.shadowRoot ? location = location.shadowRoot : null;

return (strings, ...values) => {
const templateKey = (strings.join(''));
let compiler = templateCache.get(templateKey);
let compiler = templateCache.get(location);

if (compiler) {
compiler.update(values);
} else {
compiler = new Template(strings, values, location, context);
templateCache.set(templateKey, compiler);
templateCache.set(location, compiler);
}

return compiler;

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -204,20 +204,19 @@ class Template {
}
}

const templateCache = new Map();
const templateCache = new WeakMap();

function templiteral(location = this, context = this) {
location.shadowRoot ? location = location.shadowRoot : null;

return (strings, ...values) => {
const templateKey = (strings.join(''));
let compiler = templateCache.get(templateKey);
let compiler = templateCache.get(location);

if (compiler) {
compiler.update(values);
} else {
compiler = new Template(strings, values, location, context);
templateCache.set(templateKey, compiler);
templateCache.set(location, compiler);
}

return compiler;
Oops, something went wrong.

0 comments on commit d184288

Please sign in to comment.