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: simplify reflected attribute accesses #10356

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

maxpatiiuk
Copy link
Member

@maxpatiiuk maxpatiiuk commented Sep 19, 2024

Minor refactor - some HTML attributes are reflected to properties.
Thus, we can access properties instead of calling getAttribute/hasAttribute.
Properties are also more type-safe (where as getAttribute string parameter does not have type-checking)

And other minor changes.

@github-actions github-actions bot added the refactor Issues tied to code that needs to be significantly reworked. label Sep 19, 2024
@@ -764,10 +761,6 @@ export class Dialog
}
}

private setContainerEl = (el: HTMLDivElement): void => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never read, thus removed

@@ -774,9 +774,9 @@ export class InputDatePicker

@State() private localeData: DateLocaleData;

private startInput: HTMLCalciteInputElement;
private startInput: HTMLCalciteInputTextElement;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was causing a type error in Lumina - the ref is assigned to calcite-input-text, but the type here was calcite-input.

packages/calcite-components/src/components/input/input.tsx Outdated Show resolved Hide resolved
@@ -146,8 +146,6 @@ export class Tooltip implements FloatingUIComponent, OpenCloseComponent {

guid = `calcite-tooltip-${guid()}`;

hasLoaded = false;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never read

@@ -228,7 +228,7 @@ export class CalciteMenu implements LocalizedComponent, T9nComponent, LoadableCo
}

private getEffectiveRole(): string {
return this.el.getAttribute("role") || "menubar";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

equivalent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Issues tied to code that needs to be significantly reworked.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant