Skip to content

Commit 0ae14b9

Browse files
committed
Add new mixin annotations, remove GestureEventListeners alias
1 parent 4cc6c33 commit 0ae14b9

11 files changed

+69
-56
lines changed

lib/mixins/dir-mixin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ function takeRecords() {
8383
* @mixinFunction
8484
* @polymer
8585
* @appliesMixin PropertyAccessors
86+
* @template T
87+
* @param {function(new:T)} superClass Class to apply mixin to.
88+
* @return {function(new:T)} superClass with mixin applied.
8689
*/
8790
export const DirMixin = dedupingMixin((base) => {
8891

lib/mixins/disable-upgrade-mixin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ const DISABLED_ATTR = 'disable-upgrade';
3838
* @mixinFunction
3939
* @polymer
4040
* @appliesMixin ElementMixin
41+
* @template T
42+
* @param {function(new:T)} superClass Class to apply mixin to.
43+
* @return {function(new:T)} superClass with mixin applied.
4144
*/
4245
export const DisableUpgradeMixin = dedupingMixin((base) => {
4346
/**

lib/mixins/element-mixin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ const builtCSS = window.ShadyCSS && window.ShadyCSS['cssBuild'];
9595
* import strategies.
9696
* @summary Element class mixin that provides the core API for Polymer's
9797
* meta-programming features.
98+
* @template T
99+
* @param {function(new:T)} superClass Class to apply mixin to.
100+
* @return {function(new:T)} superClass with mixin applied.
98101
*/
99102
export const ElementMixin = dedupingMixin(base => {
100103
/**

lib/mixins/gesture-event-listeners.js

Lines changed: 39 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -24,65 +24,48 @@ import { addListener, removeListener } from '../utils/gestures.js';
2424
* @mixinFunction
2525
* @polymer
2626
* @summary Element class mixin that provides API for adding Polymer's
27-
* cross-platform
28-
* gesture events to nodes
27+
* cross-platform gesture events to nodes
28+
* @template T
29+
* @param {function(new:T)} superClass Class to apply mixin to.
30+
* @return {function(new:T)} superClass with mixin applied.
2931
*/
30-
const GestureEventListeners = dedupingMixin(
32+
export const GestureEventListeners = dedupingMixin((superClass) => {
33+
/**
34+
* @polymer
35+
* @mixinClass
36+
* @implements {Polymer_GestureEventListeners}
37+
*/
38+
class GestureEventListeners extends superClass {
3139
/**
32-
* @template T
33-
* @param {function(new:T)} superClass Class to apply mixin to.
34-
* @return {function(new:T)} superClass with mixin applied.
40+
* Add the event listener to the node if it is a gestures event.
41+
*
42+
* @param {!EventTarget} node Node to add event listener to
43+
* @param {string} eventName Name of event
44+
* @param {function(!Event):void} handler Listener function to add
45+
* @return {void}
46+
* @override
3547
*/
36-
(superClass) => {
37-
/**
38-
* @polymer
39-
* @mixinClass
40-
* @implements {Polymer_GestureEventListeners}
41-
*/
42-
class GestureEventListeners extends superClass {
43-
/**
44-
* Add the event listener to the node if it is a gestures event.
45-
*
46-
* @param {!EventTarget} node Node to add event listener to
47-
* @param {string} eventName Name of event
48-
* @param {function(!Event):void} handler Listener function to add
49-
* @return {void}
50-
* @override
51-
*/
52-
_addEventListenerToNode(node, eventName, handler) {
53-
if (!addListener(node, eventName, handler)) {
54-
super._addEventListenerToNode(node, eventName, handler);
55-
}
56-
}
57-
58-
/**
59-
* Remove the event listener to the node if it is a gestures event.
60-
*
61-
* @param {!EventTarget} node Node to remove event listener from
62-
* @param {string} eventName Name of event
63-
* @param {function(!Event):void} handler Listener function to remove
64-
* @return {void}
65-
* @override
66-
*/
67-
_removeEventListenerFromNode(node, eventName, handler) {
68-
if (!removeListener(node, eventName, handler)) {
69-
super._removeEventListenerFromNode(node, eventName, handler);
70-
}
71-
}
48+
_addEventListenerToNode(node, eventName, handler) {
49+
if (!addListener(node, eventName, handler)) {
50+
super._addEventListenerToNode(node, eventName, handler);
7251
}
52+
}
7353

74-
return GestureEventListeners;
75-
});
76-
77-
// Somehow GestureEventListeners is incorrectly typed as *. For now add this
78-
// cast.
79-
/**
80-
* @template T
81-
* @param {function(new:T)} superClass Class to apply mixin to.
82-
* @return {function(new:T)} superClass with mixin applied.
83-
*/
84-
const _GestureEventListeners = function(superClass) {
85-
return GestureEventListeners(superClass);
86-
};
54+
/**
55+
* Remove the event listener to the node if it is a gestures event.
56+
*
57+
* @param {!EventTarget} node Node to remove event listener from
58+
* @param {string} eventName Name of event
59+
* @param {function(!Event):void} handler Listener function to remove
60+
* @return {void}
61+
* @override
62+
*/
63+
_removeEventListenerFromNode(node, eventName, handler) {
64+
if (!removeListener(node, eventName, handler)) {
65+
super._removeEventListenerFromNode(node, eventName, handler);
66+
}
67+
}
68+
}
8769

88-
export {_GestureEventListeners as GestureEventListeners};
70+
return GestureEventListeners;
71+
});

lib/mixins/mutable-data.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ function mutablePropertyChange(inst, property, value, old, mutableData) {
6767
* @polymer
6868
* @summary Element class mixin to skip strict dirty-checking for objects
6969
* and arrays
70+
* @template T
71+
* @param {function(new:T)} superClass Class to apply mixin to.
72+
* @return {function(new:T)} superClass with mixin applied.
7073
*/
7174
export const MutableData = dedupingMixin(superClass => {
7275

lib/mixins/properties-changed.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ const microtask = microTask;
3333
* @polymer
3434
* @summary Element class mixin for reacting to property changes from
3535
* generated property accessors.
36+
* @template T
37+
* @param {function(new:T)} superClass Class to apply mixin to.
38+
* @return {function(new:T)} superClass with mixin applied.
3639
*/
3740
export const PropertiesChanged = dedupingMixin(
3841
/**

lib/mixins/properties-mixin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ function normalizeProperties(props) {
4747
* @appliesMixin PropertiesChanged
4848
* @summary Mixin that provides a minimal starting point for using
4949
* the PropertiesChanged mixin by providing a declarative `properties` object.
50+
* @template T
51+
* @param {function(new:T)} superClass Class to apply mixin to.
52+
* @return {function(new:T)} superClass with mixin applied.
5053
*/
5154
export const PropertiesMixin = dedupingMixin(superClass => {
5255

lib/mixins/property-accessors.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ function saveAccessorValue(model, property) {
9191
* @appliesMixin PropertiesChanged
9292
* @summary Element class mixin for reacting to property changes from
9393
* generated property accessors.
94+
* @template T
95+
* @param {function(new:T)} superClass Class to apply mixin to.
96+
* @return {function(new:T)} superClass with mixin applied.
9497
*/
9598
export const PropertyAccessors = dedupingMixin(superClass => {
9699

lib/mixins/property-effects.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,9 @@ function upper(name) {
10791079
* @appliesMixin PropertyAccessors
10801080
* @summary Element class mixin that provides meta-programming for Polymer's
10811081
* template binding and data observation system.
1082+
* @template T
1083+
* @param {function(new:T)} superClass Class to apply mixin to.
1084+
* @return {function(new:T)} superClass with mixin applied.
10821085
*/
10831086
export const PropertyEffects = dedupingMixin(superClass => {
10841087

lib/mixins/strict-binding-parser.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ function storeMethodNumber(bindingData, text, i) {
115115
* @appliesMixin PropertyEffects
116116
* @polymer
117117
* @summary Mixin that parses binding expressions and generates corresponding metadata.
118+
* @template T
119+
* @param {function(new:T)} superClass Class to apply mixin to.
120+
* @return {function(new:T)} superClass with mixin applied.
118121
*/
119122
const StrictBindingParser = dedupingMixin((base) => {
120123

lib/mixins/template-stamp.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ function createNodeEventHandler(context, eventName, methodName) {
104104
* @mixinFunction
105105
* @polymer
106106
* @summary Element class mixin that provides basic template parsing and stamping
107+
* @template T
108+
* @param {function(new:T)} superClass Class to apply mixin to.
109+
* @return {function(new:T)} superClass with mixin applied.
107110
*/
108111
export const TemplateStamp = dedupingMixin(
109112
/**

0 commit comments

Comments
 (0)