std.dom.common

*current-dom*

dynamic

*dom-event*

*dom-handler*

dynamic

*local-dom*

dynamic

children->props

added in 3.0

(children->props children tag)

converts children array to props

(children->props “hello” :mock/label) => {:text “hello”}

(children->props “hello” :mock/pane) => {:children “hello”}

component?

added in 3.0

(component? dom)

checks if metatype is of :dom/component

(component? (dom-new :mock/label {})) => false

dom-assert

added in 3.0

(dom-assert props keys)

asserts that the props are valid (dom-assert {:a 1 :b 2} :a)

(dom-assert {:a 1 :b 2} :c) => (throws)

dom-attach

added in 3.0

(dom-attach dom handler)

attaches a handler to a dom node

(-> (dom-attach (dom-create :mock/label) (fn dom event event)) :handler) => fn?

dom-children

added in 3.0

(dom-children {:keys [tag props], :as dom})

retrieves children of dom object

(dom-children (dom-create :mock/pane {} “hello”)) => {:key :children :children “hello”}

dom-clone

added in 3.0

(dom-clone dom)

creates shallow copy of a node and its data

(def -a- (dom-create :mock/label)) (def -b- (dom-clone -a-))

(= -a- -b-) => false (dom-equal? -a- -b-) => true

dom-compile

added in 3.0

(dom-compile form)(dom-compile [tag props? & children :as form] create-fn)

compiles a tree structure into a dom

(-> (dom-compile :mock/pane “hello”) dom-format) => :- :mock/pane “hello”

(-> (dom-compile [:mock/pane :mock/label “hello” :mock/label “world”]) dom-format) => [:- :mock/pane :- :mock/label “hello” :- :mock/label “world”]

dom-create

added in 3.0

(dom-create tag)(dom-create tag props)(dom-create tag props children)

creates an dom

(dom-create :mock/pane {} “hello”) ;; :- :label “hello” => dom?

dom-detach

added in 3.0

(dom-detach dom)

detaches a handler from a dom node

(-> (dom-attach (dom-create :mock/label) (fn dom event event)) (dom-detach) :handler) => nil

dom-equal?

added in 3.0

(dom-equal? obj-a obj-b)

checks if two dom elements are equal

(dom-equal? (dom-create :mock/label {} “hello”) (dom-create :mock/label {} “hello”)) => true

dom-format

added in 3.0

(dom-format {:keys [tag props], :as dom})

formats dom for printing

(dom-format (dom-create :mock/label {} “hello”)) => :- :mock/label “hello”

dom-item

added in 3.0

(dom-item dom)

returns itement associated with the dom

(-> (dom-new :mock/label {:a 1}) (impl/dom-render) (dom-item)) => mock/mock?

(-> (dom-new :mock/label) (dom-item)) => nil

dom-item?

added in 3.0

(dom-item? dom)

returns whether dom has associated itement

(dom-item? (dom-new :mock/pane)) => false

(-> (dom-new :mock/pane) impl/dom-render dom-item?) => true

dom-metaclass

added in 3.0

(dom-metaclass dom)

returns the associated metaclass

(dom-metaclass (dom-new :mock/label {})) => :mock/element

dom-metaprops

added in 3.0

(dom-metaprops dom)

checks dom for ui type

(dom-metaprops (dom-new :mock/label {})) => (contains {:tag :mock/label :construct fn? :children {:key :text :single true} :metaclass :mock/element :metatype :dom/element})

dom-metatype

added in 3.0

(dom-metatype dom)

returns the associated metatype

(dom-metatype (dom-new :mock/label {})) => :dom/element

dom-new

added in 3.0

(dom-new)(dom-new obj)(dom-new tag props)(dom-new tag props item parent handler shadow cache extra)

creates a new dom type

(dom-new :mock/label {}) => dom?

dom-props-equal?

added in 3.0

(dom-props-equal? props-a props-b)

checks if two dome nodes have the same props

(dom-props-equal? {:a 1 :b 2} {:a 1 :b 2}) => true

dom-split-props

added in 3.0

(dom-split-props props)(dom-split-props props lookup select)

splits :on namespace keywords

(dom-split-props {:on/item :event/item :item “hello”}) => [{:on/item :event/item} {:item “hello”}]

dom-tags-equal?

added in 3.0

(dom-tags-equal? obj-a obj-b)

checks if two dom nodes have the same tags

(dom-tags-equal? (dom-create :mock/label) (dom-create :mock/label)) => true

dom-top

added in 3.0

(dom-top dom)

returns the top-most dom element

(def -a- (dom-create :mock/label)) (def -b- (dom-create :mock/pane {} [(dom-create :mock/pane {} -a-)]))

(dom-top -a-) => -b-

dom-trigger

added in 3.0

(dom-trigger {:keys [parent handler], :as dom} event)

triggers an event, propogating up the dom hierarchy

(def -p- (promise))

(-> (dom-create :mock/label) (dom-attach (fn dom event(deliver -p- event) nil)) (dom-trigger {:a 1 :b 2}))

@-p- => {:a 1, :b 2}

dom-vector?

added in 3.0

(dom-vector? obj)

checks if a vector can be a dom representation

(dom-vector? :fx/label "") => true

(dom-vector? ^:data :fx/label "") => false

dom?

added in 3.0

(dom? obj)

checks if object is an dom

(dom? (dom-create :mock/label {} “hello”)) => true

element?

added in 3.0

(element? dom)

checks if metatype is of :dom/element

(element? (dom-new :mock/label {})) => true

props-apply

added in 3.0

(props-apply props action)

applies an action to props map

(props-apply {:a (dom-create :mock/label {:text “hello”}) :b (dom-create :mock/pane {} “world”)} (comp :props dom-item impl/dom-render)) => {:a {:text “hello”}, :b {:children “world”}}

value?

added in 3.0

(value? dom)

checks if metatype is of :dom/value

(value? (dom-new :mock/insets {})) => true