Skip to content

Commit 8f7119a

Browse files
authored
Merge pull request #5528 from Polymer/closure-statics-workaround
Upstream compilation fixes
2 parents 07f1e19 + 6960c2b commit 8f7119a

12 files changed

+105
-12
lines changed

lib/legacy/class.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ function flattenBehaviors(behaviors, list, exclude) {
159159
* Copies property descriptors from source to target, overwriting all fields
160160
* of any previous descriptor for a property *except* for `value`, which is
161161
* merged in from the target if it does not exist on the source.
162-
*
162+
*
163163
* @param {*} target Target properties object
164164
* @param {*} source Source properties object
165165
*/
@@ -215,10 +215,13 @@ function GenerateClassFromInfo(info, Base, behaviors) {
215215
class PolymerGenerated extends Base {
216216

217217
// explicitly not calling super._finalizeClass
218+
/** @nocollapse */
218219
static _finalizeClass() {
219220
// if calling via a subclass that hasn't been generated, pass through to super
220221
if (!this.hasOwnProperty(JSCompiler_renameProperty('generatedFrom', this))) {
221-
super._finalizeClass();
222+
// TODO(https://github.com/google/closure-compiler/issues/3240):
223+
// Change back to just super.methodCall()
224+
Base._finalizeClass.call(this);
222225
} else {
223226
// interleave properties and observers per behavior and `info`
224227
if (behaviorList) {
@@ -243,6 +246,7 @@ function GenerateClassFromInfo(info, Base, behaviors) {
243246
}
244247
}
245248

249+
/** @nocollapse */
246250
static get properties() {
247251
const properties = {};
248252
if (behaviorList) {
@@ -254,6 +258,7 @@ function GenerateClassFromInfo(info, Base, behaviors) {
254258
return properties;
255259
}
256260

261+
/** @nocollapse */
257262
static get observers() {
258263
let observers = [];
259264
if (behaviorList) {

lib/legacy/legacy-data-mixin.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export const LegacyDataMixin = dedupingMixin(superClass => {
9494
// undefined or not. Multi-property observers must have all arguments defined
9595
if (this._legacyUndefinedCheck && vals.length > 1) {
9696
for (let i=0; i<vals.length; i++) {
97-
if (vals[i] === undefined ||
97+
if (vals[i] === undefined ||
9898
(args[i].wildcard && vals[i].base === undefined)) {
9999
// Break out of effect's control flow; will be caught in
100100
// wrapped property effect function below
@@ -130,9 +130,13 @@ export const LegacyDataMixin = dedupingMixin(superClass => {
130130
* @param {Object=} effect Effect metadata object
131131
* @return {void}
132132
* @protected
133+
* @nocollapse
133134
*/
134135
static _addTemplatePropertyEffect(templateInfo, prop, effect) {
135-
return super._addTemplatePropertyEffect(templateInfo, prop, wrapEffect(effect));
136+
// TODO(https://github.com/google/closure-compiler/issues/3240):
137+
// Change back to just super.methodCall()
138+
return superClass._addTemplatePropertyEffect.call(
139+
this, templateInfo, prop, wrapEffect(effect));
136140
}
137141

138142
}

lib/legacy/legacy-element-mixin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export const LegacyElementMixin = dedupingMixin((base) => {
8585
* @return {!Object} The `import.meta` object set on the prototype
8686
* @suppress {missingProperties} `this` is always in the instance in
8787
* closure for some reason even in a static method, rather than the class
88+
* @nocollapse
8889
*/
8990
static get importMeta() {
9091
return this.prototype.importMeta;

lib/mixins/dir-mixin.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,12 @@ export const DirMixin = dedupingMixin((base) => {
113113
* @param {string} baseURI .
114114
* @return {string} .
115115
* @suppress {missingProperties} Interfaces in closure do not inherit statics, but classes do
116+
* @nocollapse
116117
*/
117118
static _processStyleText(cssText, baseURI) {
118-
cssText = super._processStyleText(cssText, baseURI);
119+
// TODO(https://github.com/google/closure-compiler/issues/3240):
120+
// Change back to just super.methodCall()
121+
cssText = elementBase._processStyleText.call(this, cssText, baseURI);
119122
if (!SHIM_SHADOW && DIR_CHECK.test(cssText)) {
120123
cssText = this._replaceDirInCssText(cssText);
121124
this.__activateDir = true;
@@ -128,6 +131,7 @@ export const DirMixin = dedupingMixin((base) => {
128131
*
129132
* @param {string} text CSS text to replace DIR
130133
* @return {string} Modified CSS
134+
* @nocollapse
131135
*/
132136
static _replaceDirInCssText(text) {
133137
let replacedText = text;

lib/mixins/element-mixin.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ export const ElementMixin = dedupingMixin(base => {
329329
/**
330330
* Current Polymer version in Semver notation.
331331
* @type {string} Semver notation of the current version of Polymer.
332+
* @nocollapse
332333
*/
333334
static get polymerElementVersion() {
334335
return version;
@@ -340,16 +341,20 @@ export const ElementMixin = dedupingMixin(base => {
340341
* @return {void}
341342
* @protected
342343
* @suppress {missingProperties} Interfaces in closure do not inherit statics, but classes do
344+
* @nocollapse
343345
*/
344346
static _finalizeClass() {
345-
super._finalizeClass();
347+
// TODO(https://github.com/google/closure-compiler/issues/3240):
348+
// Change back to just super.methodCall()
349+
polymerElementBase._finalizeClass.call(this);
346350
const observers = ownObservers(this);
347351
if (observers) {
348352
this.createObservers(observers, this._properties);
349353
}
350354
this._prepareTemplate();
351355
}
352356

357+
/** @nocollapse */
353358
static _prepareTemplate() {
354359
// note: create "working" template that is finalized at instance time
355360
let template = /** @type {PolymerElementConstructor} */ (this).template;
@@ -371,6 +376,7 @@ export const ElementMixin = dedupingMixin(base => {
371376
* @param {!Object} props .
372377
* @return {void}
373378
* @protected
379+
* @nocollapse
374380
*/
375381
static createProperties(props) {
376382
for (let p in props) {
@@ -388,6 +394,7 @@ export const ElementMixin = dedupingMixin(base => {
388394
* reference is changed
389395
* @return {void}
390396
* @protected
397+
* @nocollapse
391398
*/
392399
static createObservers(observers, dynamicFns) {
393400
const proto = this.prototype;
@@ -431,6 +438,7 @@ export const ElementMixin = dedupingMixin(base => {
431438
* }
432439
*
433440
* @return {!HTMLTemplateElement|string} Template to be stamped
441+
* @nocollapse
434442
*/
435443
static get template() {
436444
// Explanation of template-related properties:
@@ -488,6 +496,7 @@ export const ElementMixin = dedupingMixin(base => {
488496
*
489497
* @return {string} The import path for this element class
490498
* @suppress {missingProperties}
499+
* @nocollapse
491500
*/
492501
static get importPath() {
493502
if (!this.hasOwnProperty(JSCompiler_renameProperty('_importPath', this))) {
@@ -572,6 +581,7 @@ export const ElementMixin = dedupingMixin(base => {
572581
* @param {string} baseURI Base URI to rebase CSS paths against
573582
* @return {string} The processed CSS text
574583
* @protected
584+
* @nocollapse
575585
*/
576586
static _processStyleText(cssText, baseURI) {
577587
return resolveCss(cssText, baseURI);
@@ -585,6 +595,7 @@ export const ElementMixin = dedupingMixin(base => {
585595
* @param {string} is Tag name (or type extension name) for this element
586596
* @return {void}
587597
* @protected
598+
* @nocollapse
588599
*/
589600
static _finalizeTemplate(is) {
590601
/** @const {HTMLTemplateElement} */
@@ -751,10 +762,14 @@ export const ElementMixin = dedupingMixin(base => {
751762
* @param {!NodeInfo} nodeInfo Node metadata for current template.
752763
* @return {boolean} .
753764
* @suppress {missingProperties} Interfaces in closure do not inherit statics, but classes do
765+
* @nocollapse
754766
*/
755767
static _parseTemplateContent(template, templateInfo, nodeInfo) {
756768
templateInfo.dynamicFns = templateInfo.dynamicFns || this._properties;
757-
return super._parseTemplateContent(template, templateInfo, nodeInfo);
769+
// TODO(https://github.com/google/closure-compiler/issues/3240):
770+
// Change back to just super.methodCall()
771+
return polymerElementBase._parseTemplateContent.call(
772+
this, template, templateInfo, nodeInfo);
758773
}
759774

760775
/**
@@ -767,6 +782,7 @@ export const ElementMixin = dedupingMixin(base => {
767782
* @return {void}
768783
* @protected
769784
* @suppress {missingProperties} Interfaces in closure do not inherit statics, but classes do
785+
* @nocollapse
770786
*/
771787
static _addTemplatePropertyEffect(templateInfo, prop, effect) {
772788
// Warn if properties are used in template without being declared.
@@ -781,7 +797,10 @@ export const ElementMixin = dedupingMixin(base => {
781797
console.warn(`Property '${prop}' used in template but not declared in 'properties'; ` +
782798
`attribute will not be observed.`);
783799
}
784-
return super._addTemplatePropertyEffect(templateInfo, prop, effect);
800+
// TODO(https://github.com/google/closure-compiler/issues/3240):
801+
// Change back to just super.methodCall()
802+
return polymerElementBase._addTemplatePropertyEffect.call(
803+
this, templateInfo, prop, effect);
785804
}
786805

787806
}

lib/mixins/gesture-event-listeners.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { addListener, removeListener } from '../utils/gestures.js';
2727
* cross-platform
2828
* gesture events to nodes
2929
*/
30-
export const GestureEventListeners = dedupingMixin(
30+
const _GestureEventListeners = dedupingMixin(
3131
/**
3232
* @template T
3333
* @param {function(new:T)} superClass Class to apply mixin to.
@@ -73,3 +73,14 @@ export const GestureEventListeners = dedupingMixin(
7373

7474
return GestureEventListeners;
7575
});
76+
77+
// Somehow _GestureEventListeners is incorrectly typed as *. For now add this
78+
// cast.
79+
/**
80+
* @template T
81+
* @param {function(new:T)} superClass Class to apply mixin to.
82+
* @return {function(new:T)} superClass with mixin applied.
83+
*/
84+
export const GestureEventListeners = function(superClass) {
85+
return _GestureEventListeners(superClass);
86+
};

lib/mixins/mutable-data.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ export const OptionalMutableData = dedupingMixin(superClass => {
152152
*/
153153
class OptionalMutableData extends superClass {
154154

155+
/** @nocollapse */
155156
static get properties() {
156157
return {
157158
/**

lib/mixins/properties-changed.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const PropertiesChanged = dedupingMixin(
5555
* @param {!Object} props Object whose keys are names of accessors.
5656
* @return {void}
5757
* @protected
58+
* @nocollapse
5859
*/
5960
static createProperties(props) {
6061
const proto = this.prototype;
@@ -74,6 +75,7 @@ export const PropertiesChanged = dedupingMixin(
7475
* @return {string} Attribute name corresponding to the given property.
7576
*
7677
* @protected
78+
* @nocollapse
7779
*/
7880
static attributeNameForProperty(property) {
7981
return property.toLowerCase();
@@ -85,6 +87,7 @@ export const PropertiesChanged = dedupingMixin(
8587
* @param {string} name Name of property
8688
*
8789
* @protected
90+
* @nocollapse
8891
*/
8992
static typeForProperty(name) { } //eslint-disable-line no-unused-vars
9093

lib/mixins/properties-mixin.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export const PropertiesMixin = dedupingMixin(superClass => {
113113
* Implements standard custom elements getter to observes the attributes
114114
* listed in `properties`.
115115
* @suppress {missingProperties} Interfaces in closure do not inherit statics, but classes do
116+
* @nocollapse
116117
*/
117118
static get observedAttributes() {
118119
if (!this.hasOwnProperty('__observedAttributes')) {
@@ -129,6 +130,7 @@ export const PropertiesMixin = dedupingMixin(superClass => {
129130
* accessors exist on the element prototype. This method calls
130131
* `_finalizeClass` to finalize each constructor in the prototype chain.
131132
* @return {void}
133+
* @nocollapse
132134
*/
133135
static finalize() {
134136
if (!this.hasOwnProperty(JSCompiler_renameProperty('__finalized', this))) {
@@ -147,6 +149,7 @@ export const PropertiesMixin = dedupingMixin(superClass => {
147149
* `finalize` and finalizes the class constructor.
148150
*
149151
* @protected
152+
* @nocollapse
150153
*/
151154
static _finalizeClass() {
152155
const props = ownProperties(/** @type {!PropertiesMixinConstructor} */(this));
@@ -162,6 +165,7 @@ export const PropertiesMixin = dedupingMixin(superClass => {
162165
*
163166
* @return {Object} Object containing properties for this class
164167
* @protected
168+
* @nocollapse
165169
*/
166170
static get _properties() {
167171
if (!this.hasOwnProperty(
@@ -181,6 +185,7 @@ export const PropertiesMixin = dedupingMixin(superClass => {
181185
* @return {*} Type to which to deserialize attribute
182186
*
183187
* @protected
188+
* @nocollapse
184189
*/
185190
static typeForProperty(name) {
186191
const info = this._properties[name];

lib/mixins/property-accessors.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export const PropertyAccessors = dedupingMixin(superClass => {
119119
* `camelCase` convention
120120
*
121121
* @return {void}
122+
* @nocollapse
122123
*/
123124
static createPropertiesForAttributes() {
124125
let a$ = this.observedAttributes;
@@ -134,6 +135,7 @@ export const PropertyAccessors = dedupingMixin(superClass => {
134135
* @return {string} Attribute name corresponding to the given property.
135136
*
136137
* @protected
138+
* @nocollapse
137139
*/
138140
static attributeNameForProperty(property) {
139141
return camelToDashCase(property);

0 commit comments

Comments
 (0)