Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 7fe0e4f

Browse files
Shi Shucopybara-github
authored andcommitted
refactor(tooltip): Refactor tooltipContainsElement to use this.root instead of this.tooltipElem.
PiperOrigin-RevId: 347008382
1 parent ac41a57 commit 7fe0e4f

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

packages/mdc-tooltip/component.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export class MDCTooltip extends MDCComponent<MDCTooltipFoundation> {
3434
}
3535

3636
private anchorElem!: HTMLElement; // assigned in initialize
37-
private tooltipElem!: HTMLElement|null; // assigned in initialize
3837
private isTooltipRich!: boolean; // assigned in initialSyncWithDOM
3938
private isTooltipPersistent!: boolean; // assigned in initialSyncWithDOM
4039

@@ -54,7 +53,6 @@ export class MDCTooltip extends MDCComponent<MDCTooltipFoundation> {
5453
const anchorElem = document.querySelector<HTMLElement>(
5554
`[aria-describedby="${tooltipId}"]`) ||
5655
document.querySelector<HTMLElement>(`[data-tooltip-id="${tooltipId}"]`);
57-
this.tooltipElem = document.querySelector<HTMLElement>(`#${tooltipId}`);
5856
if (!anchorElem) {
5957
throw new Error(
6058
'MDCTooltip: Tooltip component requires an anchor element annotated with [aria-describedby] or [data-tooltip-id] anchor element.');
@@ -167,7 +165,7 @@ export class MDCTooltip extends MDCComponent<MDCTooltipFoundation> {
167165
return !!this.anchorElem?.contains(element);
168166
},
169167
tooltipContainsElement: (element) => {
170-
return !!this.tooltipElem?.contains(element);
168+
return this.root.contains(element);
171169
},
172170
registerEventHandler: (evt, handler) => {
173171
if (this.root instanceof HTMLElement) {

0 commit comments

Comments
 (0)