Skip to content

Commit

Permalink
Add new mixin annotations, remove GestureEventListeners alias
Browse files Browse the repository at this point in the history
  • Loading branch information
aomarks committed May 31, 2019
1 parent 4cc6c33 commit 0ae14b9
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 56 deletions.
3 changes: 3 additions & 0 deletions lib/mixins/dir-mixin.js
Expand Up @@ -83,6 +83,9 @@ function takeRecords() {
* @mixinFunction
* @polymer
* @appliesMixin PropertyAccessors
* @template T
* @param {function(new:T)} superClass Class to apply mixin to.
* @return {function(new:T)} superClass with mixin applied.
*/
export const DirMixin = dedupingMixin((base) => {

Expand Down
3 changes: 3 additions & 0 deletions lib/mixins/disable-upgrade-mixin.js
Expand Up @@ -38,6 +38,9 @@ const DISABLED_ATTR = 'disable-upgrade';
* @mixinFunction
* @polymer
* @appliesMixin ElementMixin
* @template T
* @param {function(new:T)} superClass Class to apply mixin to.
* @return {function(new:T)} superClass with mixin applied.
*/
export const DisableUpgradeMixin = dedupingMixin((base) => {
/**
Expand Down
3 changes: 3 additions & 0 deletions lib/mixins/element-mixin.js
Expand Up @@ -95,6 +95,9 @@ const builtCSS = window.ShadyCSS && window.ShadyCSS['cssBuild'];
* import strategies.
* @summary Element class mixin that provides the core API for Polymer's
* meta-programming features.
* @template T
* @param {function(new:T)} superClass Class to apply mixin to.
* @return {function(new:T)} superClass with mixin applied.
*/
export const ElementMixin = dedupingMixin(base => {
/**
Expand Down
95 changes: 39 additions & 56 deletions lib/mixins/gesture-event-listeners.js
Expand Up @@ -24,65 +24,48 @@ import { addListener, removeListener } from '../utils/gestures.js';
* @mixinFunction
* @polymer
* @summary Element class mixin that provides API for adding Polymer's
* cross-platform
* gesture events to nodes
* cross-platform gesture events to nodes
* @template T
* @param {function(new:T)} superClass Class to apply mixin to.
* @return {function(new:T)} superClass with mixin applied.
*/
const GestureEventListeners = dedupingMixin(
export const GestureEventListeners = dedupingMixin((superClass) => {
/**
* @polymer
* @mixinClass
* @implements {Polymer_GestureEventListeners}
*/
class GestureEventListeners extends superClass {
/**
* @template T
* @param {function(new:T)} superClass Class to apply mixin to.
* @return {function(new:T)} superClass with mixin applied.
* Add the event listener to the node if it is a gestures event.
*
* @param {!EventTarget} node Node to add event listener to
* @param {string} eventName Name of event
* @param {function(!Event):void} handler Listener function to add
* @return {void}
* @override
*/
(superClass) => {
/**
* @polymer
* @mixinClass
* @implements {Polymer_GestureEventListeners}
*/
class GestureEventListeners extends superClass {
/**
* Add the event listener to the node if it is a gestures event.
*
* @param {!EventTarget} node Node to add event listener to
* @param {string} eventName Name of event
* @param {function(!Event):void} handler Listener function to add
* @return {void}
* @override
*/
_addEventListenerToNode(node, eventName, handler) {
if (!addListener(node, eventName, handler)) {
super._addEventListenerToNode(node, eventName, handler);
}
}

/**
* Remove the event listener to the node if it is a gestures event.
*
* @param {!EventTarget} node Node to remove event listener from
* @param {string} eventName Name of event
* @param {function(!Event):void} handler Listener function to remove
* @return {void}
* @override
*/
_removeEventListenerFromNode(node, eventName, handler) {
if (!removeListener(node, eventName, handler)) {
super._removeEventListenerFromNode(node, eventName, handler);
}
}
_addEventListenerToNode(node, eventName, handler) {
if (!addListener(node, eventName, handler)) {
super._addEventListenerToNode(node, eventName, handler);
}
}

return GestureEventListeners;
});

// Somehow GestureEventListeners is incorrectly typed as *. For now add this
// cast.
/**
* @template T
* @param {function(new:T)} superClass Class to apply mixin to.
* @return {function(new:T)} superClass with mixin applied.
*/
const _GestureEventListeners = function(superClass) {
return GestureEventListeners(superClass);
};
/**
* Remove the event listener to the node if it is a gestures event.
*
* @param {!EventTarget} node Node to remove event listener from
* @param {string} eventName Name of event
* @param {function(!Event):void} handler Listener function to remove
* @return {void}
* @override
*/
_removeEventListenerFromNode(node, eventName, handler) {
if (!removeListener(node, eventName, handler)) {
super._removeEventListenerFromNode(node, eventName, handler);
}
}
}

export {_GestureEventListeners as GestureEventListeners};
return GestureEventListeners;
});
3 changes: 3 additions & 0 deletions lib/mixins/mutable-data.js
Expand Up @@ -67,6 +67,9 @@ function mutablePropertyChange(inst, property, value, old, mutableData) {
* @polymer
* @summary Element class mixin to skip strict dirty-checking for objects
* and arrays
* @template T
* @param {function(new:T)} superClass Class to apply mixin to.
* @return {function(new:T)} superClass with mixin applied.
*/
export const MutableData = dedupingMixin(superClass => {

Expand Down
3 changes: 3 additions & 0 deletions lib/mixins/properties-changed.js
Expand Up @@ -33,6 +33,9 @@ const microtask = microTask;
* @polymer
* @summary Element class mixin for reacting to property changes from
* generated property accessors.
* @template T
* @param {function(new:T)} superClass Class to apply mixin to.
* @return {function(new:T)} superClass with mixin applied.
*/
export const PropertiesChanged = dedupingMixin(
/**
Expand Down
3 changes: 3 additions & 0 deletions lib/mixins/properties-mixin.js
Expand Up @@ -47,6 +47,9 @@ function normalizeProperties(props) {
* @appliesMixin PropertiesChanged
* @summary Mixin that provides a minimal starting point for using
* the PropertiesChanged mixin by providing a declarative `properties` object.
* @template T
* @param {function(new:T)} superClass Class to apply mixin to.
* @return {function(new:T)} superClass with mixin applied.
*/
export const PropertiesMixin = dedupingMixin(superClass => {

Expand Down
3 changes: 3 additions & 0 deletions lib/mixins/property-accessors.js
Expand Up @@ -91,6 +91,9 @@ function saveAccessorValue(model, property) {
* @appliesMixin PropertiesChanged
* @summary Element class mixin for reacting to property changes from
* generated property accessors.
* @template T
* @param {function(new:T)} superClass Class to apply mixin to.
* @return {function(new:T)} superClass with mixin applied.
*/
export const PropertyAccessors = dedupingMixin(superClass => {

Expand Down
3 changes: 3 additions & 0 deletions lib/mixins/property-effects.js
Expand Up @@ -1079,6 +1079,9 @@ function upper(name) {
* @appliesMixin PropertyAccessors
* @summary Element class mixin that provides meta-programming for Polymer's
* template binding and data observation system.
* @template T
* @param {function(new:T)} superClass Class to apply mixin to.
* @return {function(new:T)} superClass with mixin applied.
*/
export const PropertyEffects = dedupingMixin(superClass => {

Expand Down
3 changes: 3 additions & 0 deletions lib/mixins/strict-binding-parser.js
Expand Up @@ -115,6 +115,9 @@ function storeMethodNumber(bindingData, text, i) {
* @appliesMixin PropertyEffects
* @polymer
* @summary Mixin that parses binding expressions and generates corresponding metadata.
* @template T
* @param {function(new:T)} superClass Class to apply mixin to.
* @return {function(new:T)} superClass with mixin applied.
*/
const StrictBindingParser = dedupingMixin((base) => {

Expand Down
3 changes: 3 additions & 0 deletions lib/mixins/template-stamp.js
Expand Up @@ -104,6 +104,9 @@ function createNodeEventHandler(context, eventName, methodName) {
* @mixinFunction
* @polymer
* @summary Element class mixin that provides basic template parsing and stamping
* @template T
* @param {function(new:T)} superClass Class to apply mixin to.
* @return {function(new:T)} superClass with mixin applied.
*/
export const TemplateStamp = dedupingMixin(
/**
Expand Down

0 comments on commit 0ae14b9

Please sign in to comment.