Skip to content

Commit 56fc683

Browse files
authored
Merge pull request #5423 from Polymer/5422-ldm-templatizer-fix
Apply LegacyDataMixin to TemplatizeInstanceBase. Fixes #5422
2 parents a7c861b + c23ff5e commit 56fc683

File tree

4 files changed

+195
-129
lines changed

4 files changed

+195
-129
lines changed

lib/legacy/legacy-data-mixin.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
1111
import { Class } from './class.js';
1212
import { Polymer } from '../../polymer-legacy.js';
1313
import { dedupingMixin } from '../utils/mixin.js';
14+
import { templatize } from '../utils/templatize.js';
1415

1516
const UndefinedArgumentError = class extends Error {
1617
constructor(message, arg) {
@@ -149,5 +150,14 @@ Polymer.Class = (info, mixin) => Class(info,
149150
LegacyDataMixin(superClass)
150151
);
151152

153+
// Apply LegacyDataMixin to Templatizer instances as well, and defer
154+
// runtime switch to the root's host (_methodHost)
155+
templatize.mixin =
156+
dedupingMixin(superClass => class extends LegacyDataMixin(superClass) {
157+
get _legacyUndefinedCheck() {
158+
return this._methodHost && this._methodHost._legacyUndefinedCheck;
159+
}
160+
});
161+
152162
console.info('LegacyDataMixin will be applied to all legacy elements.\n' +
153163
'Set `_legacyUndefinedCheck: true` on element class to enable.');

lib/utils/templatize.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ function createTemplatizerClass(template, templateInfo, options) {
334334
// Anonymous class created by the templatize
335335
let base = options.mutableData ?
336336
MutableTemplateInstanceBase : TemplateInstanceBase;
337+
// Affordance for global mixins onto TemplatizeInstance
338+
if (templatize.mixin) {
339+
base = templatize.mixin(base);
340+
}
337341
/**
338342
* @constructor
339343
* @extends {base}

0 commit comments

Comments
 (0)