jon.recoil.org

Module Js_of_ocaml.DomSource

DOM binding

This is a partial binding to the DOM Core API.

DOM objects

Sourceclass type 'node nodeList = object ... end

Specification of NodeList objects.

Sourcetype nodeType =
  1. | OTHER
  2. | ELEMENT
  3. | ATTRIBUTE
  4. | TEXT
  5. | CDATA_SECTION
  6. | ENTITY_REFERENCE
  7. | ENTITY
  8. | PROCESSING_INSTRUCTION
  9. | COMMENT
  10. | DOCUMENT
  11. | DOCUMENT_TYPE
  12. | DOCUMENT_FRAGMENT
  13. | NOTATION
Sourcemodule DocumentPosition : sig ... end
Sourceclass type node = object ... end

Specification of Node objects.

Sourceclass type attr = object ... end

Specification of Attr objects.

Sourceclass type 'node namedNodeMap = object ... end

Specification of NamedNodeMap objects.

Sourceclass type element = object ... end

Specification of Element objects.

Sourceclass type characterData = object ... end

Specification of CharacterData objects.

Specification of Comment objects

Specification of Text objects.

Specification of DocumentFragment objects.

Sourceclass type 'element document = object ... end

Specification of Document objects.

Helper functions

insertBefore p n c inserts node n as child of node p, just before node c, or as last child if p is empty. The expression insertBefore n c p behave the same as p##insertBefore n c but avoid the need of coercing the different objects to node t.

The expression replaceChild p n c behave the same as p##replaceChild n c (replace c by n in p) but avoid the need of coercing the different objects to node t.

Sourceval removeChild : node Js_of_ocaml.Js.t -> node Js_of_ocaml.Js.t -> unit

The expression removeChild n c behave the same as n##removeChild c (remove c from n) but avoid the need of coercing the different objects to node t.

Sourceval appendChild : node Js_of_ocaml.Js.t -> node Js_of_ocaml.Js.t -> unit

The expression appendChild n c behave the same as n##appendChild c (appends c to n) but avoid the need of coercing the different objects to node t.

Sourceval list_of_nodeList : 'a nodeList Js_of_ocaml.Js.t -> 'a Js_of_ocaml.Js.t list
Sourcetype node_type =
  1. | Element of element Js_of_ocaml.Js.t
  2. | Attr of attr Js_of_ocaml.Js.t
  3. | Text of text Js_of_ocaml.Js.t
  4. | Other of node Js_of_ocaml.Js.t
Sourcemodule CoerceTo : sig ... end

Events

Sourcetype (-'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.

Sourceclass type 'a event = object ... end
Sourceclass type ['a, 'b] customEvent = object ... end

Event handlers

Sourceval no_handler : ('a, 'b) Js_of_ocaml.Dom.event_listener

Void event handler (Javascript null value).

Sourceval handler : (('e event Js_of_ocaml.Js.t as 'b) -> bool Js_of_ocaml.Js.t) -> ('a, 'b) Js_of_ocaml.Dom.event_listener

Create an event handler that invokes the provided function. If the handler returns false, the default action is prevented.

Sourceval full_handler : ('a -> ('e event Js_of_ocaml.Js.t as 'b) -> bool Js_of_ocaml.Js.t) -> ('a, 'b) Js_of_ocaml.Dom.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.

Sourceval invoke_handler : ('a, 'b) Js_of_ocaml.Dom.event_listener -> 'a -> 'b -> bool Js_of_ocaml.Js.t

Invoke an existing handler. Useful to chain event handlers.

Sourceval 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)

Sourcetype event_listener_id
Sourcemodule Event : sig ... end
Sourceval addEventListenerWithOptions : (< .. > Js_of_ocaml.Js.t as 'a) -> 'b Js_of_ocaml.Dom.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) Js_of_ocaml.Dom.event_listener -> Js_of_ocaml.Dom.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.

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.

Sourceval removeEventListener : Js_of_ocaml.Dom.event_listener_id -> unit

Remove the given event listener.

Sourceval 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.

Sourceval createCustomEvent : ?bubbles:bool -> ?cancelable:bool -> ?detail:'b -> ['a, 'b] customEvent Js_of_ocaml.Js.t Js_of_ocaml.Dom.Event.typ -> ('a, 'b) customEvent Js_of_ocaml.Js.t

Create a custom event of given type.

Other DOM objects

Sourceclass type stringList = object ... end