Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport closure compiler fixes from internal #5480

Merged
merged 7 commits into from
Feb 6, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/legacy/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function flattenBehaviors(behaviors, list, exclude) {
/**
* @param {!PolymerInit} info Polymer info object
* @param {function(new:HTMLElement)} Base base class to extend with info object
* @param {Object} behaviors behaviors to copy into the element
* @param {Object=} behaviors behaviors to copy into the element
* @return {function(new:HTMLElement)} Generated class
* @suppress {checkTypes}
* @private
Expand Down
27 changes: 23 additions & 4 deletions lib/legacy/legacy-data-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,31 @@ Polymer.Class = (info, mixin) => Class(info,

// Apply LegacyDataMixin to Templatizer instances as well, and defer
// runtime switch to the root's host (_methodHost)
templatize.mixin =
dedupingMixin(superClass => class extends LegacyDataMixin(superClass) {
get _legacyUndefinedCheck() {
return this._methodHost && this._methodHost._legacyUndefinedCheck;
/**
* @mixinFunction
* @polymer
*/
const TemplatizeMixin =
dedupingMixin(superClass => {
/**
* @constructor
* @extends {HTMLElement}
*/
const legacyBase = LegacyDataMixin(superClass);
/**
* @private
*/
class TemplateLegacy extends legacyBase {
get _legacyUndefinedCheck() {
return this._methodHost && this._methodHost._legacyUndefinedCheck;
}
}
/** @type {!Polymer_PropertyEffects} */
TemplateLegacy.prototype._methodHost;
return TemplateLegacy;
});

templatize.mixin = TemplatizeMixin;

console.info('LegacyDataMixin will be applied to all legacy elements.\n' +
'Set `_legacyUndefinedCheck: true` on element class to enable.');
6 changes: 3 additions & 3 deletions lib/legacy/legacy-element-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ export const LegacyElementMixin = dedupingMixin((base) => {
*/
distributeContent() {
const thisEl = /** @type {Element} */ (this);
const domApi = /** @type {DomApi} */(dom(thisEl));
const domApi = /** @type {PolymerDomApi} */(dom(thisEl));
if (window.ShadyDOM && domApi.shadowRoot) {
ShadyDOM.flush();
}
Expand Down Expand Up @@ -879,9 +879,9 @@ export const LegacyElementMixin = dedupingMixin((base) => {
* @override
*/
toggleAttribute(name, bool) {
let node = /** @type {Element} */ this;
let node = /** @type {Element} */(this);
if (arguments.length === 3) {
node = /** @type {Element} */ arguments[2];
node = /** @type {Element} */(arguments[2]);
}
if (arguments.length == 1) {
bool = !node.hasAttribute(name);
Expand Down
15 changes: 9 additions & 6 deletions lib/legacy/polymer.dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const matchesSelector = function(node, selector) {
* @implements {PolymerDomApi}
* @unrestricted
*/
let DomApi = class {
class DomApi {

/**
* @param {Node} node Node for which to create a Polymer.dom helper object.
Expand Down Expand Up @@ -197,7 +197,7 @@ let DomApi = class {
* For shadow roots, returns the currently focused element within this
* shadow root.
*
* @return {Node|undefined} Currently focused element
* return {Node|undefined} Currently focused element
* @override
*/
get activeElement() {
Expand Down Expand Up @@ -378,7 +378,7 @@ DomApi.prototype.textContent;
/** @type {string} */
DomApi.prototype.innerHTML;

export {DomApi};
let DomApiImpl = DomApi;

if (window['ShadyDOM'] && window['ShadyDOM']['inUse'] && window['ShadyDOM']['noPatch'] && window['ShadyDOM']['Wrapper']) {

Expand All @@ -395,7 +395,7 @@ if (window['ShadyDOM'] && window['ShadyDOM']['inUse'] && window['ShadyDOM']['noP
}
});

DomApi = Wrapper;
DomApiImpl = Wrapper;

Object.defineProperties(EventApi.prototype, {

Expand Down Expand Up @@ -450,7 +450,7 @@ if (window['ShadyDOM'] && window['ShadyDOM']['inUse'] && window['ShadyDOM']['noP
*/
export const dom = function(obj) {
obj = obj || document;
if (obj instanceof DomApi) {
if (obj instanceof DomApiImpl) {
return /** @type {!DomApi} */(obj);
}
if (obj instanceof EventApi) {
Expand All @@ -461,9 +461,12 @@ export const dom = function(obj) {
if (obj instanceof Event) {
helper = new EventApi(obj);
} else {
helper = new DomApi(/** @type {Node} */(obj));
helper = new DomApiImpl(/** @type {Node} */(obj));
}
obj['__domApi'] = helper;
}
return helper;
};

const ExportedDomApi = DomApiImpl;
export {ExportedDomApi as DomApi};
16 changes: 8 additions & 8 deletions lib/mixins/dir-mixin.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt The complete set of authors may be found
* at http://polymer.github.io/AUTHORS.txt The complete set of contributors may
* be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by
* Google as part of the polymer project is also subject to an additional IP
* rights grant found at http://polymer.github.io/PATENTS.txt
* @suppress {checkPrototypalTypes}
dfreedm marked this conversation as resolved.
Show resolved Hide resolved
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
*/
import { PropertyAccessors } from './property-accessors.js';

import { dedupingMixin } from '../utils/mixin.js';
Expand Down
16 changes: 8 additions & 8 deletions lib/mixins/disable-upgrade-mixin.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt The complete set of authors may be found
* at http://polymer.github.io/AUTHORS.txt The complete set of contributors may
* be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by
* Google as part of the polymer project is also subject to an additional IP
* rights grant found at http://polymer.github.io/PATENTS.txt
* @suppress {checkPrototypalTypes}
dfreedm marked this conversation as resolved.
Show resolved Hide resolved
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
*/
import { ElementMixin } from './element-mixin.js';

import { dedupingMixin } from '../utils/mixin.js';
Expand Down
19 changes: 10 additions & 9 deletions lib/mixins/element-mixin.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt The complete set of authors may be found
* at http://polymer.github.io/AUTHORS.txt The complete set of contributors may
* be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by
* Google as part of the polymer project is also subject to an additional IP
* rights grant found at http://polymer.github.io/PATENTS.txt
* @suppress {checkPrototypalTypes}
dfreedm marked this conversation as resolved.
Show resolved Hide resolved
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
*/
import '../utils/boot.js';

import { rootPath, strictTemplatePolicy, allowTemplateFromDomModule, legacyOptimizations, syncInitialRender } from '../utils/settings.js';
Expand Down Expand Up @@ -325,7 +325,7 @@ export const ElementMixin = dedupingMixin(base => {
*/
class PolymerElement extends polymerElementBase {

/**
/**
* Current Polymer version in Semver notation.
* @type {string} Semver notation of the current version of Polymer.
*/
Expand Down Expand Up @@ -765,6 +765,7 @@ export const ElementMixin = dedupingMixin(base => {
* @param {Object=} effect Effect metadata object
* @return {void}
* @protected
* @suppress {missingProperties} Interfaces in closure do not inherit statics, but classes do
*/
static _addTemplatePropertyEffect(templateInfo, prop, effect) {
// Warn if properties are used in template without being declared.
Expand Down
2 changes: 1 addition & 1 deletion lib/mixins/properties-changed.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ export const PropertiesChanged = dedupingMixin(
node.removeAttribute(attribute);
} else {
if (attribute === 'class' || attribute === 'name' || attribute === 'slot') {
node = wrap(node);
node = /** @type {?Element} */(wrap(node));
}
node.setAttribute(attribute, str);
}
Expand Down
18 changes: 9 additions & 9 deletions lib/mixins/property-effects.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt The complete set of authors may be found
* at http://polymer.github.io/AUTHORS.txt The complete set of contributors may
* be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by
* Google as part of the polymer project is also subject to an additional IP
* rights grant found at http://polymer.github.io/PATENTS.txt
* @suppress {checkPrototypalTypes}
dfreedm marked this conversation as resolved.
Show resolved Hide resolved
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
*/

import '../utils/boot.js';
import { wrap } from '../utils/wrap.js';
Expand Down Expand Up @@ -1172,7 +1172,7 @@ export const PropertyEffects = dedupingMixin(superClass => {
* the prototype on the instance.
*
* @override
* @param {!Object} props Properties to initialize on the prototype
* @param {Object} props Properties to initialize on the prototype
* @return {void}
*/
_initializeProtoProperties(props) {
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/gestures.js
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ export function setTouchAction(node, value) {
function _fire(target, type, detail) {
let ev = new Event(type, { bubbles: true, cancelable: true, composed: true });
ev.detail = detail;
wrap(target).dispatchEvent(ev);
wrap(/** @type {!Node} */(target)).dispatchEvent(ev);
// forward `preventDefault` in a clean way
if (ev.defaultPrevented) {
let preventer = detail.preventer || detail.sourceEvent;
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/telemetry.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const registrations = [];
* @private
*/
function _regLog(prototype) {
console.log('[' + prototype.is + ']: registered');
console.log('[' + /** @type {?} */(prototype).is + ']: registered');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/templatize.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ function createTemplatizerClass(template, templateInfo, options) {
*/
let templatizerBase = options.mutableData ?
MutableTemplateInstanceBase : TemplateInstanceBase;

// Affordance for global mixins onto TemplatizeInstance
if (templatize.mixin) {
templatizerBase = templatize.mixin(templatizerBase);
Expand Down