Polymer cli reports the following error in CI:
<multipart-file-form-item name="{{item.name}}" value="{{item.value}}" required auto-validate></multipart-file-form-item>
~~~~~
multipart-payload-editor.html(135,59) warning [set-unknown-attribute] - multipart-file-form-item elements do not have a property named value. Consider instead: name
However it implements a behavior that contains Polymer.IronFormElementBehavior which has a value property.
This is the behavior:
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-validatable-behavior/iron-validatable-behavior.html">
<link rel="import" href="../iron-form-element-behavior/iron-form-element-behavior.html">
<script>
window.MyBehaviors = window.MyBehaviors || {};
window.MyBehaviors.MultipartFormItemBehaviorImpl = {
properties: {
name: {
type: String,
notify: true
}
}
};
window.MyBehaviors.MultipartFormItemBehavior = [
Polymer.IronFormElementBehavior,
Polymer.IronValidatableBehavior,
window.MyBehaviors.MultipartFormItemBehaviorImpl
];
})();
Now, because Polymer.IronFormElementBehavior has value property the element that is implementing MyBehaviors.MultipartFormItemBehavior behavior should also have value property. And it has - at leas in working code. The value change is notified to parent element. However linter says that this property is not declared.
I also encountered this issue but with the polymer-2 ruleset. The warnings in my case are caused by the localize function, inherited from Polymer.AppLocalizeBehavior, and used in the templates like this:
<paper-button class="primary">[[ localize('Click me!') ]]</paper-button>
I get the following warning for every instance of localize being called inside the templates:
warning [databind-with-unknown-property] - localize is not declared and is only read from, never written to. If it's part of the element's API it should be a declared property.
I was using the "hybrid" style and decided to migrate to the Polymer 2.0 style. The only difference is that instead of using the behaviors property, I am using the Polymer.mixinBehaviors function in order to construct a base class. It seems that the result of invoking the Polymer.mixinBehaviors function cannot be analyzed successfully by the linter, because when using the hybrid syntax (putting the behaviors array in the behaviors property) and linting with the polymer-2-hybrid ruleset I had no such warnings. The localize function works as expected but those warnings are annoying me.
Here is my custom element declaration:
class MyElement extends Polymer.mixinBehaviors([Polymer.AppLocalizeBehavior], Polymer.Element) { }
I am using [email protected] and [email protected].
When applying mixins you need to use the @appliesMixin jsdoc annotation:
/**
* @extends {Polymer.Element}
* @appliesMixin Polymer.AppLocalizeBehavior
*/
class MyElement extends Polymer.mixinBehaviors([Polymer.AppLocalizeBehavior], Polymer.Element) {
}
@rictic
Is the same for polymer-1 ruleset?
@rictic I find it strange that I have to change my JSDoc annotations for a class extending Polymer.Element to applying a mixin.
@jarrodek We should be able to detect when you apply a behavior. Is the behavior annotated with @polymerBehavior?
@stramel Yeah, we should be able to infer most mixin application automatically, the code just hasn't been written to do so.
I believe both the array and the Impl object need to be annotated as @polymerBehavior.
@rictic After adding second annotation on the array it started working. It doesn't work if the annotation is missing in the impl or the array.
So I guess we can close this?
+1
Most helpful comment
When applying mixins you need to use the
@appliesMixinjsdoc annotation:More info: https://github.com/Polymer/polymer-analyzer/wiki/JS-Doc-Annotations-recognized-by-the-polymer-analyzer