diff --git a/lib/mixins/element-mixin.js b/lib/mixins/element-mixin.js index c931fb7fc0..415e2e2b3d 100644 --- a/lib/mixins/element-mixin.js +++ b/lib/mixins/element-mixin.js @@ -777,7 +777,10 @@ export const ElementMixin = dedupingMixin(base => { // The warning is only enabled in `legacyOptimizations` mode, since // we don't want to spam existing users who might have adopted the // shorthand when attribute deserialization is not important. - if (legacyOptimizations && !(prop in this._properties)) { + if (legacyOptimizations && !(prop in this._properties) && + effect.info && effect.info.part && + !(effect.info.part.signature && effect.info.part.signature.static) && + !effect.info.part.hostProp && !templateInfo.nestedTemplate) { console.warn(`Property '${prop}' used in template but not declared in 'properties'; ` + `attribute will not be observed.`); } diff --git a/lib/mixins/property-effects.js b/lib/mixins/property-effects.js index c92bea3fa6..65d76136be 100644 --- a/lib/mixins/property-effects.js +++ b/lib/mixins/property-effects.js @@ -2640,7 +2640,7 @@ export const PropertyEffects = dedupingMixin(superClass => { let hostProps = nodeInfo.templateInfo.hostProps; let mode = '{'; for (let source in hostProps) { - let parts = [{ mode, source, dependencies: [source] }]; + let parts = [{ mode, source, dependencies: [source], hostProp: true }]; addBinding(this, templateInfo, nodeInfo, 'property', '_host_' + source, parts); } return noted; diff --git a/lib/mixins/template-stamp.js b/lib/mixins/template-stamp.js index 167fbe530a..156bacee5f 100644 --- a/lib/mixins/template-stamp.js +++ b/lib/mixins/template-stamp.js @@ -204,6 +204,7 @@ export const TemplateStamp = dedupingMixin( if (!template._templateInfo) { let templateInfo = template._templateInfo = {}; templateInfo.nodeInfoList = []; + templateInfo.nestedTemplate = Boolean(outerTemplateInfo); templateInfo.stripWhiteSpace = (outerTemplateInfo && outerTemplateInfo.stripWhiteSpace) || template.hasAttribute('strip-whitespace'); diff --git a/test/unit/property-effects.html b/test/unit/property-effects.html index 087023914f..61a2a75083 100644 --- a/test/unit/property-effects.html +++ b/test/unit/property-effects.html @@ -1900,6 +1900,30 @@ assert.equal(console.warn.callCount, 3); }); + test('do not warn on valid non-property bindings', () => { + setLegacyOptimizations(true); + Polymer({ + is: 'x-nowarn-undeclared-binding', + properties: { + hostProp: String + }, + _template: html` +