mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-12 12:04: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
|
// if not found, use default context
|
||||||
const parentElement = element.closest("[context-menu]")
|
const parentElement = element.closest("[context-menu]")
|
||||||
|
|
||||||
|
let contexts = []
|
||||||
|
|
||||||
if (parentElement) {
|
if (parentElement) {
|
||||||
let contexts = parentElement.getAttribute("context-menu") ?? []
|
contexts = parentElement.getAttribute("context-menu") ?? []
|
||||||
|
|
||||||
if (typeof contexts === "string") {
|
if (typeof contexts === "string") {
|
||||||
contexts = contexts.split(",").map((context) => context.trim())
|
contexts = contexts.split(",").map((context) => context.trim())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if context includes ignore, return null
|
// if context includes ignore, return null
|
||||||
if (contexts.includes("ignore")) {
|
if (contexts.includes("ignore")) {
|
||||||
@ -74,7 +77,6 @@ export default class ContextMenuCore extends Core {
|
|||||||
items.push(contextObject)
|
items.push(contextObject)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// fullfill each item with a correspondent index if missing declared
|
// fullfill each item with a correspondent index if missing declared
|
||||||
items = items.map((item, index) => {
|
items = items.map((item, index) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user