JS Doc Annotations recognized by the polymer analyzer - Polymer/polymer-analyzer GitHub Wiki
Declaring an Element
Custom element classes can be annotated with @customElement
. If they're Polymer elements, you can add the @polymer
annotation. The analyzer can generally infer custom elements from your source code though, so these annotations are only necessary for elements that are not immediately registered using the customElements.define
method.
// This class is registered as a custom element immediately, so it's clear that it's an element.
class MyPolymerElement extends Polymer.Elemnet {
is: 'my-polymer-element'
};
customElements.define(MyPolymerElement.is, MyPolymerElement);
/**
* This class calls a nonstandard method to register itself, so it must be annotated.
* @polymer
* @customElement
*/
class OtherPolymerElement extends Polymer.Elemnet {
is: 'other-polymer-element'
};
myCustomDefineCall(OtherElement);
Using a Mixin
When using a mixin the analyzer isn't (currently) able to infer the mixins applied to your class. So you must tell us with @appliesMixin
, and include the base class as well with @extends
. For example:
/**
* @extends {Polymer.Base}
* @appliesMixin fooMixin
* @appliesMixin barMixin
*/
class MyElement extends barMixin(fooMixin(Polymer.Base)) {
static get is() {
return 'my-element';
}
}
Declaring a Mixin
When writing a mixin, your mixin function must be annotated as a @mixinFunction
/**
* @mixinFunction
* @polymer
*/
var fooMixin = function(Superclass) {
return class Foo extends Superclass {
foo() {}
}
}
If you don't immediately return the generated class in your mixin function, then it must also be annotated with @mixinClass
:
/**
* @mixinFunction
*/
var barMixin = function(Superclass) {
/**
* @mixinClass
*/
class Bar extends Superclass {
bar() {}
}
return Bar;
}