Liking cljdoc? Tell your friends :D

dommy.core

cljs

Core DOM manipulation functions

Core DOM manipulation functions
raw docstring

add-class!cljs

(add-class! elem classes)
(add-class! elem classes & more-classes)

Add classes to elem, trying to use Element::classList, and falling back to fast string parsing/manipulation

Add `classes` to `elem`, trying to use Element::classList, and
falling back to fast string parsing/manipulation
sourceraw docstring

ancestor-nodescljsdeprecated

source

ancestorscljs

(ancestors elem)

Lazy seq of the ancestors of elem

Lazy seq of the ancestors of `elem`
sourceraw docstring

append!cljs

(append! parent child)
(append! parent child & more-children)

Append child to parent

Append `child` to `parent`
sourceraw docstring

attrcljs

(attr elem k)
source

bounding-client-rectcljs

(bounding-client-rect elem)

Returns a map of the bounding client rect of elem as a map with [:top :left :right :bottom :width :height]

Returns a map of the bounding client rect of `elem`
as a map with [:top :left :right :bottom :width :height]
sourceraw docstring

by-classclj/smacro

(by-class class)
(by-class base class)

Returns a sequence of DOM nodes selected by class. class can be a string or keyword and should not include the . selector prefix. Expands to base.getElementsByClassName. If base node is given, selection is limited to its descendant nodes.

Returns a sequence of DOM nodes selected by `class`. `class` can be
a string or keyword and should not include the . selector prefix.
Expands to `base.getElementsByClassName`. If `base` node is given,
selection is limited to its descendant nodes.
sourceraw docstring

by-idclj/smacro

(by-id id)

Returns the DOM node with id in document if it exists, otherwise nil. id can be a string or keyword. Expands to document.getElementById.

Returns the DOM node with id in document if it exists, otherwise nil.
`id` can be a string or keyword. Expands to `document.getElementById`.
sourceraw docstring

by-tagclj/smacro

(by-tag tag)
(by-tag base tag)

Same behavior as by-class, selecting by tag instead of a class.

Same behavior as `by-class`, selecting by `tag` instead of a class.
sourceraw docstring

childrencljs

(children elem)
source

classcljs

(class elem)
source

clear!cljs

(clear! elem)

Clears all children from elem

Clears all children from `elem`
sourceraw docstring

closestcljs

(closest elem selector)
(closest base elem selector)

Closest ancestor of elem (up to base, if provided) that matches selector

Closest ancestor of `elem` (up to `base`, if provided)
that matches `selector`
sourceraw docstring

create-elementcljs

(create-element tag)
(create-element tag-ns tag)
source

create-text-nodecljs

(create-text-node text)
source

descendant?cljs

(descendant? descendant ancestor)

