From d27b4a12fbbf30feb9fcbe88a8d40847dd4249da Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Thu, 9 Aug 2018 16:50:23 -0700 Subject: [PATCH] Add a template setter to ElementMixin. Currently, to assign a template to a Polymer element, you need to override the setter, or call Object.defineProperty. This also allows users to simply assign the template onto their constructor. This is especially useful for TypeScript, which compiles "static template = foo" to "MyClass.template = foo". --- lib/mixins/element-mixin.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/mixins/element-mixin.js b/lib/mixins/element-mixin.js index 861d1b120f..7bf6057d3b 100644 --- a/lib/mixins/element-mixin.js +++ b/lib/mixins/element-mixin.js @@ -375,7 +375,7 @@ export const ElementMixin = dedupingMixin(base => { * } * } * - * @return {HTMLTemplateElement|string} Template to be stamped + * @return {!HTMLTemplateElement|string} Template to be stamped */ static get template() { if (!this.hasOwnProperty(JSCompiler_renameProperty('_template', this))) { @@ -389,6 +389,15 @@ export const ElementMixin = dedupingMixin(base => { return this._template; } + /** + * Set the template. + * + * @param {!HTMLTemplateElement|string} value Template to set. + */ + static set template(value) { + this._template = value; + } + /** * Path matching the url from which the element was imported. *