Module Js_of_ocaml__.Dom
DOM objects
class type 'node nodeList = object ... end
Specification of
NodeList
objects.
type nodeType
=
|
OTHER
|
ELEMENT
|
ATTRIBUTE
|
TEXT
|
CDATA_SECTION
|
ENTITY_REFERENCE
|
ENTITY
|
PROCESSING_INSTRUCTION
|
COMMENT
|
DOCUMENT
|
DOCUMENT_TYPE
|
DOCUMENT_FRAGMENT
|
NOTATION
module DocumentPosition : sig ... end
class type node = object ... end
Specification of
Node
objects.
class type attr = object ... end
Specification of
Attr
objects.
and 'node namedNodeMap = object ... end
Specification of
NamedNodeMap
objects.
and element = object ... end
Specification of
Element
objects.
class type characterData = object ... end
Specification of
CharacterData
objects.
class type comment = characterData
Specification of
Comment
objects
class type text = characterData
Specification of
Text
objects.
class type documentFragment = node
Specification of
DocumentFragment
objects.
class type 'element document = object ... end
Specification of
Document
objects.
Helper functions
val insertBefore : node Js_of_ocaml.Js.t -> node Js_of_ocaml.Js.t -> node Js_of_ocaml.Js.t Js_of_ocaml.Js.opt -> unit
insertBefore p n c
inserts noden
as child of nodep
, just before nodec
, or as last child ifp
is empty. The expressioninsertBefore n c p
behave the same asp##insertBefore n c
but avoid the need of coercing the different objects tonode t
.
val replaceChild : node Js_of_ocaml.Js.t -> node Js_of_ocaml.Js.t -> node Js_of_ocaml.Js.t -> unit
The expression
replaceChild p n c
behave the same asp##replaceChild n c
(replacec
byn
inp
) but avoid the need of coercing the different objects tonode t
.
val removeChild : node Js_of_ocaml.Js.t -> node Js_of_ocaml.Js.t -> unit
The expression
removeChild n c
behave the same asn##removeChild c
(removec
fromn
) but avoid the need of coercing the different objects tonode t
.
val appendChild : node Js_of_ocaml.Js.t -> node Js_of_ocaml.Js.t -> unit
The expression
appendChild n c
behave the same asn##appendChild c
(appendsc
ton
) but avoid the need of coercing the different objects tonode t
.
val list_of_nodeList : 'a nodeList Js_of_ocaml.Js.t -> 'a Js_of_ocaml.Js.t list
type node_type
=
|
Element of element Js_of_ocaml.Js.t
|
Attr of attr Js_of_ocaml.Js.t
|
Text of text Js_of_ocaml.Js.t
|
Other of node Js_of_ocaml.Js.t
val nodeType : node Js_of_ocaml.Js.t -> node_type
module CoerceTo : sig ... end
Events
type (-'a, -'b) event_listener
The type of event listener functions. The first type parameter
'a
is the type of the target object; the second parameter'b
is the type of the event object.
class type 'a event = object ... end
class type ['a, 'b] customEvent = object ... end
Event handlers
val no_handler : ('a, 'b) event_listener
Void event handler (Javascript
null
value).
val handler : ('e event Js_of_ocaml.Js.t as b -> bool Js_of_ocaml.Js.t) -> ('a, 'b) event_listener
Create an event handler that invokes the provided function. If the handler returns false, the default action is prevented.
val full_handler : ('a -> 'e event Js_of_ocaml.Js.t as b -> bool Js_of_ocaml.Js.t) -> ('a, 'b) event_listener
Create an event handler that invokes the provided function. The event target (implicit parameter
this
) is also passed as argument to the function.
val invoke_handler : ('a, 'b) event_listener -> 'a -> 'b -> bool Js_of_ocaml.Js.t
Invoke an existing handler. Useful to chain event handlers.
val eventTarget : < .. > as a event Js_of_ocaml.Js.t -> 'a Js_of_ocaml.Js.t
Returns which object is the target of this event. It raises
Not_found
in case there is no target (if the event has not been triggered yet)
module Event : sig ... end
val addEventListenerWithOptions : < .. > Js_of_ocaml.Js.t as a -> 'b Event.typ -> ?capture:bool Js_of_ocaml.Js.t -> ?once:bool Js_of_ocaml.Js.t -> ?passive:bool Js_of_ocaml.Js.t -> ('a, 'b) event_listener -> event_listener_id
Add an event listener. This function matches the option-object variant of the
addEventListener
DOM method, except that it returns an id for removing the listener.
val addEventListener : < .. > Js_of_ocaml.Js.t as a -> 'b Event.typ -> ('a, 'b) event_listener -> bool Js_of_ocaml.Js.t -> event_listener_id
Add an event listener. This function matches the useCapture boolean variant of the
addEventListener
DOM method, except that it returns an id for removing the listener.
val removeEventListener : event_listener_id -> unit
Remove the given event listener.
val preventDefault : 'a event Js_of_ocaml.Js.t -> unit
Call this to prevent the default handler for the event. To stop propagation of the event, call
Dom_html.stopPropagation
.
val createCustomEvent : ?bubbles:bool -> ?cancelable:bool -> ?detail:'b -> ['a, 'b] customEvent Js_of_ocaml.Js.t Event.typ -> ('a, 'b) customEvent Js_of_ocaml.Js.t
Create a custom event of given type.
Other DOM objects
class type stringList = object ... end