|
205 | 205 | are controlled via the finalization mechanism provided by `Properties-Mixin`. |
206 | 206 |
|
207 | 207 | `Properties` and `observers` are collected by manually traversing the prototype |
208 | | - chain and merging. |
209 | | -
|
210 | | - The `_registered` method is called via `LegacyElementMixin._finalizeClass` |
211 | | - and is called on each prototype in the element's chain. Because a non-legacy |
212 | | - element may extend a legacy one, it's important that work in `_registered` |
213 | | - carefully act only once. |
| 208 | + chain and merging. The `_registered` method is called via |
| 209 | + `LegacyElementMixin._finalizeClass`. |
214 | 210 |
|
215 | 211 | */ |
216 | 212 | /** |
|
224 | 220 | function GenerateClassFromInfo(info, Base, behaviors) { |
225 | 221 |
|
226 | 222 | // manages behavior and lifecycle processing (filled in after class definition) |
227 | | - let registered = false; |
228 | 223 | let activeBehaviors; |
229 | 224 | const lifecycle = {}; |
230 | 225 |
|
|
285 | 280 | `is` in `beforeRegister` as you could in 1.x. |
286 | 281 | */ |
287 | 282 | const proto = this; |
288 | | - // NOTE: this `registered` flag is required so that extensions |
289 | | - // that do not override `_registered` do not try to "re-register" |
290 | | - // this data. Only extensions that use `mixinBehaviors` will normally |
291 | | - // have this implementation. |
292 | | - if (!registered) { |
293 | | - registered = true; |
294 | | - if (activeBehaviors) { |
295 | | - copyAndFilterBehaviors(proto, activeBehaviors, lifecycle); |
296 | | - } |
297 | | - copyAndFilterProperties(proto, info, lifecycle); |
298 | | - let list = lifecycle.beforeRegister; |
299 | | - if (list) { |
300 | | - for (let i=0; i < list.length; i++) { |
301 | | - list[i].call(proto); |
302 | | - } |
| 283 | + if (activeBehaviors) { |
| 284 | + copyAndFilterBehaviors(proto, activeBehaviors, lifecycle); |
| 285 | + } |
| 286 | + copyAndFilterProperties(proto, info, lifecycle); |
| 287 | + let list = lifecycle.beforeRegister; |
| 288 | + if (list) { |
| 289 | + for (let i=0; i < list.length; i++) { |
| 290 | + list[i].call(proto); |
303 | 291 | } |
304 | | - list = lifecycle.registered; |
305 | | - if (list) { |
306 | | - for (let i=0; i < list.length; i++) { |
307 | | - list[i].call(proto); |
308 | | - } |
| 292 | + } |
| 293 | + list = lifecycle.registered; |
| 294 | + if (list) { |
| 295 | + for (let i=0; i < list.length; i++) { |
| 296 | + list[i].call(proto); |
309 | 297 | } |
310 | 298 | } |
311 | 299 | } |
|
0 commit comments