Skip to content

Commit

Permalink
Down to 30ish warnings, need PolymerPass v2
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Jun 6, 2017
1 parent 872e1c2 commit de87c58
Show file tree
Hide file tree
Showing 17 changed files with 1,824 additions and 1,041 deletions.
496 changes: 34 additions & 462 deletions closure.log

Large diffs are not rendered by default.

2,022 changes: 1,551 additions & 471 deletions externs/closure-types.js

Large diffs are not rendered by default.

82 changes: 80 additions & 2 deletions externs/polymer-externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,48 @@
* @externs
*/

/* eslint-disable */

/**
* @param {!{is: string}} init
* @typedef Object<string, {
* value: *,
* type: (Function | undefined),
* readOnly: (boolean | undefined),
* computed: (string | undefined),
* reflectToAttribute: (boolean | undefined),
* notify: (boolean | undefined),
* observer: (string | undefined)
* }>)
*/
let PolymerElementProperties;

/**
* @typedef {{
* is: string,
* extends: (string | undefined),
* properties: (!PolymerElementProperties | undefined),
* observers: (!Array<string> | undefined),
* template: (!HTMLTemplateElement | string | undefined),
* hostAttributes: (!Object<string, *> | undefined),
* listeners: (!Object<string, string> | undefined)
* }}
*/
let PolymerInit;

let PolymerElementConstructor = function () { };
/** @type {(string | undefined)} */
PolymerElementConstructor.is;
/** @type {(string | undefined)} */
PolymerElementConstructor.extends;
/** @type {(!PolymerElementProperties | undefined)} */
PolymerElementConstructor.properties;
/** @type {(!Array<string> | undefined)} */
PolymerElementConstructor.observers;
/** @type {(!HTMLTemplateElement | string | undefined)} */
PolymerElementConstructor.template;

/**
* @param {!PolymerInit} init
* @return {!HTMLElement}
*/
function Polymer(init){}
Expand Down Expand Up @@ -32,4 +72,42 @@ PolymerTelemetry.prototype._regLog;
/** @type {function(HTMLElement)} */
PolymerTelemetry.prototype.register;
/** @type {function(HTMLElement)} */
PolymerTelemetry.prototype.dumpRegistrations;
PolymerTelemetry.prototype.dumpRegistrations;

/**
* @typedef {{
* name: (string | undefined),
* structured: (boolean | undefined),
* wildcard: (boolean | undefined)
* }}
*/
var DataTrigger;

/**
* @typedef {{
* info: ?,
* trigger: (!DataTrigger | undefined),
* fn: (!Function | undefined)
* }}
*/
var DataEffect;

