Domonic: DOM

createElement

to create your own elements use the DOM API

from domonic.dom import *

site = html()
el = document.createElement('myelement')
site.appendChild(el)
print(site)

addEventlisteners recently been started. There’s several more DOM methods. Check code to see what’s currently implemented.

domonic.dom

methods on the dom

class domonic.dom.Document(*args, **kwargs)[source]

Baseclass for the html tag

anchors()[source]

Returns a collection of all <a> elements in the document that have a name attribute

applets()[source]

Returns a collection of all <applet> elements in the document

body

returns the document’s body (the <body> element)

characterSet

Returns the character encoding for the document

charset

Use characterSet instead.

Type:Returns the character encoding for the document. Deprecated
static createAttribute(name)[source]

Creates an attribute node

static createComment(message)[source]

Creates a Comment node with the specified text

static createElement(_type)[source]

Creates an Element node - WARNING THIS WILL NOT CREATE A ‘DOMONIC ELEMENT’ (yet), so it wont have features

static createEvent(event_type=None)[source]

Creates a new event

doctype()[source]

Returns the Document Type Declaration associated with the document

domain()[source]

Returns the domain name of the server that loaded the document

embeds()[source]

Returns a collection of all <embed> elements the document

forms

Returns a collection of all <form> elements in the document

getElementById()[source]

Returns the element that has the ID attribute with the specified value

getElementsByClassName()[source]

Returns a NodeList containing all elements with the specified class name

getElementsByName()[source]

Returns a NodeList containing all elements with a specified name

head()[source]

Returns the <head> element of the document

images

Returns a collection of all <img> elements in the document

implementation

Returns the DOMImplementation object that handles this document

links()[source]

Returns a collection of all <a> and <area> elements in the document that have a href attribute

normalize()[source]

Removes empty Text nodes, and joins adjacent nodes

normalizeDocument()[source]

Removes empty Text nodes, and joins adjacent nodes

querySelector()[source]

Returns the first element that matches a specified CSS selector(s) in the document

querySelectorAll()[source]

Returns a static NodeList containing all elements that matches a specified CSS selector(s) in the document

renameNode(node, namespaceURI, nodename)[source]

Renames the specified node

scripts

Returns a collection of <script> elements in the document

title

Sets or returns the title of the document

write(html: str = '') → None[source]

Writes HTML expressions or JavaScript code to a document

writeln(html: str = '') → None[source]

Same as write(), but adds a newline character after each statement

class domonic.dom.Element(*args, **kwargs)[source]

Baseclass for all html tags

attributes

Returns a List of an element’s attributes

blur()[source]

Removes focus from an element

classList

Returns the value of the classList attribute of an element

className

Sets or returns the value of the className attribute of an element

click()[source]

Simulates a mouse-click on an element

clientHeight

Returns the height of an element, including padding

clientLeft

Returns the width of the left border of an element

clientTop

Returns the width of the top border of an element

clientWidth

Returns the width of an element, including padding

compareDocumentPosition()[source]

Compares the document position of two elements

contentEditable()[source]

Sets or returns whether the content of an element is editable or not

dir()[source]

Sets or returns the value of the dir attribute of an element

exitFullscreen()[source]

Cancels an element in fullscreen mode

firstElementChild()[source]

Returns the first child element of an element

focus()[source]

Gives focus to an element

getAttribute(attribute: str) → str[source]

Returns the specified attribute value of an element node

getAttributeNode(attribute: str) → str[source]

Returns the specified attribute node

getBoundingClientRect()[source]

Returns the size of an element and its position relative to the viewport

getElementsByClassName()[source]

Returns a collection of all child elements with the specified class name

getElementsByTagName(tag: str) → List[T][source]

Returns a collection of all child elements with the specified tag name

hasAttribute(attribute: str) → str[source]

Returns true if an element has the specified attribute, otherwise false

hasAttributes() → bool[source]

Returns true if an element has any attributes, otherwise false

id

Sets or returns the value of the id attribute of an element

innerHTML

Sets or returns the content of an element

