crow/js/dom.crow
(source)
node
extern
Represents a DOM node.
You can use as-js
and treat this as a JS object.
create-node
node
(tag-name
symbol
)
Create a new DOM node with the given tag.
create-node
node
(tag-name
symbol
, attr
symbol
[
string
]
)
Create a new node with the given tag and HTML attributes.
create-node
node
(tag-name
symbol
, attr
symbol
[
string
]
, class-name
string
, children
node
array
)
create-button
node
(title
string
, class-name
string
, children
node
array
, on-click
mut
void
(void
))
style
record
mut
, nominal
node
node
set-subscript
void
(a
style
, key
symbol
, value
string
)
classes
record
mut
, nominal
node
node
~=
void
(a
classes
, class-name
string
)
set-classes
void
(a
node
, class-names
string
array
)
remove-class
void
(a
node
, class-name
string
)
set-text-content
void
(a
node
, text
string
)
add-event-listener
void
(a
node
, event-name
string
, fn
mut
void
(js-any
))
create-input-text
node
(on-input
mut
void
(js-any
), value
string
)
create-div
node
()
create-div
node
(class-name
string
)
create-div
node
(class-name
string
, children
node
array
)
create-span
node
(class-name
string
, children
node
array
)
create-span
node
(class-name
string
, attr
symbol
[
string
]
, children
node
array
)
create-text-node
node
(text
string
)
document
node
() summon
is-text-node
bool
(a
node
)
attributes
record
mut
, nominal
node
node
subscript
string
?
(a
attributes
, attr-name
symbol
)
set-subscript
void
(a
attributes
, attr-name
symbol
, value
string
)
value
string
(a
node
)
Gets the value for an input node, or "" if it's not an input node.
set-value
void
(a
node
, value
string
)
You can set a 'value' on any node, but it will only make a visual difference for input nodes.
query
node
?
(parent
node
, selector
string
)
Calls 'querySelector'
query-all
node
array
(selector
string
)
child-nodes
node
array
(a
node
)
element
node
?
(parent
node
, id
string
)
Calls 'getElementById'
first-child
node
?
(a
node
)
on-click
void
(a
node
, fn
mut
void
(void
)) summon
~=
void
(a
node
, b
node
)
Append a child node.
~~=
void
(a
node
, b
node
array
)
Append many child nodes.
set-children
void
(a
node
, children
node
array
)
Overwrites any existing child nodes.