@@ -727,7 +727,7 @@ export const ElementMixin = dedupingMixin(base => {
727
727
}
728
728
729
729
/**
730
- * Overrides `PropertyAccessors ` to add map of dynamic functions on
730
+ * Overrides `PropertyEffects ` to add map of dynamic functions on
731
731
* template info, for consumption by `PropertyEffects` template binding
732
732
* code. This map determines which method templates should have accessors
733
733
* created for them.
@@ -743,6 +743,32 @@ export const ElementMixin = dedupingMixin(base => {
743
743
return super . _parseTemplateContent ( template , templateInfo , nodeInfo ) ;
744
744
}
745
745
746
+ /**
747
+ * Overrides `PropertyEffects` to warn on use of undeclared properties in
748
+ * template.
749
+ *
750
+ * @param {Object } templateInfo Template metadata to add effect to
751
+ * @param {string } prop Property that should trigger the effect
752
+ * @param {Object= } effect Effect metadata object
753
+ * @return {void }
754
+ * @protected
755
+ */
756
+ static _addTemplatePropertyEffect ( templateInfo , prop , effect ) {
757
+ // Warn if properties are used in template without being declared.
758
+ // Properties must be listed in `properties` to be included in
759
+ // `observedAttributes` since CE V1 reads that at registration time, and
760
+ // since we want to keep template parsing lazy, we can't automatically
761
+ // add undeclared properties used in templates to `observedAttributes`.
762
+ // The warning is only enabled in `legacyOptimizations` mode, since
763
+ // we don't want to spam existing users who might have adopted the
764
+ // shorthand when attribute deserialization is not important.
765
+ if ( legacyOptimizations && ! ( prop in this . _properties ) ) {
766
+ console . warn ( `Property '${ prop } ' used in template but not declared in 'properties'; ` +
767
+ `attribute will not be observed.` ) ;
768
+ }
769
+ return super . _addTemplatePropertyEffect ( templateInfo , prop , effect ) ;
770
+ }
771
+
746
772
}
747
773
748
774
return PolymerElement ;
0 commit comments