innerText()[source]

Sets or returns the text content of a node and its descendants

insertAdjacentElement()[source]

Inserts a HTML element at the specified position relative to the current element

insertAdjacentHTML()[source]

Inserts a HTML formatted text at the specified position relative to the current element

insertAdjacentText()[source]

Inserts text into the specified position relative to the current element

isContentEditable()[source]

Returns true if the content of an element is editable, otherwise false

isDefaultNamespace()[source]

Returns true if a specified namespaceURI is the default, otherwise false

lang()[source]

Sets or returns the value of the lang attribute of an element

lastElementChild()[source]

Returns the last child element of an element

namespaceURI()[source]

Returns the namespace URI of an element

nextElementSibling

Returns the next element at the same node tree level

nextSibling

Returns the next node at the same node tree level

normalize()[source]

Joins adjacent text nodes and removes empty text nodes in an element

offsetHeight()[source]

Returns the height of an element, including padding, border and scrollbar

offsetLeft()[source]

Returns the horizontal offset position of an element

offsetParent()[source]

Returns the offset container of an element

offsetTop()[source]

Returns the vertical offset position of an element

offsetWidth()[source]

Returns the width of an element, including padding, border and scrollbar

ownerDocument()[source]

Returns the root element (document object) for an element

parentElement

Returns the parent element node of an element

previousElementSibling

Returns the previous element at the same node tree level

previousSibling

Returns the previous node at the same node tree level

querySelector()[source]

Returns the first child element that matches a specified CSS selector(s) of an element

querySelectorAll()[source]

Returns all child elements that matches a specified CSS selector(s) of an element

remove()[source]

Removes the element from the DOM

removeAttribute(attribute: str)[source]

Removes a specified attribute from an element

removeAttributeNode(attribute)[source]

Removes a specified attribute node, and returns the removed node

requestFullscreen()[source]

Shows an element in fullscreen mode

scrollHeight()[source]

Returns the entire height of an element, including padding

scrollIntoView()[source]

Scrolls the specified element into the visible area of the browser window

scrollLeft()[source]

Sets or returns the number of pixels an element’s content is scrolled horizontally

scrollTop()[source]

Sets or returns the number of pixels an element’s content is scrolled vertically

scrollWidth()[source]

Returns the entire width of an element, including padding

setAttribute(attribute, value)[source]

Sets or changes the specified attribute, to the specified value

setAttributeNode(attr)[source]

Sets or changes the specified attribute node

style

returns the value of the style attribute of an element

textContent

Sets or returns the textual content of a node and its descendants

title

Sets or returns the value of the title attribute of an element

toString()[source]

Converts an element to a string

class domonic.dom.EventTarget(*args, **kwargs)[source]

Baseclass for Node

class domonic.dom.Node(*args, **kwargs)[source]

Element extends from Node

appendChild(item)[source]

Adds a new child node, to an element, as the last child node

childElementCount

Returns the number of child elements an element has

childNodes

Returns a collection of an element’s child nodes (including text and comment nodes)

children

Returns a collection of an element’s child element (excluding text and comment nodes)

cloneNode(deep=True)[source]

Returns a copy.

contains(node)[source]

Check whether a node is a descendant of a given node

firstChild

Returns the first child node of an element

hasChildNodes

Returns true if an element has any child nodes, otherwise false

insertBefore(new_node, reference_node)[source]

inserts a node before a reference node as a child of a specified parent node.

isEqualNode(node)[source]

Checks if two elements are equal

isSameNode(node)[source]

Checks if two elements are the same node

lastChild

Returns the last child node of an element

nodeName

Returns the name of a node

nodeType

Returns the node type of a node

nodeValue

Sets or returns the value of a node

removeChild(node)[source]

removes a child node from the DOM and returns the removed node.

replaceChild(newChild, oldChild)[source]

Replaces a child node within the given (parent) node.

rootNode

[read-only property returns a Node object representing the topmost node in the tree, or the current node if it’s the topmost node in the tree]

