Package

purescript-dom

Repository
purescript-contrib/purescript-dom
License
MIT
Uploaded by
garyb

Latest release Build status Maintainer: garyb

Type definitions, low level interface implementations, and standard effect type for use while interacting with the DOM.

Installation

bower install purescript-dom

Introduction

purescript-dom is intended to provide a common base for projects that need to talk to or about the DOM.

The API isn't primarily intended for "human consumption", but instead aims to provide functions and types that match up with the interfaces described in the DOM4, HTML5, and CSSOM specifications, with a minimal amount of additional opinion as to how they should be implemented in PureScript.

This consists of:

  • foreign data types for the various interfaces described.
  • Functions that read Foreign typed values (and IsForeign instances) for foreign types.
  • No classes or other niceties to aid with subtyping relationships. However, coercions are provided from subtypes to their supertypes. For example, from DOM.Node.Types, elementToNode.
  • Functions that can mutate the DOM, or that don't always return the same value, or return a value that may be mutated at a distance use Eff with the DOM effect
  • Enumeration values are provided as ADTs, but with an option to read the raw value too. For example, from DOM.Node.Node, nodeType and nodeTypeIndex.

Module structure

Interfaces from DOM4 are grouped under DOM.Node and interfaces from HTML5 are grouped under DOM.HTML, aside from event-related things which are grouped under DOM.Events. Additionally there are a few other useful DOM interfaces such as the File and XMLHttpRequest2 that have their own submodules.

In each submodule there is a .Types which should enumerate foreign data types for the interfaces within and the coercions and Foreign-reading functions that go with them. After that each interface should have its own submodule - so for example, Element is provided in DOM.Node.Types and the functions from the Element API are defined in DOM.Node.Element. Enumeration types such as NodeType also get their own modules, such as DOM.Node.NodeType.

Module documentation is published on Pursuit: http://pursuit.purescript.org/packages/purescript-dom

Non-standards compliant interfaces

Currently we're choosing not to implement deprecated or non-standard interfaces even if they are commonly available. The innerHTML property of Element and keyCode/charCode of KeyboardEvent being examples of this. Ideally this module will only provide types and functions that "everyone" can agree on. This also means new parts of the specifications that are currently not widely available may also be omitted for the time being, however this only applies to the API implementation, types for new interfaces will be included as needed.

Modules
DOM
DOM.CSS.Event.Types
DOM.Event.ClipboardEvent
DOM.Event.CompositionEvent
DOM.Event.Event
DOM.Event.EventPhase
DOM.Event.EventTarget
DOM.Event.FocusEvent
DOM.Event.KeyboardEvent
DOM.Event.MouseEvent
DOM.Event.Types
DOM.Event.WheelEvent
DOM.File.Blob
DOM.File.File
DOM.File.FileList
DOM.File.FileReader
DOM.File.FileReader.ReadyState
DOM.File.Types
DOM.HTML
DOM.HTML.Document
DOM.HTML.Event.DataTransfer
DOM.HTML.Event.DragEvent
DOM.HTML.Event.DragEvent.DataTransfer
DOM.HTML.Event.ErrorEvent
DOM.HTML.Event.EventTypes
DOM.HTML.Event.HashChangeEvent
DOM.HTML.Event.Types
DOM.HTML.HTMLAnchorElement
DOM.HTML.HTMLAreaElement
DOM.HTML.HTMLBaseElement
DOM.HTML.HTMLButtonElement
DOM.HTML.HTMLCanvasElement
DOM.HTML.HTMLDataElement
DOM.HTML.HTMLDataListElement
DOM.HTML.HTMLElement
DOM.HTML.HTMLEmbedElement
DOM.HTML.HTMLFieldSetElement
DOM.HTML.HTMLFormElement
DOM.HTML.HTMLIFrameElement
DOM.HTML.HTMLImageElement
DOM.HTML.HTMLInputElement
DOM.HTML.HTMLKeygenElement
DOM.HTML.HTMLLIElement
DOM.HTML.HTMLLabelElement
DOM.HTML.HTMLLegendElement
DOM.HTML.HTMLLinkElement
DOM.HTML.HTMLMapElement
DOM.HTML.HTMLMediaElement
DOM.HTML.HTMLMediaElement.CanPlayType
DOM.HTML.HTMLMediaElement.NetworkState
DOM.HTML.HTMLMediaElement.ReadyState
DOM.HTML.HTMLMetaElement
DOM.HTML.HTMLMeterElement
DOM.HTML.HTMLModElement
DOM.HTML.HTMLOListElement
DOM.HTML.HTMLObjectElement
DOM.HTML.HTMLOptGroupElement
DOM.HTML.HTMLOptionElement
DOM.HTML.HTMLOutputElement
DOM.HTML.HTMLParamElement
DOM.HTML.HTMLProgressElement
DOM.HTML.HTMLQuoteElement
DOM.HTML.HTMLScriptElement
DOM.HTML.HTMLSelectElement
DOM.HTML.HTMLSourceElement
DOM.HTML.HTMLStyleElement
DOM.HTML.HTMLTableCellElement
DOM.HTML.HTMLTableColElement
DOM.HTML.HTMLTableElement
DOM.HTML.HTMLTableHeaderCellElement
DOM.HTML.HTMLTableRowElement
DOM.HTML.HTMLTableSectionElement
DOM.HTML.HTMLTemplateElement
DOM.HTML.HTMLTextAreaElement
DOM.HTML.HTMLTimeElement
DOM.HTML.HTMLTitleElement
DOM.HTML.HTMLTrackElement
DOM.HTML.HTMLTrackElement.ReadyState
DOM.HTML.HTMLVideoElement
DOM.HTML.History
DOM.HTML.Location
DOM.HTML.Navigator
DOM.HTML.SelectionMode
DOM.HTML.Types
DOM.HTML.URL
DOM.HTML.Window
DOM.Node.ChildNode
DOM.Node.Document
DOM.Node.DocumentType
DOM.Node.Element
DOM.Node.HTMLCollection
DOM.Node.Node
DOM.Node.NodeList
DOM.Node.NodeType
DOM.Node.NonDocumentTypeChildNode
DOM.Node.NonElementParentNode
DOM.Node.ParentNode
DOM.Node.Types
DOM.Util.FFI
DOM.Websocket.Event.CloseEvent
DOM.Websocket.Event.Types
DOM.XHR.FormData
DOM.XHR.Types
Dependencies