remove unused controller

This commit is contained in:
Cory LaViska
2024-03-21 15:10:16 -04:00
parent 252d710175
commit cf9044d826
2 changed files with 11 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
import { classMap } from 'lit/directives/class-map.js';
import { getTextContent, HasSlotController } from '../../internal/slot.js';
import { getTextContent } from '../../internal/slot.js';
import { html } from 'lit';
import { LocalizeController } from '../../utilities/localize.js';
import { property, query } from 'lit/decorators.js';
@@ -67,8 +67,7 @@ export default class WaMenuItem extends WebAwesomeElement {
@property({ type: Boolean, reflect: true }) disabled = false;
private readonly localize = new LocalizeController(this);
private readonly hasSlotController = new HasSlotController(this, 'submenu');
private submenuController: SubmenuController = new SubmenuController(this, this.hasSlotController, this.localize);
private submenuController: SubmenuController = new SubmenuController(this, this.localize);
connectedCallback() {
super.connectedCallback();
@@ -150,7 +149,7 @@ export default class WaMenuItem extends WebAwesomeElement {
}
isSubmenu() {
return this.hasSlotController.test('submenu');
return this.querySelector(`:scope > [slot="submenu"]`) !== null;
}
render() {

View File

@@ -1,5 +1,4 @@
import { createRef, ref, type Ref } from 'lit/directives/ref.js';
import { type HasSlotController } from '../../internal/slot.js';
import { html } from 'lit';
import { type LocalizeController } from '../../utilities/localize.js';
import type { ReactiveController, ReactiveControllerHost } from 'lit';
@@ -14,22 +13,20 @@ export class SubmenuController implements ReactiveController {
private isConnected = false;
private isPopupConnected = false;
private skidding = 0;
private readonly hasSlotController: HasSlotController;
private readonly localize: LocalizeController;
private readonly submenuOpenDelay = 100;
constructor(
host: ReactiveControllerHost & WaMenuItem,
hasSlotController: HasSlotController,
localize: LocalizeController
) {
constructor(host: ReactiveControllerHost & WaMenuItem, localize: LocalizeController) {
(this.host = host).addController(this);
this.hasSlotController = hasSlotController;
this.localize = localize;
}
private hasSubmenu() {
return this.host.querySelector(`:scope > [slot="submenu"]`) !== null;
}
hostConnected() {
if (this.hasSlotController.test('submenu') && !this.host.disabled) {
if (this.hasSubmenu() && !this.host.disabled) {
this.addListeners();
}
}
@@ -39,7 +36,7 @@ export class SubmenuController implements ReactiveController {
}
hostUpdated() {
if (this.hasSlotController.test('submenu') && !this.host.disabled) {
if (this.hasSubmenu() && !this.host.disabled) {
this.addListeners();
this.updateSkidding();
} else {
@@ -93,7 +90,7 @@ export class SubmenuController implements ReactiveController {
};
private handleMouseOver = () => {
if (this.hasSlotController.test('submenu')) {
if (this.hasSubmenu()) {
this.enableSubmenu();
}
};