Skip to content

Commit

Permalink
Address review feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Orvell committed Oct 22, 2022
1 parent 49090db commit 2bd819e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/blue-olives-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lit/reactive-element': patch
---

Initializers added to subclasses are no longer improperly added to superclass.
8 changes: 4 additions & 4 deletions packages/reactive-element/src/reactive-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,7 @@ export abstract class ReactiveElement
*/
static addInitializer(initializer: Initializer) {
this.finalize();
this._initializers ??= [];
this._initializers!.push(initializer);
(this._initializers ??= []).push(initializer);
}

static _initializers?: Initializer[];
Expand Down Expand Up @@ -764,8 +763,9 @@ export abstract class ReactiveElement
const superCtor = Object.getPrototypeOf(this) as typeof ReactiveElement;
superCtor.finalize();
// Create own set of initializers for this class if any exist on the
// superclass and copy them down.
if (superCtor._initializers) {
// superclass and copy them down. Note, for a small perf boost, avoid
// creating initializers unless needed.
if (superCtor._initializers !== undefined) {
this._initializers = [...superCtor._initializers];
}
this.elementProperties = new Map(superCtor.elementProperties);
Expand Down

0 comments on commit 2bd819e

Please sign in to comment.