Skip to content

Commit

Permalink
fix: review
Browse files Browse the repository at this point in the history
  • Loading branch information
kyubisation committed Dec 12, 2023
1 parent 7ebb615 commit 67a9c2e
Show file tree
Hide file tree
Showing 15 changed files with 15 additions and 28 deletions.
2 changes: 1 addition & 1 deletion CODING_STANDARDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ event and re-render the view. This can be done by marking the field with `@state
import { LanguageController } from '../core/common-behaviors';

export class Component extends LitElement {
private _language = new LanguageController(this /*, this._abort */);
private _language = new LanguageController(this);

protected override render(): TemplateResult {
return html` ... ${i18nExample[this._language.current]} ... `;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class SbbBreadcrumbGroupElement extends SlotChildObserver(LitElement) {

private _resizeObserver = new AgnosticResizeObserver(() => this._evaluateCollapsedState());
private _abort = new ConnectedAbortController(this);
private _language = new LanguageController(this, this._abort);
private _language = new LanguageController(this);
private _markForFocus = false;

private _handleKeyDown(evt: KeyboardEvent): void {
Expand Down
2 changes: 1 addition & 1 deletion src/components/checkbox/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class SbbCheckboxElement extends LitElement {
private _checkbox: HTMLInputElement;
private _selectionPanelElement: HTMLElement;
private _abort: ConnectedAbortController = new ConnectedAbortController(this);
private _language = new LanguageController(this, this._abort);
private _language = new LanguageController(this);

/**
* @deprecated only used for React. Will probably be removed once React 19 is available.
Expand Down
9 changes: 1 addition & 8 deletions src/components/core/common-behaviors/language-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ReactiveController, ReactiveControllerHost } from 'lit';

import { readConfig } from '../config';
import { isBrowser } from '../dom';
import { ConnectedAbortController } from '../eventing';
import { AgnosticMutationObserver } from '../observers';

/**
Expand Down Expand Up @@ -55,13 +54,7 @@ export class LanguageController implements ReactiveController {
private _previousLanguage: string;
private _handlers: (() => void)[] = [];

public constructor(
private _host: ReactiveControllerHost,
private _abortController?: ConnectedAbortController,
) {
if (!this._abortController) {
this._abortController = new ConnectedAbortController(this._host);
}
public constructor(private _host: ReactiveControllerHost) {
this._host.addController(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ export class SbbDatepickerNextDayElement extends LitElement implements ButtonPro
private _datePickerController: AbortController;

private _abort = new ConnectedAbortController(this);
private _language = new LanguageController(this, this._abort).withHandler(() =>
this._setAriaLabel(),
);
private _language = new LanguageController(this).withHandler(() => this._setAriaLabel());

private _handleClick(): void {
if (!this._datePickerElement || isValidAttribute(this, 'data-disabled')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ export class SbbDatepickerPreviousDayElement extends LitElement implements Butto
private _datePickerController: AbortController;

private _abort = new ConnectedAbortController(this);
private _language = new LanguageController(this, this._abort).withHandler(() =>
this._setAriaLabel(),
);
private _language = new LanguageController(this).withHandler(() => this._setAriaLabel());

private _handleClick(): void {
if (!this._datePickerElement || isValidAttribute(this, 'data-disabled')) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/datepicker/datepicker/datepicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export class SbbDatepickerElement extends LitElement {
readConfig().datetime?.dateAdapter ?? defaultDateAdapter;

private _abort = new ConnectedAbortController(this);
private _language = new LanguageController(this, this._abort).withHandler(() => {
private _language = new LanguageController(this).withHandler(() => {
if (this._inputElement) {
this._inputElement.placeholder = i18nDatePickerPlaceholder[this._language.current];
const valueAsDate = this.getValueAsDate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class SbbFormFieldClearElement extends LitElement {
private _handlerRepository = new HandlerRepository(this, actionElementHandlerAspect);
private _formField: SbbFormFieldElement;
private _abort = new ConnectedAbortController(this);
private _language = new LanguageController(this, this._abort);
private _language = new LanguageController(this);

public override connectedCallback(): void {
super.connectedCallback();
Expand Down
2 changes: 1 addition & 1 deletion src/components/form-field/form-field/form-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class SbbFormFieldElement extends LitElement {
}

private _abort = new ConnectedAbortController(this);
private _language = new LanguageController(this, this._abort);
private _language = new LanguageController(this);
private _handlerRepository = new HandlerRepository(
this,
namedSlotChangeHandlerAspect((m) => (this._namedSlots = m(this._namedSlots))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class SbbNavigationActionElement extends LitElement {

private _navigationMarker: SbbNavigationMarkerElement;
private _abort = new ConnectedAbortController(this);
private _language = new LanguageController(this, this._abort);
private _language = new LanguageController(this);

private _handlerRepository = new HandlerRepository(this, actionElementHandlerAspect);

Expand Down
2 changes: 1 addition & 1 deletion src/components/navigation/navigation/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class SbbNavigationElement extends UpdateScheduler(LitElement) {
private _navigationController: AbortController;
private _windowEventsController: AbortController;
private _abort = new ConnectedAbortController(this);
private _language = new LanguageController(this, this._abort);
private _language = new LanguageController(this);
private _focusTrap = new FocusTrap();
private _scrollHandler = new ScrollHandler();
private _isPointerDownEventOnNavigation: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/components/radio-button/radio-button/radio-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class SbbRadioButtonElement extends LitElement {

private _selectionPanelElement: HTMLElement;
private _abort = new ConnectedAbortController(this);
private _language = new LanguageController(this, this._abort);
private _language = new LanguageController(this);

/**
* @internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ export class SbbTimetableOccupancyIconElement extends SbbIconBase {
@property({ reflect: true, type: Boolean }) public negative: boolean = false;

private _abort = new ConnectedAbortController(this);
private _language = new LanguageController(this, this._abort).withHandler(() =>
this._setAriaLabel(),
);
private _language = new LanguageController(this).withHandler(() => this._setAriaLabel());

private async _setNameAndAriaLabel(): Promise<void> {
if (!this.occupancy) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/toast/toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class SbbToastElement extends LitElement {

private _closeTimeout: ReturnType<typeof setTimeout>;
private _abort = new ConnectedAbortController(this);
private _language = new LanguageController(this, this._abort);
private _language = new LanguageController(this);

/**
* Role of the live region. This is only for Firefox as there is a known issue where Firefox +
Expand Down
2 changes: 1 addition & 1 deletion src/components/train/train-formation/train-formation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class SbbTrainFormationElement extends SlotChildObserver(LitElement) {
private _formationDiv: HTMLDivElement;
private _contentResizeObserver = new AgnosticResizeObserver(() => this._applyCssWidth());
private _abort = new ConnectedAbortController(this);
private _language = new LanguageController(this, this._abort);
private _language = new LanguageController(this);

public override connectedCallback(): void {
super.connectedCallback();
Expand Down

0 comments on commit 67a9c2e

Please sign in to comment.