Skip to content

Commit

Permalink
Merge pull request #5550 from Polymer/externs-fixes-1
Browse files Browse the repository at this point in the history
Various compilation fixes for externs
  • Loading branch information
aomarks authored Jun 6, 2019
2 parents 05231a0 + f0fb532 commit fe81676
Show file tree
Hide file tree
Showing 16 changed files with 93 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sudo: false
dist: trusty
node_js: '9'
addons:
firefox: latest
firefox: "66.0"
chrome: stable
cache:
directories:
Expand Down
1 change: 1 addition & 0 deletions lib/elements/custom-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export class CustomStyle extends HTMLElement {
const include = style.getAttribute(attr);
if (include) {
style.removeAttribute(attr);
/** @suppress {deprecated} */
style.textContent = cssFromModules(include) + style.textContent;
}
/*
Expand Down
7 changes: 6 additions & 1 deletion lib/elements/dom-bind.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,16 @@ export class DomBind extends domBindBase {
this.__children = null;
}

/* eslint-disable no-unused-vars */
/**
* @override
* @param {string} name Name of attribute that changed
* @param {?string} old Old attribute value
* @param {?string} value New attribute value
* @param {?string} namespace Attribute namespace.
* @return {void}
*/
attributeChangedCallback() {
attributeChangedCallback(name, old, value, namespace) {
// assumes only one observed attribute
this.mutableData = true;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/elements/dom-repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ export class DomRepeat extends domRepeatBase {
this.__sortFn = null;
this.__filterFn = null;
this.__observePaths = null;
/** @type {?function(new:Polymer.TemplateInstanceBase, *)} */
/** @type {?function(new:TemplateInstanceBase, *)} */
this.__ctor = null;
this.__isDetached = true;
this.template = null;
Expand Down
3 changes: 3 additions & 0 deletions lib/mixins/dir-mixin.js
Original file line number Diff line number Diff line change
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
7 changes: 5 additions & 2 deletions lib/mixins/disable-upgrade-mixin.js
Original file line number Diff line number Diff line change
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 Expand Up @@ -67,8 +70,8 @@ export const DisableUpgradeMixin = dedupingMixin((base) => {
* @param {string} name Attribute name.
* @param {?string} old The previous value for the attribute.
* @param {?string} value The new value for the attribute.
* @param {?string=} namespace The XML namespace for the attribute.
* @return {undefined}
* @param {?string} namespace The XML namespace for the attribute.
* @return {void}
*/
attributeChangedCallback(name, old, value, namespace) {
if (name == DISABLED_ATTR) {
Expand Down
3 changes: 3 additions & 0 deletions lib/mixins/element-mixin.js
Original file line number Diff line number Diff line change
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
93 changes: 39 additions & 54 deletions lib/mixins/gesture-event-listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,63 +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;
});
/**
* 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);
}
}
}

// 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.
*/
export const GestureEventListeners = function(superClass) {
return _GestureEventListeners(superClass);
};
return GestureEventListeners;
});
3 changes: 3 additions & 0 deletions lib/mixins/mutable-data.js
Original file line number Diff line number Diff line change
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
7 changes: 5 additions & 2 deletions lib/mixins/properties-changed.js
Original file line number Diff line number Diff line change
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 Expand Up @@ -161,7 +164,7 @@ export const PropertiesChanged = dedupingMixin(

constructor() {
super();
/** @protected {boolean} */
/** @type {boolean} */
this.__dataEnabled = false;
this.__dataReady = false;
this.__dataInvalid = false;
Expand Down Expand Up @@ -426,7 +429,7 @@ export const PropertiesChanged = dedupingMixin(
* @param {string} name Name of attribute that changed
* @param {?string} old Old attribute value
* @param {?string} value New attribute value
* @param {?string=} namespace Attribute namespace.
* @param {?string} namespace Attribute namespace.
* @return {void}
* @suppress {missingProperties} Super may or may not implement the callback
* @override
Expand Down
3 changes: 3 additions & 0 deletions lib/mixins/properties-mixin.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
6 changes: 6 additions & 0 deletions lib/mixins/property-effects.js
Original file line number Diff line number Diff line change
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 Expand Up @@ -1150,6 +1153,9 @@ export const PropertyEffects = dedupingMixin(superClass => {
this.__templateInfo;
}

/**
* @return {!Object<string, string>} Effect prototype property name map.
*/
get PROPERTY_EFFECT_TYPES() {
return TYPES;
}
Expand Down
3 changes: 3 additions & 0 deletions lib/mixins/strict-binding-parser.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
10 changes: 8 additions & 2 deletions lib/utils/templatize.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ function upgradeTemplate(template, constructor) {
* @implements {Polymer_PropertyEffects}
* @private
*/
const templateInstanceBase = PropertyEffects(class {});
const templateInstanceBase = PropertyEffects(
// This cast shouldn't be neccessary, but Closure doesn't understand that
// "class {}" is a constructor function.
/** @type {function(new:Object)} */(class {}));

/**
* @polymer
Expand Down Expand Up @@ -317,7 +320,10 @@ TemplateInstanceBase.prototype.__hostProps;
* @implements {Polymer_MutableData}
* @private
*/
const MutableTemplateInstanceBase = MutableData(TemplateInstanceBase);
const MutableTemplateInstanceBase = MutableData(
// This cast shouldn't be necessary, but Closure doesn't seem to understand
// this constructor.
/** @type {function(new:TemplateInstanceBase)} */(TemplateInstanceBase));

function findMethodHost(template) {
// Technically this should be the owner of the outermost template.
Expand Down

0 comments on commit fe81676

Please sign in to comment.