/**
* @record
* @extends {Polymer_PropertyEffects}
*/
function PropertyEffectsInstance(){}
/** @type {Object<string, !Array<!DataEffect>>} */
PropertyEffectsInstance.prototype.__computeEffects;
/** @type {Object<string, !Array<!DataEffect>>} */
PropertyEffectsInstance.prototype.__reflectEffects;
/** @type {Object<string, !Array<!DataEffect>>} */
PropertyEffectsInstance.prototype.__notifyEffects;
/** @type {Object<string, !Array<!DataEffect>>} */
PropertyEffectsInstance.prototype.__propagateEffects;
/** @type {Object<string, !Array<!DataEffect>>} */
PropertyEffectsInstance.prototype.__observeEffects;
/** @type {Object<string, !Array<!DataEffect>>} */
PropertyEffectsInstance.prototype.__readOnly;
/** @type {Object} */
PropertyEffectsInstance.prototype.__data;
4 changes: 1 addition & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,11 @@ gulp.task('closure', ['clean'], () => {
rewrite_polyfills: false,
new_type_inf: true,
checks_only: CLOSURE_LINT_ONLY,
jscomp_warning: 'newCheckTypes',
jscomp_off: 'newCheckTypesExtraChecks',
externs: [
'bower_components/shadycss/externs/shadycss-externs.js',
'externs/webcomponents-externs.js',
'externs/polymer-externs.js',
'externs/closure-types.js',
'externs/polymer-externs.js',
],
extra_annotation_name: [
'polymerMixin',
Expand Down
19 changes: 15 additions & 4 deletions lib/elements/array-selector.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->

<link rel="import" href="../../polymer-element.html">
<link rel="import" href="../mixins/property-effects.html">
<link rel="import" href="../utils/mixin.html">
<link rel="import" href="../utils/array-splice.html">
<link rel="import" href="../../polymer-element.html">

<script>
(function() {
'use strict';

/**
* Element mixin for recording dynamic associations between item paths in a
* Element mixin for recording dynamic associations between item paths in a
* master `items` array and a `selected` array such that path changes to the
* master array (at the host) element or elsewhere via data-binding) are
* correctly propagated to items in the selected array and vice-versa.
Expand All @@ -31,15 +32,26 @@
* is an array of multiply selected items.
*
* @polymerMixin
* @mixes Polymer.PropertyEffects
* @memberof Polymer
* @summary Element mixin for recording dynamic associations between item paths in a
* master `items` array and a `selected` array
*/
let ArraySelectorMixin = Polymer.dedupingMixin(superClass => {

/**
* @constructor
* @extends {superClass}
* @implements {Polymer_PropertyEffects}
*/
let propertyEffectsBase = Polymer.PropertyEffects(superClass);

/**
* @polymerMixinClass
* @implements {Polymer_ArraySelectorMixin}
* @unrestricted
*/
class ArraySelectorMixin extends superClass {
class ArraySelectorMixin extends propertyEffectsBase {

static get properties() {

Expand Down Expand Up @@ -391,7 +403,6 @@
* ```
*
* @polymerElement
* @extends Polymer.Element
* @mixes Polymer.ArraySelectorMixin
* @memberof Polymer
* @summary Custom element that links paths between an input `items` array and
Expand Down
10 changes: 5 additions & 5 deletions lib/elements/dom-bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

/**
* @constructor
* @extends {HTMLElement}
* @implements {Polymer_PropertyEffects}
* @implements {Polymer_OptionalMutableData}
* @implements {Polymer_GestureEventListeners}
* @extends {HTMLElement}
*/
const domBindBase =
Polymer.GestureEventListeners(
Expand All @@ -43,7 +43,6 @@
* @mixes Polymer.PropertyEffects
* @mixes Polymer.OptionalMutableData
* @mixes Polymer.GestureEventListeners
* @extends HTMLElement
* @memberof Polymer
* @summary Custom element to allow using Polymer's template features (data
* binding, declarative event listeners, etc.) in the main document.
Expand Down Expand Up @@ -87,18 +86,19 @@
/**
* Forces the element to render its content. This is typically only
* necessary to call if HTMLImports with the async attribute are used.
* @suppress {missingProperties}
*/
render() {
let template;
if (!this.__children) {
template = template || this.querySelector('template');
template = /** @type {HTMLTemplateElement} */(template || this.querySelector('template'));
if (!template) {
// Wait until childList changes and template should be there by then
let observer = new MutationObserver(() => {
template = this.querySelector('template');
template = /** @type {HTMLTemplateElement} */(this.querySelector('template'));
if (template) {
observer.disconnect();
this.render(template);
this.render();
} else {
throw new Error('dom-bind requires a <template> child');
}
Expand Down
2 changes: 2 additions & 0 deletions lib/elements/dom-if.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
this.__renderDebouncer = null;
this.__invalidProps = null;
this.__instance = null;
this._lastIf = false;
this.__ctor = null;
}

__debounceRender() {
Expand Down
7 changes: 4 additions & 3 deletions lib/elements/dom-repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@
*
* @polymerElement
* @memberof Polymer
* @extends Polymer.Element
* @mixes Polymer.MutableData
* @summary Custom element for stamping instance of a template bound to
* items in an array.
Expand Down Expand Up @@ -288,6 +287,8 @@
this.__filterFn = null;
this.__observePaths = null;
this.__ctor = null;
this.__isDetached = true;
this.template = null;
}

disconnectedCallback() {
Expand Down Expand Up @@ -470,10 +471,10 @@
}

/**
* @param {function()} fn Function to debounce.
* @param {function(this:DomRepeat)} fn Function to debounce.
* @param {number=} delay Delay in ms to debounce by.
*/
__debounceRender(fn, delay) {
__debounceRender(fn, delay = 0) {
this.__renderDebouncer = Polymer.Debouncer.debounce(
this.__renderDebouncer
, delay > 0 ? Polymer.Async.timeOut.after(delay) : Polymer.Async.microTask
Expand Down
35 changes: 23 additions & 12 deletions lib/legacy/class.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

'use strict';

let LegacyElementMixin = Polymer.LegacyElementMixin;

let metaProps = {
attached: true,
detached: true,
Expand All @@ -36,19 +34,20 @@
* the underlying element.
*
* @param {!(Object|Array)} behaviors Behavior object or array of behaviors.
* @param {HTMLElement} klass Element class.
* @return {HTMLElement} Returns a new Element class extended by the
* @param {!HTMLElement|function(new:HTMLElement)} klass Element class.
* @return {!HTMLElement} Returns a new Element class extended by the
* passed in `behaviors` and also by `Polymer.LegacyElementMixin`.
* @memberof Polymer
* @suppress {invalidCasts, checkTypes}
*/
function mixinBehaviors(behaviors, klass) {
if (!behaviors) {
return klass;
return /** @type {HTMLElement} */(klass);
}
// NOTE: ensure the bahevior is extending a class with
// legacy element api. This is necessary since behaviors expect to be able
// to access 1.x legacy api.
klass = LegacyElementMixin(klass);
klass = Polymer.LegacyElementMixin(klass);
if (!Array.isArray(behaviors)) {
behaviors = [behaviors];
}
Expand All @@ -62,7 +61,7 @@
}
// Set behaviors on prototype for BC...
klass.prototype.behaviors = behaviors;
return klass;
return /** @type {!HTMLElement} */(klass);
}

// NOTE:
Expand Down Expand Up @@ -132,6 +131,13 @@
return list;
}

/**
* @param {!PolymerInit} info Polymer info object
* @param {!HTMLElement} Base base class to extend with info object
* @return {!HTMLElement} Generated class
* @suppress {missingProperties, checkTypes}
* @private
*/
function GenerateClassFromInfo(info, Base) {

class PolymerGenerated extends Base {
Expand All @@ -144,6 +150,10 @@
return info.observers;
}

/**
* @suppress {missingProperties}
* @return {HTMLTemplateElement} template for this class
*/
static get template() {
// get template first from any imperative set in `info._template`
return info._template ||
Expand All @@ -153,7 +163,8 @@
// to ensure correct `this.is`)
Base.template ||
// finally fall back to `_template` in element's protoype.
this.prototype._template;
this.prototype._template ||
null;
}

created() {
Expand Down Expand Up @@ -230,7 +241,7 @@
}
}

PolymerGenerated.generatedFrom = info
PolymerGenerated.generatedFrom = info

for (let p in info) {
// NOTE: cannot copy `metaProps` methods onto prototype at least because
Expand Down Expand Up @@ -309,9 +320,9 @@
* this element have been propagated to its template and all observers
* have run
*
* @param {Object} info Object containing Polymer metadata and functions
* @param {!PolymerInit} info Object containing Polymer metadata and functions
* to become class methods.
* @return {Polymer.LegacyElement} Generated class
* @return {!HTMLElement} Generated class
* @memberof Polymer
*/
Polymer.Class = function(info) {
Expand All @@ -321,7 +332,7 @@
let klass = GenerateClassFromInfo(info, info.behaviors ?
// note: mixinBehaviors ensures `LegacyElementMixin`.
mixinBehaviors(info.behaviors, HTMLElement) :
LegacyElementMixin(HTMLElement));
Polymer.LegacyElementMixin(HTMLElement));
// decorate klass with registration info
klass.is = info.is;
return klass;
Expand Down
7 changes: 4 additions & 3 deletions lib/legacy/legacy-element-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@

/**
* @constructor
* @extends {base}
* @implements {Polymer_ElementMixin}
* @implements {Polymer_GestureEventListeners}
* @extends {base}
*/
const legacyElementBase = Polymer.GestureEventListeners(Polymer.ElementMixin(base));

Expand Down Expand Up @@ -572,11 +572,12 @@
* `<content>`. Defaults to `content`.
* @return {Array<HTMLElement>} List of distributed nodes for the
* `<slot>`.
* @suppress {invalidCasts}
*/
getContentChildren(slctr) {
return this.getContentChildNodes(slctr).filter(function(n) {
return /** @type {Array<HTMLElement>} */(this.getContentChildNodes(slctr).filter(function(n) {
return (n.nodeType === Node.ELEMENT_NODE);
});
}));
}

/**
Expand Down
Loading

0 comments on commit de87c58

Please sign in to comment.