Skip to content

Commit

Permalink
remove all "global this" warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Apr 28, 2017
1 parent f821e46 commit c0ddc60
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 186 deletions.
215 changes: 43 additions & 172 deletions closure.log

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions externs/closure-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ Polymer_PropertyAccessors.prototype._shouldPropertyChange = function(property, v
*/
function Polymer_TemplateStamp(){}
/**
*/
Polymer_TemplateStamp.prototype._initializeProperties = function(){};
/**
* @param {HTMLTemplateElement} template
* @return {DocumentFragment}
*/
Expand Down
20 changes: 19 additions & 1 deletion externs/polymer-externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
function JSCompiler_renameProperty(string, obj) {}

/** @record */
function PolymerTelemetry(){}
/** @type {number} */
PolymerTelemetry.prototype.instanceCount;
/** @type {Array<HTMLElement>} */
PolymerTelemetry.prototype.registrations;
/** @type {function(HTMLElement)} */
PolymerTelemetry.prototype._regLog;
/** @type {function(HTMLElement)} */
PolymerTelemetry.prototype.register;
/** @type {function(HTMLElement)} */
PolymerTelemetry.prototype.dumpRegistrations;
1 change: 1 addition & 0 deletions lib/elements/dom-if.html
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions lib/elements/dom-repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -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<i$.length) && (inst=i$[i]); i++) {
inst.forwardHostProp(prop, value);
}
},
/** @this {this} */
notifyInstanceProp: function(inst, prop, value) {
if (Polymer.Path.matches(this.as, prop)) {
let idx = inst[this.itemsIndexAs];
Expand Down
1 change: 1 addition & 0 deletions lib/legacy/mutable-data-behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
* @param {*} value New property value
* @param {*} old Previous property value
* @return {boolean} Whether the property should be considered a change
* @this {this}
* @protected
*/
_shouldPropertyChange(property, value, old) {
Expand Down
2 changes: 2 additions & 0 deletions lib/mixins/element-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@
* Registers a class prototype for telemetry purposes.
* @param {HTMLElement} prototype Element prototype to register
* @protected
* @this {PolymerTelemetry}
*/
register: function(prototype) {
this.registrations.push(prototype);
Expand All @@ -899,6 +900,7 @@
/**
* Logs all elements registered with an `is` to the console.
* @public
* @this {PolymerTelemetry}
*/
dumpRegistrations: function() {
this.registrations.forEach(this._regLog);
Expand Down
8 changes: 2 additions & 6 deletions lib/mixins/property-accessors.html
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,8 @@
this.__dataHasAccessor[property] = true;
saveAccessorValue(this, property);
Object.defineProperty(this, property, {
get: function() {
return this.__data[property];
},
set: readOnly ? function() { } : function(value) {
this._setProperty(property, value);
}
get: () => this.__data[property],
set: readOnly ? function(){} : (value) => {this._setProperty(property, value)}
});
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/mixins/property-effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -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. '<property>-changed')
* @param {CustomEvent} event Notification event (e.g. '<property>-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
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
}
Expand Down
9 changes: 9 additions & 0 deletions lib/utils/path.html
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand Down Expand Up @@ -178,6 +184,7 @@
* @memberof Polymer.Path
* @param {string | !Array<string|number>} path Input path
* @return {!Array<string>} Array of path parts
* @this {Path}
*/
split: function(path) {
if (Array.isArray(path)) {
Expand All @@ -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;
Expand Down Expand Up @@ -224,6 +232,7 @@
* @param {string | !Array<string|number>} 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;
Expand Down
4 changes: 4 additions & 0 deletions lib/utils/style-gather.html
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ');
Expand All @@ -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);
Expand Down Expand Up @@ -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 = '';
Expand Down Expand Up @@ -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 = '';
Expand Down

0 comments on commit c0ddc60

Please sign in to comment.