|
63 | 63 | return GenerateClassFromInfo({}, klass); |
64 | 64 | } |
65 | 65 |
|
66 | | - |
67 | 66 | function applyBehaviors(behaviors, klass) { |
68 | 67 | if (!behaviors) { |
69 | 68 | klass = /** @type {HTMLElement} */(klass); // eslint-disable-line no-self-assign |
|
72 | 71 | // NOTE: ensure the behavior is extending a class with |
73 | 72 | // legacy element api. This is necessary since behaviors expect to be able |
74 | 73 | // to access 1.x legacy api. |
75 | | - klass = class extends Polymer.LegacyElementMixin(klass) {}; |
| 74 | + klass = class extends Polymer.LegacyElementMixin(klass) { }; |
76 | 75 | if (!Array.isArray(behaviors)) { |
77 | 76 | behaviors = [behaviors]; |
78 | 77 | } |
79 | 78 | let superBehaviors = klass.prototype.behaviors; |
80 | 79 | // get flattened, deduped list of behaviors *not* already on super class |
81 | 80 | behaviors = flattenBehaviors(behaviors, null, superBehaviors); |
82 | 81 | // mixin new behaviors |
83 | | - klass = _applyBehaviors(behaviors, klass); |
| 82 | + // klass = _applyBehaviors(behaviors, klass); |
84 | 83 | if (superBehaviors) { |
85 | 84 | behaviors = superBehaviors.concat(behaviors); |
86 | 85 | } |
|
120 | 119 | // (1) C.created, (2) A.created, (3) B.created, (4) element.created |
121 | 120 | // (again same as 1.x) |
122 | 121 | function _applyBehaviors(behaviors, klass) { |
123 | | - for (let i=0; i<behaviors.length; i++) { |
124 | | - let b = behaviors[i]; |
125 | | - if (b) { |
126 | | - Array.isArray(b) ? _applyBehaviors(b, klass) : |
127 | | - copyProperties(b, klass.prototype); |
| 122 | + if (behaviors) { |
| 123 | + for (let i=0; i<behaviors.length; i++) { |
| 124 | + let b = behaviors[i]; |
| 125 | + // if (b) { |
| 126 | + // Array.isArray(b) ? _applyBehaviors(b, klass) : |
| 127 | + copyProperties(b, klass.prototype); |
| 128 | + // } |
128 | 129 | } |
| 130 | + return klass; |
129 | 131 | } |
130 | | - return klass; |
131 | 132 | } |
132 | 133 |
|
133 | 134 | /** |
|
286 | 287 | in `beforeRegister` or `registered`. It is no longer possible to set |
287 | 288 | `is` in `beforeRegister` as you could in 1.x. |
288 | 289 | */ |
289 | | - if (this.behaviors) { |
290 | | - for (let i=0, b; i < this.behaviors.length; i++) { |
291 | | - b = this.behaviors[i]; |
| 290 | + const proto = Object.getPrototypeOf(this); |
| 291 | + _applyBehaviors(proto.behaviors, proto.constructor); |
| 292 | + copyProperties(info, proto); |
| 293 | + if (proto.behaviors) { |
| 294 | + for (let i=0, b; i < proto.behaviors.length; i++) { |
| 295 | + b = proto.behaviors[i]; |
292 | 296 | if (b.beforeRegister) { |
293 | | - b.beforeRegister.call(Object.getPrototypeOf(this)); |
| 297 | + b.beforeRegister.call(proto); |
294 | 298 | } |
295 | 299 | if (b.registered) { |
296 | | - b.registered.call(Object.getPrototypeOf(this)); |
| 300 | + b.registered.call(proto); |
297 | 301 | } |
298 | 302 | } |
299 | 303 | } |
300 | 304 | if (info.beforeRegister) { |
301 | | - info.beforeRegister.call(Object.getPrototypeOf(this)); |
| 305 | + info.beforeRegister.call(proto); |
302 | 306 | } |
303 | 307 | if (info.registered) { |
304 | | - info.registered.call(Object.getPrototypeOf(this)); |
| 308 | + info.registered.call(proto); |
305 | 309 | } |
306 | 310 | } |
307 | 311 |
|
|
428 | 432 |
|
429 | 433 | PolymerGenerated.generatedFrom = info; |
430 | 434 |
|
431 | | - copyProperties(info, PolymerGenerated.prototype); |
| 435 | + // copyProperties(info, PolymerGenerated.prototype); |
432 | 436 |
|
433 | 437 | return PolymerGenerated; |
434 | 438 | } |
|
0 commit comments