Skip to content

Commit

Permalink
fix: make setupTooltip a private method
Browse files Browse the repository at this point in the history
  • Loading branch information
luwes committed Sep 26, 2024
1 parent dbdec7e commit aea5b42
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/js/media-chrome-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,19 @@ class MediaChromeButton extends globalThis.HTMLElement {

globalThis.customElements
.whenDefined('media-tooltip')
.then(this.setupTooltip.bind(this));
.then(this.#setupTooltip.bind(this));
}

// Called when we know the tooltip is ready / defined
#setupTooltip() {
this.addEventListener('mouseenter', this.#positionTooltip);
this.addEventListener('focus', this.#positionTooltip);
this.addEventListener('click', this.#clickListener);

const initialPlacement = this.tooltipPlacement;
if (initialPlacement && this.tooltipEl) {
this.tooltipEl.placement = initialPlacement;
}

Check warning on line 300 in src/js/media-chrome-button.ts

View check run for this annotation

Codecov / codecov/patch

src/js/media-chrome-button.ts#L299-L300

Added lines #L299 - L300 were not covered by tests
}

disconnectedCallback() {
Expand Down Expand Up @@ -319,18 +331,6 @@ class MediaChromeButton extends globalThis.HTMLElement {
* @argument {Event} e
*/
handleClick(e) {} // eslint-disable-line

// Called when we know the tooltip is ready / defined
setupTooltip() {
this.addEventListener('mouseenter', this.#positionTooltip);
this.addEventListener('focus', this.#positionTooltip);
this.addEventListener('click', this.#clickListener);

const initialPlacement = this.tooltipPlacement;
if (initialPlacement && this.tooltipEl) {
this.tooltipEl.placement = initialPlacement;
}
}
}

if (!globalThis.customElements.get('media-chrome-button')) {
Expand Down

0 comments on commit aea5b42

Please sign in to comment.