From c0ddc60bbc43c3bff56aec18f1ca5ced53ca0b98 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Thu, 27 Apr 2017 17:31:56 -0700 Subject: [PATCH] remove all "global this" warnings --- closure.log | 215 ++++++-------------------- externs/closure-types.js | 3 - externs/polymer-externs.js | 20 ++- lib/elements/dom-if.html | 1 + lib/elements/dom-repeat.html | 2 + lib/legacy/mutable-data-behavior.html | 1 + lib/mixins/element-mixin.html | 2 + lib/mixins/property-accessors.html | 8 +- lib/mixins/property-effects.html | 8 +- lib/utils/path.html | 9 ++ lib/utils/style-gather.html | 4 + 11 files changed, 87 insertions(+), 186 deletions(-) diff --git a/closure.log b/closure.log index 7a433851f3..2f1214451c 100644 --- a/closure.log +++ b/closure.log @@ -35,10 +35,6 @@ to : T let value = path ? Polymer.Path.get(inst, path) : inst.__data[property]; ^^^^^^^^^^^ -/polymer.html_script_10.js:298: WARNING - Property detail never defined on event of type Event - let detail = event.detail; - ^^^^^^^^^^^^ - /polymer.html_script_10.js:308: WARNING - Property _setPendingPropertyOrPath never defined on inst of type Object if (inst._setPendingPropertyOrPath(toPath, value, true, Boolean(fromPath)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,10 +43,6 @@ to : T inst._invalidateProperties(); ^^^^^^^^^^^^^^^^^^^^^^^^^^ -/polymer.html_script_10.js:330: WARNING - Property sanitizeDOMValue never defined on Polymer of type Polymer<|function({is:string}):HTMLElement|>{prototype:?} - value = Polymer.sanitizeDOMValue(value, info.attrName, 'attribute', inst); - ^^^^^^^^^^^^^^^^^^^^^^^^ - /polymer.html_script_10.js:332: WARNING - Property _propertyToAttribute never defined on inst of type {__data:Object} inst._propertyToAttribute(property, info.attrName, value); ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -123,11 +115,7 @@ The found type is a union that includes an unexpected type: null let value = info.evaluator._evaluateBinding(inst, part, path, props, oldProps, hasPaths); ^^^^^^^^^^^^^^ -/polymer.html_script_10.js:538: WARNING - Property sanitizeDOMValue never defined on Polymer of type Polymer<|function({is:string}):HTMLElement|>{prototype:?} - value = Polymer.sanitizeDOMValue(value, binding.target, binding.kind, node); - ^^^^^^^^^^^^^^^^^^^^^^^^ - -/polymer.html_script_10.js:538: WARNING - Property kind never defined on binding of type {target:?} +/polymer.html_script_10.js:538: WARNING - Property kind never defined on binding of type {target:string} value = Polymer.sanitizeDOMValue(value, binding.target, binding.kind, node); ^^^^^^^^^^^^ @@ -414,10 +402,6 @@ Found : PropertyEffects propPath = info.path; ^^^^^^^^^ -/polymer.html_script_10.js:1871: WARNING - Dangerous use of the global THIS object - this._setProperty(property, value); - ^^^^ - /polymer.html_script_10.js:2069: WARNING - Property nodeList never defined on dom of type DocumentFragment templateInfo.nodeList = dom.nodeList; ^^^^^^^^^^^^ @@ -649,22 +633,6 @@ Found : PolymerElement console.log('[' + prototype.is + ']: registered') ^^^^^^^^^^^^ -/polymer.html_script_11.js:878: WARNING - Dangerous use of the global THIS object - this.registrations.push(prototype); - ^^^^ - -/polymer.html_script_11.js:879: WARNING - Dangerous use of the global THIS object - Polymer.log && this._regLog(prototype); - ^^^^ - -/polymer.html_script_11.js:886: WARNING - Dangerous use of the global THIS object - this.registrations.forEach(this._regLog); - ^^^^ - -/polymer.html_script_11.js:886: WARNING - Dangerous use of the global THIS object - this.registrations.forEach(this._regLog); - ^^^^ - /polymer.html_script_21.js:331: WARNING - Property polyfillWrapFlushCallback never defined on window.customElements of type CustomElementRegistry !(window.customElements.polyfillWrapFlushCallback); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -788,89 +756,61 @@ Found : $polymer_html_script_26$classdecl$var2<|function(new:$polymer_html_sc mutableData: this.mutableData, ^^^^^^^^^^^^^^^^ -/polymer.html_script_30.js:326: WARNING - Dangerous use of the global THIS object - let i$ = this.__instances; - ^^^^ - -/polymer.html_script_30.js:332: WARNING - Dangerous use of the global THIS object - if (Polymer.Path.matches(this.as, prop)) { - ^^^^ - -/polymer.html_script_30.js:333: WARNING - Dangerous use of the global THIS object - let idx = inst[this.itemsIndexAs]; - ^^^^ - -/polymer.html_script_30.js:334: WARNING - Dangerous use of the global THIS object - if (prop == this.as) { - ^^^^ - -/polymer.html_script_30.js:335: WARNING - Dangerous use of the global THIS object - this.items[idx] = value; - ^^^^ - -/polymer.html_script_30.js:337: WARNING - Dangerous use of the global THIS object - let path = Polymer.Path.translate(this.as, 'items.' + idx, prop); - ^^^^ - -/polymer.html_script_30.js:338: WARNING - Dangerous use of the global THIS object - this.notifyPath(path, value); - ^^^^ - -/polymer.html_script_30.js:352: WARNING - Property __dataHost never defined on this of type DomRepeat +/polymer.html_script_30.js:354: WARNING - Property __dataHost never defined on this of type DomRepeat return this.__dataHost._methodHost || this.__dataHost; ^^^^^^^^^^^^^^^ -/polymer.html_script_30.js:361: WARNING - Invalid type for parameter 1 of function this.__debounceRender. +/polymer.html_script_30.js:363: WARNING - Invalid type for parameter 1 of function this.__debounceRender. Expected : function():? Found : function(this:DomRepeat):? this.__debounceRender(this.__render); ^^^^^^^^^^^^^ -/polymer.html_script_30.js:371: WARNING - Invalid type for parameter 1 of function this.__debounceRender. +/polymer.html_script_30.js:373: WARNING - Invalid type for parameter 1 of function this.__debounceRender. Expected : function():? Found : function(this:DomRepeat):? this.__debounceRender(this.__render); ^^^^^^^^^^^^^ -/polymer.html_script_30.js:391: WARNING - Invalid type for parameter 1 of function this.__debounceRender. +/polymer.html_script_30.js:393: WARNING - Invalid type for parameter 1 of function this.__debounceRender. Expected : function():? Found : function(this:DomRepeat):? this.__debounceRender(this.__requestRenderChunk); ^^^^^^^^^^^^^^^^^^^^^^^^^ -/polymer.html_script_30.js:404: WARNING - Property _targetFrameTime never defined on this of type DomRepeat +/polymer.html_script_30.js:406: WARNING - Property _targetFrameTime never defined on this of type DomRepeat let ratio = this._targetFrameTime / (currChunkTime - this.__lastChunkTime); ^^^^^^^^^^^^^^^^^^^^^ -/polymer.html_script_30.js:408: WARNING - Invalid type for parameter 1 of function this.__debounceRender. +/polymer.html_script_30.js:410: WARNING - Invalid type for parameter 1 of function this.__debounceRender. Expected : function():? Found : function(this:DomRepeat):? this.__debounceRender(this.__render); ^^^^^^^^^^^^^ -/polymer.html_script_30.js:427: WARNING - Invalid type for parameter 1 of function this.__debounceRender. +/polymer.html_script_30.js:429: WARNING - Invalid type for parameter 1 of function this.__debounceRender. Expected : function():? Found : function(this:DomRepeat):? this.__debounceRender(this.__render); ^^^^^^^^^^^^^ -/polymer.html_script_30.js:438: WARNING - Invalid type for parameter 1 of function this.__debounceRender. +/polymer.html_script_30.js:440: WARNING - Invalid type for parameter 1 of function this.__debounceRender. Expected : function():? Found : function(this:DomRepeat):? this.__debounceRender(this.__render, this.delay); ^^^^^^^^^^^^^ -/polymer.html_script_30.js:438: WARNING - Property delay never defined on this of type DomRepeat{__needFullRefresh:boolean, __observePaths:truthy} +/polymer.html_script_30.js:440: WARNING - Property delay never defined on this of type DomRepeat{__needFullRefresh:boolean, __observePaths:truthy} this.__debounceRender(this.__render, this.delay); ^^^^^^^^^^ -/polymer.html_script_30.js:452: WARNING - Invalid type for parameter 1 of function Polymer.Async.timeOut.after. +/polymer.html_script_30.js:454: WARNING - Invalid type for parameter 1 of function Polymer.Async.timeOut.after. Expected : number Found : number|undefined More details: @@ -878,66 +818,66 @@ The found type is a union that includes an unexpected type: undefined , delay > 0 ? Polymer.Async.timeOut.after(delay) : Polymer.Async.microTask ^^^^^ -/polymer.html_script_30.js:467: WARNING - Invalid type for parameter 1 of function this.__debounceRender. +/polymer.html_script_30.js:469: WARNING - Invalid type for parameter 1 of function this.__debounceRender. Expected : function():? Found : function(this:DomRepeat):? this.__debounceRender(this.__render); ^^^^^^^^^^^^^ -/polymer.html_script_30.js:484: WARNING - Property _setRenderedItemCount never defined on this of type DomRepeat{__pool:{length:number} (loose)} +/polymer.html_script_30.js:486: WARNING - Property _setRenderedItemCount never defined on this of type DomRepeat{__pool:{length:number} (loose)} this._setRenderedItemCount(this.__instances.length); ^^^^^^^^^^^^^^^^^^^^^^^^^^ -/polymer.html_script_30.js:520: WARNING - Property as never defined on this of type DomRepeat{__instances:Object, __itemsIdxToInstIdx:Object{}, __limit:number, items:?=} +/polymer.html_script_30.js:522: WARNING - Property as never defined on this of type DomRepeat{__instances:Object, __itemsIdxToInstIdx:Object{}, __limit:number, items:?=} inst._setPendingProperty(this.as, item); ^^^^^^^ -/polymer.html_script_30.js:521: WARNING - Property indexAs never defined on this of type DomRepeat{__instances:Object, __itemsIdxToInstIdx:Object{}, __limit:number, items:?=} +/polymer.html_script_30.js:523: WARNING - Property indexAs never defined on this of type DomRepeat{__instances:Object, __itemsIdxToInstIdx:Object{}, __limit:number, items:?=} inst._setPendingProperty(this.indexAs, instIdx); ^^^^^^^^^^^^ -/polymer.html_script_30.js:522: WARNING - Property itemsIndexAs never defined on this of type DomRepeat{__instances:Object, __itemsIdxToInstIdx:Object{}, __limit:number, items:?=} +/polymer.html_script_30.js:524: WARNING - Property itemsIndexAs never defined on this of type DomRepeat{__instances:Object, __itemsIdxToInstIdx:Object{}, __limit:number, items:?=} inst._setPendingProperty(this.itemsIndexAs, itemIdx); ^^^^^^^^^^^^^^^^^ -/polymer.html_script_30.js:558: WARNING - Property as never defined on this of type DomRepeat +/polymer.html_script_30.js:560: WARNING - Property as never defined on this of type DomRepeat model[this.as] = item; ^^^^^^^ -/polymer.html_script_30.js:559: WARNING - Property indexAs never defined on this of type DomRepeat +/polymer.html_script_30.js:561: WARNING - Property indexAs never defined on this of type DomRepeat model[this.indexAs] = instIdx; ^^^^^^^^^^^^ -/polymer.html_script_30.js:560: WARNING - Property itemsIndexAs never defined on this of type DomRepeat +/polymer.html_script_30.js:562: WARNING - Property itemsIndexAs never defined on this of type DomRepeat model[this.itemsIndexAs] = itemIdx; ^^^^^^^^^^^^^^^^^ -/polymer.html_script_30.js:569: WARNING - Property as never defined on this of type DomRepeat{__pool:{pop:LOOSE_TOP_FUNCTION} (loose)} +/polymer.html_script_30.js:571: WARNING - Property as never defined on this of type DomRepeat{__pool:{pop:LOOSE_TOP_FUNCTION} (loose)} inst._setPendingProperty(this.as, item); ^^^^^^^ -/polymer.html_script_30.js:570: WARNING - Property indexAs never defined on this of type DomRepeat{__pool:{pop:LOOSE_TOP_FUNCTION} (loose)} +/polymer.html_script_30.js:572: WARNING - Property indexAs never defined on this of type DomRepeat{__pool:{pop:LOOSE_TOP_FUNCTION} (loose)} inst._setPendingProperty(this.indexAs, instIdx); ^^^^^^^^^^^^ -/polymer.html_script_30.js:571: WARNING - Property itemsIndexAs never defined on this of type DomRepeat{__pool:{pop:LOOSE_TOP_FUNCTION} (loose)} +/polymer.html_script_30.js:573: WARNING - Property itemsIndexAs never defined on this of type DomRepeat{__pool:{pop:LOOSE_TOP_FUNCTION} (loose)} inst._setPendingProperty(this.itemsIndexAs, itemIdx); ^^^^^^^^^^^^^^^^^ -/polymer.html_script_30.js:605: WARNING - Property as never defined on this of type DomRepeat{__instances:Object, __itemsIdxToInstIdx:Object} +/polymer.html_script_30.js:607: WARNING - Property as never defined on this of type DomRepeat{__instances:Object, __itemsIdxToInstIdx:Object} let itemPath = this.as + (itemSubPath ? '.' + itemSubPath : ''); ^^^^^^^ -/polymer.html_script_30.js:629: WARNING - Property as never defined on this of type DomRepeat +/polymer.html_script_30.js:631: WARNING - Property as never defined on this of type DomRepeat return instance && instance[this.as]; ^^^^^^^ -/polymer.html_script_30.js:643: WARNING - Property indexAs never defined on this of type DomRepeat +/polymer.html_script_30.js:645: WARNING - Property indexAs never defined on this of type DomRepeat return instance && instance[this.indexAs]; ^^^^^^^^^^^^ -/polymer.html_script_30.js:664: WARNING - Property template never defined on this of type DomRepeat +/polymer.html_script_30.js:666: WARNING - Property template never defined on this of type DomRepeat return Polymer.Templatize.modelForElement(this.template, el); ^^^^^^^^^^^^^ @@ -953,35 +893,11 @@ Found : function(this:DomRepeat):? this.__ctor = Polymer.Templatize.templatize(template, this, { ^^^^^^^^^^^ -/polymer.html_script_31.js:175: WARNING - Dangerous use of the global THIS object - if (this.__instance) { - ^^^^ - -/polymer.html_script_31.js:176: WARNING - Dangerous use of the global THIS object - if (this.if) { - ^^^^ - -/polymer.html_script_31.js:177: WARNING - Dangerous use of the global THIS object - this.__instance.forwardHostProp(prop, value); - ^^^^ - -/polymer.html_script_31.js:183: WARNING - Dangerous use of the global THIS object - this.__invalidProps = this.__invalidProps || Object.create(null); - ^^^^ - -/polymer.html_script_31.js:183: WARNING - Dangerous use of the global THIS object - this.__invalidProps = this.__invalidProps || Object.create(null); - ^^^^ - -/polymer.html_script_31.js:184: WARNING - Dangerous use of the global THIS object - this.__invalidProps[Polymer.Path.root(prop)] = true; - ^^^^ - -/polymer.html_script_31.js:214: WARNING - Property __dataHost never defined on this of type DomIf{__instance:{_setPendingProperty:LOOSE_TOP_FUNCTION} (loose)} +/polymer.html_script_31.js:215: WARNING - Property __dataHost never defined on this of type DomIf{__instance:{_setPendingProperty:LOOSE_TOP_FUNCTION} (loose)} this.__instance._setPendingProperty(prop, this.__dataHost[prop]); ^^^^^^^^^^^^^^^ -/polymer.html_script_31.js:237: WARNING - Property if never defined on this of type DomIf +/polymer.html_script_31.js:238: WARNING - Property if never defined on this of type DomIf let hidden = this.__hideTemplateChildren__ || !this.if; ^^^^^^^ @@ -1095,26 +1011,6 @@ Found : Element let mutablePropertyChange = Polymer.MutableData._mutablePropertyChange; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -/polymer.html_script_34.js:132: WARNING - Dangerous use of the global THIS object - return mutablePropertyChange(this, property, value, old, this.mutableData); - ^^^^ - -/polymer.html_script_4.js:37: WARNING - Dangerous use of the global THIS object - cssText += this.cssFromModule(modules[i]); - ^^^^ - -/polymer.html_script_4.js:61: WARNING - Dangerous use of the global THIS object - cssText += this.cssFromTemplate(t, m.assetpath); - ^^^^ - -/polymer.html_script_4.js:64: WARNING - Dangerous use of the global THIS object - cssText += this.cssFromModuleImports(moduleId); - ^^^^ - -/polymer.html_script_4.js:93: WARNING - Dangerous use of the global THIS object - cssText += this.cssFromModules(include); - ^^^^ - /polymer.html_script_5.js:87: WARNING - Property importForElement never defined on HTMLImports of type HTMLImports HTMLImports.importForElement(this) || document : this.ownerDocument; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1123,25 +1019,12 @@ Found : Element this.__assetpath = Polymer.ResolveUrl.pathFromUrl(url); ^^^^^^^^^^^^^^^^ -/polymer.html_script_6.js:121: WARNING - Dangerous use of the global THIS object - this.isAncestor(base, path) || - ^^^^ +/polymer.html_script_6.js:179: WARNING - Invalid type for parameter 1 of function this.normalize. +Expected : string|undefined +Found : Array -/polymer.html_script_6.js:122: WARNING - Dangerous use of the global THIS object - this.isDescendant(base, path); - ^^^^ - -/polymer.html_script_6.js:172: WARNING - Dangerous use of the global THIS object return this.normalize(path).split('.'); - ^^^^ - -/polymer.html_script_6.js:191: WARNING - Dangerous use of the global THIS object - let parts = this.split(path); - ^^^^ - -/polymer.html_script_6.js:218: WARNING - Dangerous use of the global THIS object - let parts = this.split(path); - ^^^^ + ^^^^ /polymer.html_script_8.js:110: WARNING - Function this._attributeToProperty: called with 2 argument(s). Function requires at least 3 argument(s) and at most 3. this._attributeToProperty(name, value); @@ -1165,22 +1048,10 @@ Found : PropertyAccessors{__serializing:boolean} this._valueToNodeAttribute(this, value, ^^^^ -/polymer.html_script_8.js:372: WARNING - Dangerous use of the global THIS object - return this.__data[property]; - ^^^^ - -/polymer.html_script_8.js:375: WARNING - Dangerous use of the global THIS object - this._setProperty(property, value); - ^^^^ - -/polymer.html_script_8.js:416: WARNING - Missing return statement. Function expected to return boolean. +/polymer.html_script_8.js:412: WARNING - Missing return statement. Function expected to return boolean. _setPendingProperty(property, value) { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -/polymer.html_script_9.js:110: WARNING - Cannot add property $ to a struct instance after it is constructed. - this.$ = null; - ^^^^^^ - /polymer.html_script_9.js:215: WARNING - Property hasAttribute never defined on node of type Node if (node.localName == 'template' && !node.hasAttribute('preserve-content')) { ^^^^^^^^^^^^^^^^^ @@ -1223,40 +1094,40 @@ Found : Node{$:Object{}, __noInsertionPoint:boolean, nodeList:Array} return dom; ^^^^^^^^^^^ -externs/closure-types.js:378: WARNING - property connectedCallback not defined on any supertype of Polymer_ElementMixin +externs/closure-types.js:375: WARNING - property connectedCallback not defined on any supertype of Polymer_ElementMixin Polymer_ElementMixin.prototype.connectedCallback = function(){}; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -externs/closure-types.js:382: WARNING - property disconnectedCallback not defined on any supertype of Polymer_ElementMixin +externs/closure-types.js:379: WARNING - property disconnectedCallback not defined on any supertype of Polymer_ElementMixin Polymer_ElementMixin.prototype.disconnectedCallback = function(){}; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -externs/closure-types.js:402: WARNING - property attributeChangedCallback not defined on any supertype of Polymer_ElementMixin +externs/closure-types.js:399: WARNING - property attributeChangedCallback not defined on any supertype of Polymer_ElementMixin Polymer_ElementMixin.prototype.attributeChangedCallback = function(name, old, value){}; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -externs/closure-types.js:736: WARNING - property mutableData on interface Polymer_OptionalMutableData is not implemented by type OptionalMutableData +externs/closure-types.js:733: WARNING - property mutableData on interface Polymer_OptionalMutableData is not implemented by type OptionalMutableData Polymer_OptionalMutableData.prototype.mutableData; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -externs/closure-types.js:750: WARNING - property items on interface Polymer_ArraySelectorMixin is not implemented by type ArraySelectorMixin +externs/closure-types.js:747: WARNING - property items on interface Polymer_ArraySelectorMixin is not implemented by type ArraySelectorMixin Polymer_ArraySelectorMixin.prototype.items; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -externs/closure-types.js:753: WARNING - property multi on interface Polymer_ArraySelectorMixin is not implemented by type ArraySelectorMixin +externs/closure-types.js:750: WARNING - property multi on interface Polymer_ArraySelectorMixin is not implemented by type ArraySelectorMixin Polymer_ArraySelectorMixin.prototype.multi; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -externs/closure-types.js:756: WARNING - property selected on interface Polymer_ArraySelectorMixin is not implemented by type ArraySelectorMixin +externs/closure-types.js:753: WARNING - property selected on interface Polymer_ArraySelectorMixin is not implemented by type ArraySelectorMixin Polymer_ArraySelectorMixin.prototype.selected; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -externs/closure-types.js:759: WARNING - property selectedItem on interface Polymer_ArraySelectorMixin is not implemented by type ArraySelectorMixin +externs/closure-types.js:756: WARNING - property selectedItem on interface Polymer_ArraySelectorMixin is not implemented by type ArraySelectorMixin Polymer_ArraySelectorMixin.prototype.selectedItem; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -externs/closure-types.js:762: WARNING - property toggle on interface Polymer_ArraySelectorMixin is not implemented by type ArraySelectorMixin +externs/closure-types.js:759: WARNING - property toggle on interface Polymer_ArraySelectorMixin is not implemented by type ArraySelectorMixin Polymer_ArraySelectorMixin.prototype.toggle; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -0 error(s), 275 warning(s), 74.5% typed +0 error(s), 242 warning(s), 74.7% typed diff --git a/externs/closure-types.js b/externs/closure-types.js index 641c231c11..0612756caf 100644 --- a/externs/closure-types.js +++ b/externs/closure-types.js @@ -109,9 +109,6 @@ Polymer_PropertyAccessors.prototype._shouldPropertyChange = function(property, v */ function Polymer_TemplateStamp(){} /** -*/ -Polymer_TemplateStamp.prototype._initializeProperties = function(){}; -/** * @param {HTMLTemplateElement} template * @return {DocumentFragment} */ diff --git a/externs/polymer-externs.js b/externs/polymer-externs.js index 7305e11caf..32a0b55651 100644 --- a/externs/polymer-externs.js +++ b/externs/polymer-externs.js @@ -9,9 +9,27 @@ */ function Polymer(init){} +/** + * @type {(function(*,string,string,Node):*)|undefined} + */ +Polymer.sanitizeDOMValue; + /** * @param {string} string * @param {Object} obj * @return {string} */ -function JSCompiler_renameProperty(string, obj) {} \ No newline at end of file +function JSCompiler_renameProperty(string, obj) {} + +/** @record */ +function PolymerTelemetry(){} +/** @type {number} */ +PolymerTelemetry.prototype.instanceCount; +/** @type {Array} */ +PolymerTelemetry.prototype.registrations; +/** @type {function(HTMLElement)} */ +PolymerTelemetry.prototype._regLog; +/** @type {function(HTMLElement)} */ +PolymerTelemetry.prototype.register; +/** @type {function(HTMLElement)} */ +PolymerTelemetry.prototype.dumpRegistrations; \ No newline at end of file diff --git a/lib/elements/dom-if.html b/lib/elements/dom-if.html index 842e5a6593..fbf6707e03 100644 --- a/lib/elements/dom-if.html +++ b/lib/elements/dom-if.html @@ -186,6 +186,7 @@ // dom-if templatizer instances require `mutable: true`, as // `__syncHostProperties` relies on that behavior to sync objects mutableData: true, + /** @this {this} */ forwardHostProp: function(prop, value) { if (this.__instance) { if (this.if) { diff --git a/lib/elements/dom-repeat.html b/lib/elements/dom-repeat.html index 2d14691987..f93d23fa73 100644 --- a/lib/elements/dom-repeat.html +++ b/lib/elements/dom-repeat.html @@ -338,12 +338,14 @@ mutableData: this.mutableData, parentModel: true, instanceProps: instanceProps, + /** @this {this} */ forwardHostProp: function(prop, value) { let i$ = this.__instances; for (let i=0, inst; (i this.__data[property], + set: readOnly ? function(){} : (value) => {this._setProperty(property, value)} }); } } diff --git a/lib/mixins/property-effects.html b/lib/mixins/property-effects.html index 3174667eff..41ae03d0f6 100644 --- a/lib/mixins/property-effects.html +++ b/lib/mixins/property-effects.html @@ -307,7 +307,7 @@ * the event contained path information, translate that path to the host * scope's name for that path first. * - * @param {Event} event Notification event (e.g. '-changed') + * @param {CustomEvent} event Notification event (e.g. '-changed') * @param {Object} inst Host element instance handling the notification event * @param {string} fromProp Child element property that was bound * @param {string} toPath Host property/path that was bound @@ -316,7 +316,7 @@ */ function handleNotification(event, inst, fromProp, toPath, negate) { let value; - let detail = event.detail; + let detail = /** @type {Object} */(event.detail); let fromPath = detail && detail.path; if (fromPath) { toPath = Polymer.Path.translate(fromProp, toPath, fromPath); @@ -348,7 +348,7 @@ function runReflectEffect(inst, property, props, oldProps, info) { let value = inst.__data[property]; if (Polymer.sanitizeDOMValue) { - value = Polymer.sanitizeDOMValue(value, info.attrName, 'attribute', inst); + value = Polymer.sanitizeDOMValue(value, info.attrName, 'attribute', /** @type {Node} */(inst)); } inst._propertyToAttribute(property, info.attrName, value); } @@ -1888,7 +1888,7 @@ _createReadOnlyProperty(property, protectedSetter) { this._addPropertyEffect(property, TYPES.READ_ONLY); if (protectedSetter) { - this['_set' + upper(property)] = function(value) { + this['_set' + upper(property)] = /** @this {PropertyEffects} */function(value) { this._setProperty(property, value); } } diff --git a/lib/utils/path.html b/lib/utils/path.html index 2dfe89403c..a686ba54af 100644 --- a/lib/utils/path.html +++ b/lib/utils/path.html @@ -128,6 +128,12 @@ return newBase + path.slice(base.length); }, + /** + * @param {string} base Path string to test against + * @param {string} path Path string to test + * @return {boolean} True if `path` is equal to `base` + * @this {Path} + */ matches: function(base, path) { return (base === path) || this.isAncestor(base, path) || @@ -178,6 +184,7 @@ * @memberof Polymer.Path * @param {string | !Array} path Input path * @return {!Array} Array of path parts + * @this {Path} */ split: function(path) { if (Array.isArray(path)) { @@ -197,6 +204,7 @@ * (flattened) path will be set to `info.path`. * @return {*} Value at path, or `undefined` if the path could not be * fully dereferenced. + * @this {Path} */ get: function(root, path, info) { let prop = root; @@ -224,6 +232,7 @@ * @param {string | !Array} path Path to set * @param {*} value Value to set to path * @return {string | undefined} The normalized version of the input path + * @this {Path} */ set: function(root, path, value) { let prop = root; diff --git a/lib/utils/style-gather.html b/lib/utils/style-gather.html index e18a347fc2..edbaa3cd75 100644 --- a/lib/utils/style-gather.html +++ b/lib/utils/style-gather.html @@ -39,6 +39,7 @@ * @param {string} moduleIds List of dom-module id's within which to * search for css. * @return {string} Concatenated CSS content from specified `dom-module`s + * @this {StyleGather} */ cssFromModules(moduleIds) { let modules = moduleIds.trim().split(' '); @@ -60,6 +61,7 @@ * @memberof Polymer.StyleGather * @param {string} moduleId dom-module id to gather styles from * @return {string} Concatenated CSS content from specified `dom-module` + * @this {StyleGather} */ cssFromModule(moduleId) { let m = importModule(moduleId); @@ -89,6 +91,7 @@ * @param {HTMLTemplateElement} template Template to gather styles from * @param {string} baseURI Base URI to resolve the URL against * @return {string} Concatenated CSS content from specified template + * @this {StyleGather} */ cssFromTemplate(template, baseURI) { let cssText = ''; @@ -116,6 +119,7 @@ * @memberof Polymer.StyleGather * @param {string} moduleId Id of `dom-module` to gather CSS from * @return {string} Concatenated CSS content from links in specified `dom-module` + * @this {StyleGather} */ cssFromModuleImports(moduleId) { let cssText = '';