generated from lit/lit-element-starter-js
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_element.cljs
More file actions
27 lines (21 loc) · 749 Bytes
/
my_element.cljs
File metadata and controls
27 lines (21 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(ns my-element
(:require [squint.core :refer [defclass js-template]]
["lit" :as lit]))
(defclass MyElement
(extends lit/LitElement)
(field name "World")
(field count 0)
(constructor [_]
(super))
Object
(render [this]
(js-template lit/html
"<h1>" (.-name this) "</h1>"
"<button @click=" (.-_onClick this) " part=\"button\">"
"Click Count: " count
"</button>"))
(_onClick [this]
(set! count (inc count))
(.dispatchEvent this (new js/CustomEvent "count-changed"))))
(set! (.-properties MyElement) #js {"count" #js {}})
(js/window.customElements.define "my-element" MyElement)