Is descendant a descendant of ancestor? (http://goo.gl/T8pgCX)

Is `descendant` a descendant of `ancestor`?
(http://goo.gl/T8pgCX)
sourceraw docstring

has-class?cljs

(has-class? elem c)

Does elem contain c in its class list

Does `elem` contain `c` in its class list
sourceraw docstring

hidden?cljs

(hidden? elem)

Is elem hidden (as associated with hide!/show!/toggle!, using display: none)

Is `elem` hidden (as associated with hide!/show!/toggle!, using display: none)
sourceraw docstring

hide!cljs

(hide! elem)
source

htmlcljs

(html elem)
source

insert-after!cljs

(insert-after! elem other)

Insert elem after other, other must have a parent

Insert `elem` after `other`, `other` must have a parent
sourceraw docstring

insert-before!cljs

(insert-before! elem other)

Insert elem before other, other must have a parent

Insert `elem` before `other`, `other` must have a parent
sourceraw docstring

listen!cljs

(listen! elem-sel & type-fs)

Adds f as a listener for events of type event-type on elem-sel, which must either be a DOM node, or a sequence whose first item is a DOM node.

In other words, the call to listen! can take two forms:

If elem-sel is a DOM node, i.e., you're doing something like:

(listen! elem :click click-handler)

then click-handler will be set as a listener for click events on the elem.

If elem-sel is a sequence:

(listen! [elem :.selector.for :.some.descendants] :click click-handler)

then click-handler will be set as a listener for click events on descendants of elem that match the selector

Also accepts any number of event-type and handler pairs for setting multiple listeners at once:

(listen! some-elem :click click-handler :hover hover-handler)
Adds `f` as a listener for events of type `event-type` on
`elem-sel`, which must either be a DOM node, or a sequence
whose first item is a DOM node.

In other words, the call to `listen!` can take two forms:

If `elem-sel` is a DOM node, i.e., you're doing something like:

    (listen! elem :click click-handler)

then `click-handler` will be set as a listener for `click` events
on the `elem`.

If `elem-sel` is a sequence:

    (listen! [elem :.selector.for :.some.descendants] :click click-handler)

then `click-handler` will be set as a listener for `click` events
on descendants of `elem` that match the selector

Also accepts any number of event-type and handler pairs for setting
multiple listeners at once:

    (listen! some-elem :click click-handler :hover hover-handler)
sourceraw docstring

listen-once!cljs

(listen-once! elem-sel & type-fs)

Behaves like listen!, but removes the listener after the first event occurs.

Behaves like `listen!`, but removes the listener after the first event occurs.
sourceraw docstring

live-listenercljs

(live-listener elem selector f)

fires f if event.target is found with selector

fires f if event.target is found with `selector`
sourceraw docstring

matches-predcljs

(matches-pred selector)
(matches-pred base selector)

Returns a predicate on nodes that match selector at the time of this matches-pred call (may return outdated results if you fuck with the DOM)

Returns a predicate on nodes that match `selector` at the
time of this `matches-pred` call (may return outdated results
if you fuck with the DOM)
sourceraw docstring

parentcljs

(parent elem)
source

prepend!cljs

(prepend! parent child)
(prepend! parent child & more-children)

Prepend child to parent

Prepend `child` to `parent`
sourceraw docstring

pxcljs

(px elem k)
source

remove!cljs

(remove! elem)
(remove! p elem)

Remove elem from parent, return parent

Remove `elem` from `parent`, return `parent`
sourceraw docstring

remove-attr!cljs

(remove-attr! elem k)
(remove-attr! elem k & ks)

Removes dom attributes on and returns elem. class and classes are special cases which clear out the class name on removal.

Removes dom attributes on and returns `elem`.
`class` and `classes` are special cases which clear
out the class name on removal.
sourceraw docstring

remove-class!cljs

(remove-class! elem c)
(remove-class! elem class & classes)

Remove c from elem class list

Remove `c` from `elem` class list
sourceraw docstring

remove-style!cljs

(remove-style! elem & keywords)

Remove the style of elem using keywords:

(remove-style! elem :display :color)

Remove the style of `elem` using keywords:

(remove-style! elem :display :color)
sourceraw docstring

replace!cljs

(replace! elem new)

Replace elem with new, return new

Replace `elem` with `new`, return `new`
sourceraw docstring

replace-contents!cljs

(replace-contents! p child)

Replace children of elem with child

Replace children of `elem` with `child`
sourceraw docstring

scroll-into-viewcljs

(scroll-into-view elem align-with-top?)
source

selclj/smacro

(sel data)
(sel base data)

Same behavior as sel1, instead keeping the full array that by-class or by-tag expand to. Falls back to document.querySelectorAll instead of document.querySelector.

Same behavior as `sel1`, instead keeping the full array that `by-class`
or `by-tag` expand to. Falls back to `document.querySelectorAll` instead of
`document.querySelector`.
sourceraw docstring

sel1clj/smacro

(sel1 data)
(sel1 base data)

Select a single DOM node. Tries to expand to the native selector methods as defined by by-id, by-class, and by-tag, falling back to document.querySelector when the selector isn't a constant.

Select a single DOM node. Tries to expand to the native selector methods
as defined by `by-id`, `by-class`, and `by-tag`, falling back to
`document.querySelector` when the selector isn't a constant.
sourceraw docstring

selectorcljs

(selector data)

Returns a selector in string format. Accepts string, keyword, or collection.

Returns a selector in string format.
Accepts string, keyword, or collection.
sourceraw docstring

set-attr!cljs

(set-attr! elem k)
(set-attr! elem k v)
(set-attr! elem k v & kvs)

Sets dom attributes on and returns elem. Attributes without values will be set to their name:

(set-attr! elem :disabled)

With values, the function takes variadic kv pairs:

(set-attr! elem :id "some-id"
                :name "some-name")
Sets dom attributes on and returns `elem`.
Attributes without values will be set to their name:

    (set-attr! elem :disabled)

With values, the function takes variadic kv pairs:

    (set-attr! elem :id "some-id"
                    :name "some-name")
sourceraw docstring

set-class!cljs

(set-class! elem c)

Set the css class of elem to elem

Set the css class of `elem` to `elem`
sourceraw docstring

set-html!cljs

(set-html! elem html)

Set the innerHTML of elem to html

Set the innerHTML of `elem` to `html`
sourceraw docstring

set-px!cljs

(set-px! elem & kvs)
source

set-style!cljs

(set-style! elem & kvs)

Set the style of elem using key-value pairs:

(set-style! elem :display "block" :color "red")

Set the style of `elem` using key-value pairs:

(set-style! elem :display "block" :color "red")
sourceraw docstring

set-text!cljs

(set-text! elem text)

Set the textContent of elem to text, fall back to innerText

Set the textContent of `elem` to `text`, fall back to innerText
sourceraw docstring

set-value!cljs

(set-value! elem value)

Set the value of elem to value

Set the value of `elem` to `value`
sourceraw docstring

show!cljs

(show! elem)
source

special-listener-makerscljs

source

stylecljs

(style elem)
(style elem k)

The computed style of elem, optionally specifying the key of a particular style to return

The computed style of `elem`, optionally specifying the key of
a particular style to return
sourceraw docstring

textcljs

(text elem)
source

toggle!cljs

(toggle! elem)
(toggle! elem show?)

Display or hide the given elem (using display: none). Takes an optional boolean show?

Display or hide the given `elem` (using display: none).
Takes an optional boolean `show?`
sourceraw docstring

toggle-attr!cljs

(toggle-attr! elem k)
(toggle-attr! elem k add?)

Toggles a dom attribute k on elem, optionally specifying the boolean value with add?

Toggles a dom attribute `k` on `elem`, optionally specifying
the boolean value with `add?`
sourceraw docstring

toggle-class!cljs

(toggle-class! elem c)
(toggle-class! elem class add?)

(toggle-class! elem class) will add-class! if elem does not have class and remove-class! otherwise. (toggle-class! elem class add?) will add-class! if add? is truthy, otherwise it will remove-class!

(toggle-class! elem class) will add-class! if elem does not have class
and remove-class! otherwise.
(toggle-class! elem class add?) will add-class! if add? is truthy,
otherwise it will remove-class!
sourceraw docstring

unlisten!cljs

(unlisten! elem-sel & type-fs)

Removes event listener for the element defined in elem-sel, which is the same format as listen!.

The following forms are allowed, and will remove all handlers that match the parameters passed in:

(unlisten! [elem :.selector] :click event-listener)

(unlisten! [elem :.selector]
  :click event-listener
  :mouseover other-event-listener)
Removes event listener for the element defined in `elem-sel`,
 which is the same format as listen!.

The following forms are allowed, and will remove all handlers
that match the parameters passed in:

    (unlisten! [elem :.selector] :click event-listener)

    (unlisten! [elem :.selector]
      :click event-listener
      :mouseover other-event-listener)
sourceraw docstring

valuecljs

(value elem)
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close