Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove async modifier from willUpdate #3223

Merged
merged 4 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/elements/checkbox/checkbox-panel/checkbox-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class SbbCheckboxPanelElement extends SbbPanelMixin(
{ bubbles: true },
);

protected override async willUpdate(changedProperties: PropertyValues<this>): Promise<void> {
protected override willUpdate(changedProperties: PropertyValues<this>): void {
super.willUpdate(changedProperties);

if (changedProperties.has('checked')) {
Expand Down
2 changes: 1 addition & 1 deletion src/elements/checkbox/common/checkbox-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const SbbCheckboxCommonElementMixin = <T extends Constructor<LitElement>>
['disabled', 'required', 'size'].forEach((p) => this.requestUpdate(p));
}

protected override async willUpdate(changedProperties: PropertyValues<this>): Promise<void> {
protected override willUpdate(changedProperties: PropertyValues<this>): void {
super.willUpdate(changedProperties);

if (changedProperties.has('checked') || changedProperties.has('indeterminate')) {
Expand Down
4 changes: 2 additions & 2 deletions src/elements/clock/clock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ class SbbClockElement extends LitElement {
/** Callback function for minutes hand. */
private _moveMinutesHandFn = (): void => this._moveMinutesHand();

protected override async willUpdate(changedProperties: PropertyValues<this>): Promise<void> {
protected override willUpdate(changedProperties: PropertyValues<this>): void {
super.willUpdate(changedProperties);

if (!isServer && changedProperties.has('now')) {
await this._startOrConfigureClock();
this._startOrConfigureClock();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/elements/core/mixins/required-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const SbbRequiredMixin = <
}
private _required: boolean = false;

protected override async willUpdate(changedProperties: PropertyValues<this>): Promise<void> {
protected override willUpdate(changedProperties: PropertyValues<this>): void {
super.willUpdate(changedProperties);

if (changedProperties.has('required')) {
Expand Down
1 change: 0 additions & 1 deletion src/elements/datepicker/datepicker/datepicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ export function isDateAvailable<T = Date>(
min: string | number | null | undefined,
max: string | number | null | undefined,
): boolean {
// TODO: Get date adapter from config
const dateAdapter: DateAdapter<T> = readConfig().datetime?.dateAdapter ?? defaultDateAdapter;
const dateMin = dateAdapter.deserialize(min);
const dateMax = dateAdapter.deserialize(max);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ class SbbFlipCardSummaryElement extends LitElement {
@property({ attribute: 'image-alignment', reflect: true })
public accessor imageAlignment: SbbFlipCardImageAlignment = 'after';

protected override willUpdate(_changedProperties: PropertyValues): void {
super.willUpdate(_changedProperties);
protected override willUpdate(changedProperties: PropertyValues<this>): void {
super.willUpdate(changedProperties);

if (_changedProperties.has('imageAlignment')) {
if (changedProperties.has('imageAlignment')) {
this.closest?.('sbb-flip-card')?.setAttribute('data-image-alignment', this.imageAlignment);
}
}
Expand Down
10 changes: 2 additions & 8 deletions src/elements/icon/icon.snapshot.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { aTimeout, expect } from '@open-wc/testing';
import { expect } from '@open-wc/testing';
import { html } from 'lit/static-html.js';

import { mergeConfig, type SbbIconConfig } from '../core/config.js';
import { readConfig } from '../core/config.js';
import { mergeConfig, readConfig, type SbbIconConfig } from '../core/config.js';
import { fixture, testA11yTreeSnapshot } from '../core/testing/private.js';
import { waitForLitRender } from '../core/testing.js';

Expand Down Expand Up @@ -107,11 +106,6 @@ describe(`sbb-icon`, () => {
`);

icon.setAttribute('name', 'pie-medium');
// TODO: Optimize with https://lit.dev/docs/elements/lifecycle/#getUpdateComplete
// The update of the internal state happens a tick after the updateComplete down below completes.
// We could change this by implementing a getUpdateComplete which starts with a name change
// and completes with the new icon loaded.
await aTimeout(0);
await waitForLitRender(icon);

expect(icon).dom.to.be.equal(`
Expand Down
2 changes: 1 addition & 1 deletion src/elements/icon/icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { forceType, omitEmptyConverter } from '../core/decorators.js';
import { SbbIconBase } from './icon-base.js';

/**
* It displays an icon loaded from a registered namespace.
* Displays an icon loaded from a registered namespace.
*/
export
@customElement('sbb-icon')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class SbbRadioButtonPanelElement extends SbbPanelMixin(
this._hasSelectionExpansionPanelElement = !!this.closest?.('sbb-selection-expansion-panel');
}

protected override async willUpdate(changedProperties: PropertyValues<this>): Promise<void> {
protected override willUpdate(changedProperties: PropertyValues<this>): void {
super.willUpdate(changedProperties);

if (changedProperties.has('checked')) {
Expand Down
2 changes: 1 addition & 1 deletion src/elements/table/table-wrapper/table-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SbbTableWrapperElement extends SbbNegativeMixin(LitElement) {
});
private _tableWrapper!: HTMLElement;

protected override firstUpdated(changedProperties: PropertyValues): void {
protected override firstUpdated(changedProperties: PropertyValues<this>): void {
super.firstUpdated(changedProperties);
this._tableWrapper = this.shadowRoot!.querySelector<HTMLElement>('.sbb-table-wrapper')!;
this._resizeObserver.observe(this._tableWrapper);
Expand Down
2 changes: 1 addition & 1 deletion src/elements/toggle-check/toggle-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SbbToggleCheckElement extends SbbFormAssociatedCheckboxMixin(SbbIconNameMi
@property({ attribute: 'label-position', reflect: true })
public accessor labelPosition: 'before' | 'after' = 'after';

protected override async willUpdate(changedProperties: PropertyValues<this>): Promise<void> {
protected override willUpdate(changedProperties: PropertyValues<this>): void {
super.willUpdate(changedProperties);

if (changedProperties.has('checked')) {
Expand Down
Loading