Skip to content

Commit

Permalink
refactor: simplify reflected attribute accesses
Browse files Browse the repository at this point in the history
  • Loading branch information
maxpatiiuk committed Sep 19, 2024
1 parent 6f42a86 commit 7b44dd4
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export class Button
<InteractiveContainer disabled={this.disabled}>
<Tag
aria-disabled={childElType === "a" ? toAriaBoolean(this.disabled || this.loading) : null}
aria-expanded={this.el.getAttribute("aria-expanded")}
aria-expanded={this.el.ariaExpanded}
aria-label={!this.loading ? getLabelText(this) : this.messages.loading}
aria-live="polite"
class={{
Expand Down
7 changes: 0 additions & 7 deletions packages/calcite-components/src/components/dialog/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ export class Dialog
[CSS.containerOpen]: opened,
[CSS.containerEmbedded]: this.embedded,
}}
ref={this.setContainerEl}
>
{this.modal ? (
<calcite-scrim class={CSS.scrim} onClick={this.handleOutsideClose} />
Expand Down Expand Up @@ -364,8 +363,6 @@ export class Dialog

transitionEl: HTMLDivElement;

containerEl: HTMLDivElement;

focusTrap: FocusTrap;

private resizePosition: DialogResizePosition = { ...initialResizePosition };
Expand Down Expand Up @@ -764,10 +761,6 @@ export class Dialog
}
}

private setContainerEl = (el: HTMLDivElement): void => {
this.containerEl = el;
};

private setTransitionEl = (el: HTMLDivElement): void => {
this.transitionEl = el;
this.setupInteractions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -774,9 +774,9 @@ export class InputDatePicker

@State() private localeData: DateLocaleData;

private startInput: HTMLCalciteInputElement;
private startInput: HTMLCalciteInputTextElement;

private endInput: HTMLCalciteInputElement;
private endInput: HTMLCalciteInputTextElement;

private floatingEl: HTMLDivElement;

Expand Down Expand Up @@ -884,11 +884,11 @@ export class InputDatePicker
syncHiddenFormInput("date", this, input);
}

setStartInput = (el: HTMLCalciteInputElement): void => {
setStartInput = (el: HTMLCalciteInputTextElement): void => {
this.startInput = el;
};

setEndInput = (el: HTMLCalciteInputElement): void => {
setEndInput = (el: HTMLCalciteInputTextElement): void => {
this.endInput = el;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1095,8 +1095,8 @@ export class InputNumber
autofocus={this.el.autofocus ? true : null}
defaultValue={this.defaultValue}
disabled={this.disabled ? true : null}
enterKeyHint={this.el.enterKeyHint || this.el.getAttribute("enterkeyhint")}
inputMode={this.el.inputMode || this.el.getAttribute("inputmode") || "decimal"}
enterKeyHint={this.el.enterKeyHint}
inputMode={this.el.inputMode || "decimal"}
key="localized-input"
maxLength={this.maxLength}
minLength={this.minLength}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,8 @@ export class InputText
}}
defaultValue={this.defaultValue}
disabled={this.disabled ? true : null}
enterKeyHint={this.el.enterKeyHint || this.el.getAttribute("enterkeyhint")}
inputMode={this.el.inputMode || this.el.getAttribute("inputmode")}
enterKeyHint={this.el.enterKeyHint}
inputMode={this.el.inputMode}
maxLength={this.maxLength}
minLength={this.minLength}
name={this.name}
Expand Down
6 changes: 3 additions & 3 deletions packages/calcite-components/src/components/input/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1171,9 +1171,9 @@ export class Input
const prefixText = <div class={CSS.prefix}>{this.prefixText}</div>;
const suffixText = <div class={CSS.suffix}>{this.suffixText}</div>;

const autofocus = this.el.autofocus || this.el.hasAttribute("autofocus") ? true : null;
const enterKeyHint = this.el.enterKeyHint || this.el.getAttribute("enterkeyhint");
const inputMode = this.el.inputMode || this.el.getAttribute("inputmode");
const autofocus = this.el.autofocus ? true : null;
const enterKeyHint = this.el.enterKeyHint;
const inputMode = this.el.inputMode;

const localeNumberInput =
this.type === "number" ? (
Expand Down
2 changes: 1 addition & 1 deletion packages/calcite-components/src/components/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export class CalciteMenu implements LocalizedComponent, T9nComponent, LoadableCo
}

private getEffectiveRole(): string {
return this.el.getAttribute("role") || "menubar";
return this.el.role || "menubar";
}

// --------------------------------------------------------------------------
Expand Down

0 comments on commit 7b44dd4

Please sign in to comment.