handle undefined correctly in attrs

This commit is contained in:
Nariman Jelveh 2024-06-24 18:26:38 -07:00
parent d1b310e59c
commit 07120e3ca4

View File

@ -351,13 +351,14 @@ function UIContextMenu(options){
const menu_id = window.global_element_id++;
let h = '';
console.log(options.parent_id)
h += H`<div
id="context-menu-${menu_id}"
data-is-submenu="${options.is_submenu ? 'true' : 'false'}"
data-element-id="${menu_id}"
data-id="${options.id ?? ''}"
${options.parent_id ? `data-parent-id="${options.parent_id}"` : ``}
${!options.parent_id && options.parent_element ? `data-parent-id="${$(options.parent_element).attr('data-element-id')}"` : ``}
${!options.parent_id && $(options.parent_element).attr('data-element-id') !== undefined ? `data-parent-id="${$(options.parent_element).attr('data-element-id')}"` : ``}
class="context-menu context-menu-active ${options.is_submenu ? 'context-menu-submenu-open' : ''}"
>`;