Make the ID publicly readonly, privately writable

This commit is contained in:
Oliver-Akins 2025-04-05 15:32:31 -06:00
parent bfddf855a4
commit 228cc21de7

View file

@ -3,7 +3,11 @@ import { Logger } from "./Logger.mjs";
export class PopoverEventManager { export class PopoverEventManager {
#options; #options;
id; #id;
get id() {
return this.#id;
};
/** @type {Map<string, PopoverEventManager>} */ /** @type {Map<string, PopoverEventManager>} */
static #existing = new Map(); static #existing = new Map();
@ -14,7 +18,7 @@ export class PopoverEventManager {
*/ */
constructor(id, element, popoverClass, options = {}) { constructor(id, element, popoverClass, options = {}) {
id = `${id}-${popoverClass.name}`; id = `${id}-${popoverClass.name}`;
this.id = id; this.#id = id;
if (PopoverEventManager.#existing.has(id)) { if (PopoverEventManager.#existing.has(id)) {
const manager = PopoverEventManager.#existing.get(id); const manager = PopoverEventManager.#existing.get(id);
@ -101,7 +105,7 @@ export class PopoverEventManager {
#construct(options) { #construct(options) {
options.popover ??= {}; options.popover ??= {};
options.popover.managerId = this.id; options.popover.managerId = this.#id;
return new this.#class(options); return new this.#class(options);
}; };