Files
blockly/core/menu_separator.ts
Aaron Dodson fa4fce5c12 feat!: Added support for separators in menus. (#8767)
* feat!: Added support for separators in menus.

* chore: Do English gooder.

* fix: Remove menu separators from the DOM during dispose.
2025-02-27 14:00:40 -08:00

39 lines
775 B
TypeScript

/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import * as aria from './utils/aria.js';
/**
* Representation of a section separator in a menu.
*/
export class MenuSeparator {
/**
* DOM element representing this separator in a menu.
*/
private element: HTMLHRElement | null = null;
/**
* Creates the DOM representation of this separator.
*
* @returns An <hr> element.
*/
createDom(): HTMLHRElement {
this.element = document.createElement('hr');
this.element.className = 'blocklyMenuSeparator';
aria.setRole(this.element, aria.Role.SEPARATOR);
return this.element;
}
/**
* Disposes of this separator.
*/
dispose() {
this.element?.remove();
this.element = null;
}
}