Add unicorn lint rules - DOM built-in functions (#628)

- Prefer append(), remove(), replaceAll()
- Wrap nested ternaries in parenthesis
This commit is contained in:
filtered
2025-02-27 20:18:25 +11:00
committed by GitHub
parent 6f51767451
commit 1e8938ceff
11 changed files with 60 additions and 56 deletions

View File

@@ -122,7 +122,7 @@ export class ContextMenu {
const element = document.createElement("div")
element.className = "litemenu-title"
element.innerHTML = options.title
root.appendChild(element)
root.append(element)
}
// entries
@@ -132,7 +132,7 @@ export class ContextMenu {
if (typeof name !== "string") {
name = name != null
? name.content === undefined ? String(name) : name.content
? (name.content === undefined ? String(name) : name.content)
: name
}
@@ -151,9 +151,9 @@ export class ContextMenu {
const root_document = ownerDocument || document
if (root_document.fullscreenElement)
root_document.fullscreenElement.appendChild(root)
root_document.fullscreenElement.append(root)
else
root_document.body.appendChild(root)
root_document.body.append(root)
// compute best position
let left = options.left || 0
@@ -231,7 +231,7 @@ export class ContextMenu {
}
}
this.root.appendChild(element)
this.root.append(element)
if (!disabled) element.addEventListener("click", inner_onclick)
if (!disabled && options.autoopen)
element.addEventListener("pointerenter", inner_over)