mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Apply LegacyDataMixin to TemplatizeInstanceBase. Fixes #5422
This commit is contained in:
@@ -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.');
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user