Skip to content

[1.x] Ensure template instance isn't cached on prototype. Fixes #5096 #5102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/lib/template/templatizer.html
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,13 @@
},

_customPrepAnnotations: function(archetype, template) {
archetype._template = template;
var c = template._content;
// Store a "clone" of the template on the archetype to ensure no
// references on this template are leaked onto the cached archetype
// Note we don't actually clone the template since it could be
// a type-extension; rather we create a new one and copy the
// `_content` reference holding the prototypical content over
var t = archetype._template = document.createElement('template');
var c = t._content = template._content;
if (!c._notes) {
var rootDataHost = archetype._rootDataHost;
if (rootDataHost) {
Expand Down
4 changes: 4 additions & 0 deletions test/unit/templatizer-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@
});
var parent = Polymer.dom(this).parentNode;
Polymer.dom(parent).appendChild(this.instance.root);
// Ensure templatizer class does not leak reference to dataHost
assert.notOk(this.ctor.prototype._template.dataHost, 'templatizer class should not leak reference to dataHost');
}
});

Expand Down Expand Up @@ -196,6 +198,8 @@
});
var parent = Polymer.dom(this).parentNode;
Polymer.dom(parent).appendChild(this.instance.root);
// Ensure templatizer class does not leak reference to dataHost
assert.notOk(this.ctor.prototype._template.dataHost, 'templatizer class should not leak reference to dataHost');
}
});

Expand Down