mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-11 03:24:16 +00:00
improve empty parentElement
behavior
This commit is contained in:
parent
7a41913207
commit
685af011c1
@ -33,12 +33,15 @@ export default class ContextMenuCore extends Core {
|
||||
// if not found, use default context
|
||||
const parentElement = element.closest("[context-menu]")
|
||||
|
||||
let contexts = []
|
||||
|
||||
if (parentElement) {
|
||||
let contexts = parentElement.getAttribute("context-menu") ?? []
|
||||
contexts = parentElement.getAttribute("context-menu") ?? []
|
||||
|
||||
if (typeof contexts === "string") {
|
||||
contexts = contexts.split(",").map((context) => context.trim())
|
||||
}
|
||||
}
|
||||
|
||||
// if context includes ignore, return null
|
||||
if (contexts.includes("ignore")) {
|
||||
@ -74,7 +77,6 @@ export default class ContextMenuCore extends Core {
|
||||
items.push(contextObject)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fullfill each item with a correspondent index if missing declared
|
||||
items = items.map((item, index) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user