Skip to content

Commit b7ed99f

Browse files
authored
fix: postpone registration until first instance is created (#11354)
* fix: postpone registtration until first instance is created * chore: remove protected finalize method from typings * test: ensure registrations is empty before element is created
1 parent 0089e08 commit b7ed99f

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

packages/component-base/src/element-mixin.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,4 @@ export declare function ElementMixin<T extends Constructor<HTMLElement>>(
1818
export declare class ElementMixinClass {
1919
static is: string;
2020
static version: string;
21-
22-
protected static finalize(): void;
2321
}

packages/component-base/src/element-mixin.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ const registered = new Set();
3838
export const ElementMixin = (superClass) =>
3939
class VaadinElementMixin extends DirMixin(superClass) {
4040
/** @protected */
41-
static finalize() {
42-
super.finalize();
43-
41+
static _ensureRegistrations() {
4442
const { is } = this;
4543

4644
// Registers a class prototype for telemetry purposes.
@@ -66,5 +64,7 @@ export const ElementMixin = (superClass) =>
6664
'Vaadin components require the "standards mode" declaration. Please add <!DOCTYPE html> to the HTML document.',
6765
);
6866
}
67+
68+
this.constructor._ensureRegistrations();
6969
}
7070
};

packages/component-base/test/element-mixin.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ describe('ElementMixin', () => {
4040

4141
before(() => {
4242
ElementFoo = defineCE('element-foo');
43+
flush();
4344
});
4445

4546
it('should store the class entry in registrations once instance created', () => {
47+
expect(window.Vaadin.registrations.length).to.equal(0);
4648
document.createElement(ElementFoo.is);
4749
flush();
4850
expect(window.Vaadin.registrations).to.be.instanceOf(Array);

0 commit comments

Comments
 (0)