Skip to content

Commit 7e16d6c

Browse files
asynclizcopybara-github
authored andcommitted
fix(tabs): change indicator symbol to method
This is needed for the TS es2022 upgrade. PiperOrigin-RevId: 776253988
1 parent bfd9cdf commit 7e16d6c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

tabs/internal/tab.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {mixinFocusable} from '../../labs/behaviors/focusable.js';
2525
* Symbol for tabs to use to animate their indicators based off another tab's
2626
* indicator.
2727
*/
28-
const INDICATOR = Symbol('indicator');
28+
const GET_INDICATOR = Symbol('indicator');
2929

3030
/**
3131
* Symbol used by the tab bar to request a tab to animate its indicator from a
@@ -74,7 +74,7 @@ export class Tab extends tabBaseClass {
7474
*/
7575
@property({type: Boolean, attribute: 'icon-only'}) iconOnly = false;
7676

77-
@query('.indicator') readonly [INDICATOR]!: HTMLElement | null;
77+
@query('.indicator') private readonly indicator!: HTMLElement | null;
7878
@state() protected fullWidthIndicator = false;
7979
@queryAssignedNodes({flatten: true})
8080
private readonly assignedDefaultNodes!: Node[];
@@ -144,17 +144,21 @@ export class Tab extends tabBaseClass {
144144
this.click();
145145
}
146146

147+
[GET_INDICATOR](): HTMLElement | null {
148+
return this.indicator;
149+
}
150+
147151
[ANIMATE_INDICATOR](previousTab: Tab) {
148-
if (!this[INDICATOR]) {
152+
if (!this.indicator) {
149153
return;
150154
}
151155

152-
this[INDICATOR].getAnimations().forEach((a) => {
156+
this.indicator.getAnimations().forEach((a) => {
153157
a.cancel();
154158
});
155159
const frames = this.getKeyframes(previousTab);
156160
if (frames !== null) {
157-
this[INDICATOR].animate(frames, {
161+
this.indicator.animate(frames, {
158162
duration: 250,
159163
easing: EASING.EMPHASIZED,
160164
});
@@ -169,10 +173,10 @@ export class Tab extends tabBaseClass {
169173

170174
const from: Keyframe = {};
171175
const fromRect =
172-
previousTab[INDICATOR]?.getBoundingClientRect() ?? ({} as DOMRect);
176+
previousTab[GET_INDICATOR]()?.getBoundingClientRect() ?? ({} as DOMRect);
173177
const fromPos = fromRect.left;
174178
const fromExtent = fromRect.width;
175-
const toRect = this[INDICATOR]!.getBoundingClientRect();
179+
const toRect = this.indicator!.getBoundingClientRect();
176180
const toPos = toRect.left;
177181
const toExtent = toRect.width;
178182
const scale = fromExtent / toExtent;

0 commit comments

Comments
 (0)