Returns:[the topmost Node in the tree]
Return type:[Node]
class domonic.dom.ParentNode(*args, **kwargs)[source]

not tested yet

class domonic.dom.ShadowRoot(host, mode='open')[source]

property on element that has hidden DOM

caretPositionFromPoint()[source]

Returns a CaretPosition object containing the DOM node containing the caret, and caret’s character offset within that node.

elementFromPoint()[source]

Returns the topmost element at the specified coordinates.

elementsFromPoint()[source]

Returns an array of all elements at the specified coordinates.

getSelection()[source]

Returns a Selection object representing the range of text selected by the user, or the current position of the caret.

domonic.dom.document

alias of domonic.dom.Document

domonic.events

dom events

class domonic.events.AnimationEvent(*args, **kwargs)[source]
animationName = None

Returns the name of the animation

elapsedTime = None

Returns the number of seconds an animation has been running

pseudoElement = None

Returns the name of the pseudo-element of the animation

class domonic.events.ClipboardEvent(*args, **kwargs)[source]
clipboardData = None

Returns an object containing the data affected by the clipboard operation

class domonic.events.CustomEvent(*args, **kwargs)[source]
class domonic.events.DragEvent(*args, **kwargs)[source]
dataTransfer = None

Returns the data that is dragged/dropped

class domonic.events.Event(_type=None, *args, **kwargs)[source]

event

class domonic.events.FocusEvent(*args, **kwargs)[source]
class domonic.events.HashChangeEvent(*args, **kwargs)[source]
newURL = None

Returns the URL of the document, after the hash has been changed

class domonic.events.InputEvent(*args, **kwargs)[source]
data = None

Returns the inserted characters

class domonic.events.KeyboardEvent(*args, **kwargs)[source]

keyboard events

class domonic.events.MouseEvent(*args, **kwargs)[source]

mouse events

class domonic.events.PageTransitionEvent(*args, **kwargs)[source]
PAGESHOW = 'onpageshow'

PageTransitionEvent

persisted = None

Returns whether the webpage was cached by the browser

class domonic.events.PopStateEvent(*args, **kwargs)[source]
state = None

Returns an object containing a copy of the history entries

class domonic.events.ProgressEvent(*args, **kwargs)[source]

CustomEvent

class domonic.events.StorageEvent(*args, **kwargs)[source]
key = None

Returns the key of the changed storage item

newValue = None

Returns the new value of the changed storage item

oldValue = None

Returns the old value of the changed storage item

storageArea = None

Returns an object representing the affected storage object

url = None

Returns the URL of the changed item’s document

class domonic.events.TouchEvent(*args, **kwargs)[source]
altKey = None

Returns whether the “ALT” key was pressed when the touch event was triggered

changedTouches = None

Returns a list of all the touch objects whose state changed between the previous touch and this touch

ctrlKey = None

Returns whether the “CTRL” key was pressed when the touch event was triggered

metaKey = None

Returns whether the “meta” key was pressed when the touch event was triggered

shiftKey = None

Returns whether the “SHIFT” key was pressed when the touch event was triggered

targetTouches = None

Returns a list of all the touch objects that are in contact with the surface and where the touchstart event occured on the same target element as the current target element

touches = None

Returns a list of all the touch objects that are currently in contact with the surface

class domonic.events.TransitionEvent(*args, **kwargs)[source]
TRANSITIONEND = 'ontransitionend'

TransitionEvent

elapsedTime = None

Returns the number of seconds a transition has been running

propertyName = None

Returns the name of the transition

pseudoElement = None

Returns the name of the pseudo-element of the transition

class domonic.events.UiEvent(*args, **kwargs)[source]
class domonic.events.WheelEvent(*args, **kwargs)[source]
deltaMode = None

Returns a number that represents the unit of measurements for delta values (pixels, lines or pages)

deltaX = None

Returns the horizontal scroll amount of a mouse wheel (x-axis)

deltaY = None

Returns the vertical scroll amount of a mouse wheel (y-axis)

deltaZ = None

Returns the scroll amount of a mouse wheel for the z-axis