mirror of
https://github.com/google/blockly.git
synced 2025-12-16 14:20:10 +01:00
* feat!: Added support for separators in menus. * chore: Do English gooder. * fix: Remove menu separators from the DOM during dispose.
39 lines
775 B
TypeScript
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;
|
|
}
|
|
}
|