From e534c3cf46f76fe53dbe8e13134b9b64d46a11c0 Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Wed, 21 Aug 2019 17:53:58 -0700 Subject: [PATCH] Fix template-finding issue with DisableUpgrade mixin. The existing rules are that `prototype._template` is first priority and dom-module via `is` is second priority _for a given class_. A subclass has a new shot at overriding the previous template either by defining a new `prototype._template` or a new `is` resulting in a dom-module lookup. However, trivially subclassing a Polymer legacy element breaks these rules, since if there is no _own_ `prototype._template` on the current class, it will lookup a dom-module using `is` from up the entire prototype chain. This defeats the rule that a `prototype._template` on the superclass should have taken priority over its dom-module. This change ensures that we only lookup dom-module if the class has an _own_ is property. --- lib/legacy/class.js | 4 ++-- lib/mixins/element-mixin.js | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/legacy/class.js b/lib/legacy/class.js index dd178dcde0..c64aec55bf 100644 --- a/lib/legacy/class.js +++ b/lib/legacy/class.js @@ -534,10 +534,10 @@ export const Class = function(info, mixin) { let klass = mixin ? mixin(LegacyElementMixin(HTMLElement)) : LegacyElementMixin(HTMLElement); klass = GenerateClassFromInfo(info, klass, info.behaviors); + // decorate klass with registration info + klass.is = klass.prototype.is = info.is; if (legacyOptimizations) { klass = DisableUpgradeMixin(klass); } - // decorate klass with registration info - klass.is = klass.prototype.is = info.is; return klass; }; diff --git a/lib/mixins/element-mixin.js b/lib/mixins/element-mixin.js index bae008e744..43902b02e3 100644 --- a/lib/mixins/element-mixin.js +++ b/lib/mixins/element-mixin.js @@ -411,9 +411,13 @@ export const ElementMixin = dedupingMixin(base => { /** * Returns the template that will be stamped into this element's shadow root. * - * If a `static get is()` getter is defined, the default implementation - * will return the first `