Apply LegacyDataMixin to TemplatizeInstanceBase. Fixes #5422

This commit is contained in:
Kevin Schaaf
2018-11-01 23:15:56 -07:00
parent 1ad496fc7b
commit 6dd3456940
3 changed files with 69 additions and 3 deletions

View File

@@ -11,6 +11,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
import { Class } from './class.js';
import { Polymer } from '../../polymer-legacy.js';
import { dedupingMixin } from '../utils/mixin.js';
import { templatize } from '../utils/templatize.js';
const UndefinedArgumentError = class extends Error {
constructor(message, arg) {
@@ -149,5 +150,14 @@ Polymer.Class = (info, mixin) => Class(info,
LegacyDataMixin(superClass)
);
// Apply LegacyDataMixin to Templatizer instances as well, and defer
// runtime switch to the root's host (_methodHost)
templatize.mixin =
dedupingMixin(superClass => class extends LegacyDataMixin(superClass) {
get _legacyUndefinedCheck() {
return this._methodHost && this._methodHost._legacyUndefinedCheck;
}
});
console.info('LegacyDataMixin will be applied to all legacy elements.\n' +
'Set `_legacyUndefinedCheck: true` on element class to enable.');

View File

@@ -334,6 +334,10 @@ function createTemplatizerClass(template, templateInfo, options) {
// Anonymous class created by the templatize
let base = options.mutableData ?
MutableTemplateInstanceBase : TemplateInstanceBase;
// Affordance for global mixins onto TemplatizeInstance
if (templatize.mixin) {
base = templatize.mixin(base);
}
/**
* @constructor
* @extends {base}