Skip to content

Commit

Permalink
wip: Add alchemy-element-editor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdeyen committed Nov 29, 2023
1 parent 10ca3cc commit 76bb488
Show file tree
Hide file tree
Showing 2 changed files with 558 additions and 7 deletions.
16 changes: 9 additions & 7 deletions app/javascript/alchemy_admin/components/element_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { on } from "alchemy_admin/utils/events"
import { post } from "alchemy_admin/utils/ajax"
import { createHtmlElement } from "../utils/dom_helpers"

class ElementEditor extends HTMLElement {
export class ElementEditor extends HTMLElement {
constructor() {
super()
}
Expand Down Expand Up @@ -223,9 +223,11 @@ class ElementEditor extends HTMLElement {
* @param {boolean} scroll smoothly scroll element into view. Default (false)
*/
selectElement(scroll = false) {
document.querySelectorAll("alchemy-element-editor").forEach((el) => {
el.classList.remove("selected")
})
document
.querySelectorAll("alchemy-element-editor.selected")
.forEach((el) => {
el.classList.remove("selected")
})
window.requestAnimationFrame(() => {
this.classList.add("selected")
})
Expand Down Expand Up @@ -256,7 +258,7 @@ class ElementEditor extends HTMLElement {
*/
setClean() {
this.dirty = false
window.onbeforeunload = () => {}
window.onbeforeunload = null
this.dispatchEvent(
new CustomEvent("alchemy:element-clean", { bubbles: true })
)
Expand Down Expand Up @@ -409,14 +411,14 @@ class ElementEditor extends HTMLElement {
* @returns {boolean}
*/
get compact() {
return !!this.getAttribute("compact")
return this.getAttribute("compact") !== null
}

/**
* @returns {boolean}
*/
get fixed() {
return !!this.getAttribute("fixed")
return this.getAttribute("fixed") !== null
}

/**
Expand Down
Loading

0 comments on commit 76bb488

Please sign in to comment.