Node interfaces/classes

class wdom.node.AbstractNode[source]

Bases: xml.dom.Node

Abstract Base Class for Node classes.

class wdom.node.Node(parent: wdom.node.AbstractNode = None) → None[source]

Bases: wdom.node.AbstractNode

Base Class for Node interface.

Initialize node object with parent node.

Parameters:parent (Node) – parent node.
connected

When this instance has any connection, return True.

Return type:bool
length

Return number of child nodes.

Return type:int
parentNode

Return parent node.

If this node does not have a parent, return None.

Return type:Optional[AbstractNode]
childNodes

Return child nodes of this node.

Returned object is an instance of NodeList, which is a list like object but not support any modification. NodeList is a live object, which means that changes on this node is reflected to the object.

Return type:NodeList[]
firstChild

Return the first child node.

If this node does not have any child, return None.

Return type:Optional[AbstractNode]
lastChild

Return the last child node.

If this node does not have any child, return None.

Return type:Optional[AbstractNode]
previousSibling

Return the previous sibling of this node.

If there is no previous sibling, return None.

Return type:Optional[AbstractNode]
nextSibling

Return the next sibling of this node.

If there is no next sibling, return None.

Return type:Optional[AbstractNode]
ownerDocument

Return the owner document of this node.

Owner document is an ancestor document node of this node. If this node (or node tree including this node) is not appended to any document node, this property returns None.

Return type:Document or None
appendChild(node)[source]

Append the node at the last of this child nodes.

Return type:AbstractNode
index(node)[source]

Return index of the node.

If the node is not a child of this node, raise ValueError.

Return type:int
insertBefore(node, ref_node)[source]

Insert a node just before the reference node.

Return type:AbstractNode
hasChildNodes()[source]

Return True if this node has child nodes, otherwise return False.

Return type:bool
removeChild(node)[source]

Remove a node from this node.

If node is not a child of this node, raise ValueError.

Return type:AbstractNode
replaceChild(new_child, old_child)[source]

Replace an old child with new child.

Return type:AbstractNode
hasAttributes()[source]

Return True if this node has attributes.

Return type:bool
cloneNode(deep=False)[source]

Return new copy of this node.

If optional argument deep is specified and is True, new node has clones of child nodes of this node (if presents).

Return type:AbstractNode
empty()[source]

[Not Standard] Remove all child nodes from this node.

This is equivalent to node.textContent = ''.

Return type:None
textContent

Return text contents of this node and all chid nodes.

When any value is set to this property, all child nodes are removed and new value is set as a text node.

Return type:str
class wdom.node.Text(text: str = '', parent: wdom.node.Node = None) → None[source]

Bases: wdom.node.CharacterData

Node class to wrap text contents.

html

Return html-escaped string representation of this node.

Return type:str
class wdom.node.RawHtml(text: str = '', parent: wdom.node.Node = None) → None[source]

Bases: wdom.node.Text

Very similar to Text class, but contents are always not escaped.

This node is [NOT DOM Standard].

html

Return html representation.

Return type:str
class wdom.node.Comment(text: str = '', parent: wdom.node.Node = None) → None[source]

Bases: wdom.node.CharacterData

Comment node class.

html

Return html representation.

Return type:str
class wdom.node.DocumentType(type: str = 'html', parent: wdom.node.Node = None) → None[source]

Bases: wdom.node.Node, wdom.node.NonDocumentTypeChildNode

DocumentType node class.

Initialize DocumentType node with type doctype.

nodeName

Return node name (=type).

Return type:str
name

Return node type.

Return type:str
html

Return html representation.

Return type:str
class wdom.node.DocumentFragment(parent: wdom.node.AbstractNode = None) → None[source]

Bases: wdom.node.Node, wdom.node.ParentNode

DocumentFragument node class.

Initialize node object with parent node.

Parameters:parent (Node) – parent node.
html

Return html representation.

Return type:str
class wdom.document.Document(*, doctype: str = 'html', default_class: type = <class 'wdom.element.HTMLElement'>, **kwargs: typing.Any) → None[source]

Bases: wdom.node.Node, wdom.node.ParentNode, wdom.event.EventTarget

Base class for Document node.

Create new Document node.

Parameters:
  • doctype (str) – Document type of this document.
  • default_class (type) – Default class created by createElement() method.
getElementsBy(cond)

Return list of child elements of start_node which matches cond.

cond must be a function which gets a single argument Element, and returns boolean. If the node matches requested condition, cond should return True. This searches all child elements recursively.

Parameters:
  • start_node (ParentNode) –
  • cond – Callable[[Element], bool]
Return type:

NodeList[Element]

getElementsByTagName(tag)

Get child nodes which tag name is tag.

Return type:NodeList[]
getElementsByClassName(class_name)

Get child nodes which has class_name class attribute.

Return type:NodeList[]
defaultView

Return Window class of this document.

Return type:Window
doctype

Return DocumentType element of this document.

Return type:DocumentType
documentElement

Return <html> element of this document.

Return type:Element
head

Return <head> element of this document.

Return type:Element
characterSet

Get/Set charset of this document.

Return type:str
body

Return <body> element of this document.

Return type:Element
title

Get/Set title string of this document.

Return type:str
getElementById(id)[source]

Get element by id.

If this document does not have the element with the id, return None.

Return type:Optional[Node]
createDocumentFragment()[source]

Create empty document fragment.

Return type:DocumentFragment
createTextNode(text)[source]

Create text node with text.

Return type:Text
createComment(comment)[source]

Create comment node with comment.

Return type:Comment
createElement(tag)[source]

Create new element whose tag name is tag.

Return type:Node
createEvent(event)[source]

Create Event object with event type.

Return type:Event
createAttribute(name)[source]

Create Attribute object with name.

Return type:Attr
class wdom.element.Attr(name: str, value: typing.Union[typing.List[str], str, int, wdom.css.CSSStyleDeclaration, NoneType] = None, owner: wdom.node.Node = None) → None[source]

Bases: object

Attribute node.

In the latest DOM specification, Attr interface does not inherits Node interface. (Previously, Attr inherited Node interface.)

Initialize this attribute.

Parameters:
  • name (str) – property name.
  • value (_AttrValueType) – attribute value.
  • owner (Node) – owner node of this attribute (optional).
html

Return string representation of this.

Used in start tag of HTML representation of the Element node.

Return type:str
name

Name of this attr.

Return type:str
value

Value of this attr.

Return type:Union[List[str], str, int, CSSStyleDeclaration, None]
isId

Return True if this Attr is an ID node (name is id).

Return type:bool
class wdom.element.Element(tag: str = '', parent: wdom.node.Node = None, _registered: bool = True, **kwargs: typing.Any) → None[source]

Bases: wdom.node.Node, wdom.event.EventTarget, wdom.node.ParentNode, wdom.node.NonDocumentTypeChildNode, wdom.node.ChildNode

Element base class.

Initialize.

Parameters:
  • tag (str) – HTML tag of this node.
  • parent (Node) – Parent node of this node.
  • _registered (bool) – Is registered to CustomElementRegistry.
  • kwargs – key-value pair of attributes.
getElementsBy(cond)

Return list of child elements of start_node which matches cond.

cond must be a function which gets a single argument Element, and returns boolean. If the node matches requested condition, cond should return True. This searches all child elements recursively.

Parameters:
  • start_node (ParentNode) –
  • cond – Callable[[Element], bool]
Return type:

NodeList[Element]

getElementsByTagName(tag)

Get child nodes which tag name is tag.

Return type:NodeList[]
getElementsByClassName(class_name)

Get child nodes which has class_name class attribute.

Return type:NodeList[]
start_tag

Return HTML start tag.

Return type:str
end_tag

Return HTML end tag.

Return type:str
innerHTML

Return HTML representation of child nodes.

Return type:str
html

Return HTML representation of this node.

Return type:str
insertAdjacentHTML(position, html)[source]

Parse html to DOM and insert to position.

position is a case-insensive string, and must be one of “beforeBegin”, “afterBegin”, “beforeEnd”, or “afterEnd”.

Return type:None
outerHTML

Return html representation of this node.

Equivalent to self.html.

Return type:str
nodeName

Return tag name (capital case).

Return type:str
tagName

Return tag name (capital case).

Return type:str
localName

Return tag name (lower case).

Return type:str
className

Get/Set class name as/by string.

Return type:str
getAttribute(attr)[source]

Get attribute of this node as string format.

If this node does not have attr, return None.

Return type:Union[List[str], str, int, CSSStyleDeclaration, None]
getAttributeNode(attr)[source]

Get attribute of this node as Attr format.

If this node does not have attr, return None.

Return type:Optional[Attr]
hasAttribute(attr)[source]

Return True if this node has attr.

Return type:bool
hasAttributes()[source]

Return True if this node has any attributes.

Return type:bool
setAttribute(attr, value)[source]

Set attr and value in this node.

Return type:None
setAttributeNode(attr)[source]

Set Attr node as this node’s attribute.

Return type:None
removeAttribute(attr)[source]

Remove attr from this node.

Return type:None
removeAttributeNode(attr)[source]

Remove Attr node from this node.

Return type:Optional[Attr]
id

Getter: Get value of id attribute of this element, as string. If id is not defined, return empty string. Setter: Set the value of id attribute of this element. Deleter: Remove id attribute from this element.

Return type:str
class wdom.element.HTMLElement(*args: typing.Any, style: str = None, **kwargs: typing.Any) → None[source]

Bases: wdom.element.Element

Base class for HTMLElement.

This class extends Element class with some HTML specific features.

end_tag

Retrun html end tag.

If tag is empty tag like <img> or <br>, return empty string.

Return type:str
style

Return style attribute of this node.

Return type:CSSStyleDeclaration
draggable

Get draggable property.

Return type:Union[bool, str]
hidden

Getter: Return True if this element has hidden attribute. Otherwise return False. Setter: If True, add hidden attribute to this element. Otherwise remove hidden. Deleter: Remove hidden attribute from this element.

Return type:bool
title

Getter: Get value of title attribute of this element, as string. If title is not defined, return empty string. Setter: Set the value of title attribute of this element. Deleter: Remove title attribute from this element.

Return type:str
type

Getter: Get value of type attribute of this element, as string. If type is not defined, return empty string. Setter: Set the value of type attribute of this element. Deleter: Remove type attribute from this element.

Return type:str
class wdom.window.Window(document: wdom.node.Node) → None[source]

Bases: wdom.event.WebEventTarget

Window base class.

Make new window object.

Parameters:document (Document) – root document of the window.
document

Return document object of this window.

Return type:Node
ownerDocument

Need for connection check.

Return type:Node
customElements

Return customElementsRegistry object.

Return type:CustomElementsRegistry

Conclete HTML Elements

class wdom.element.HTMLAnchorElement(*args: typing.Any, style: str = None, **kwargs: typing.Any) → None[source]

Bases: wdom.element.HTMLElement

HTMLAnchorElement class (<a></a> tag).

href

Getter: Get value of href attribute of this element, as string. If href is not defined, return empty string. Setter: Set the value of href attribute of this element. Deleter: Remove href attribute from this element.

Return type:str
name

Getter: Get value of name attribute of this element, as string. If name is not defined, return empty string. Setter: Set the value of name attribute of this element. Deleter: Remove name attribute from this element.

Return type:str
rel

Getter: Get value of rel attribute of this element, as string. If rel is not defined, return empty string. Setter: Set the value of rel attribute of this element. Deleter: Remove rel attribute from this element.

Return type:str
src

Getter: Get value of src attribute of this element, as string. If src is not defined, return empty string. Setter: Set the value of src attribute of this element. Deleter: Remove src attribute from this element.

Return type:str
target

Getter: Get value of target attribute of this element, as string. If target is not defined, return empty string. Setter: Set the value of target attribute of this element. Deleter: Remove target attribute from this element.

Return type:str
class wdom.element.HTMLButtonElement(*args: typing.Any, style: str = None, **kwargs: typing.Any) → None[source]

Bases: wdom.element.HTMLElement

HTMLButtonElement class (<button></button> tag).

disabled

Getter: Return True if this element has disabled attribute. Otherwise return False. Setter: If True, add disabled attribute to this element. Otherwise remove disabled. Deleter: Remove disabled attribute from this element.

Return type:bool
name

Getter: Get value of name attribute of this element, as string. If name is not defined, return empty string. Setter: Set the value of name attribute of this element. Deleter: Remove name attribute from this element.

Return type:str
value

Getter: Get value of value attribute of this element, as string. If value is not defined, return empty string. Setter: Set the value of value attribute of this element. Deleter: Remove value attribute from this element.

Return type:str
class wdom.element.HTMLFormElement(*args: typing.Any, style: str = None, **kwargs: typing.Any) → None[source]

Bases: wdom.element.HTMLElement

HTMLFormElement class (<form></form> tag).

name

Getter: Get value of name attribute of this element, as string. If name is not defined, return empty string. Setter: Set the value of name attribute of this element. Deleter: Remove name attribute from this element.

Return type:str
class wdom.element.HTMLIFrameElement(*args: typing.Any, style: str = None, **kwargs: typing.Any) → None[source]

Bases: wdom.element.HTMLElement

HTMLIFrameElement class (<iframe></iframe> tag).

height

Getter: Get value of height attribute of this element, as string. If height is not defined, return empty string. Setter: Set the value of height attribute of this element. Deleter: Remove height attribute from this element.

Return type:str
name

Getter: Get value of name attribute of this element, as string. If name is not defined, return empty string. Setter: Set the value of name attribute of this element. Deleter: Remove name attribute from this element.

Return type:str
src

Getter: Get value of src attribute of this element, as string. If src is not defined, return empty string. Setter: Set the value of src attribute of this element. Deleter: Remove src attribute from this element.

Return type:str
target

Getter: Get value of target attribute of this element, as string. If target is not defined, return empty string. Setter: Set the value of target attribute of this element. Deleter: Remove target attribute from this element.

Return type:str
width

Getter: Get value of width attribute of this element, as string. If width is not defined, return empty string. Setter: Set the value of width attribute of this element. Deleter: Remove width attribute from this element.

Return type:str
class wdom.element.HTMLInputElement(*args: typing.Any, style: str = None, **kwargs: typing.Any) → None[source]

Bases: wdom.element.HTMLElement, wdom.element.FormControlMixin

HTMLInputElement class (<input></input> tag).

on_event_pre(e)[source]

Set values set on browser before calling event listeners.

Return type:None
defaultChecked

Property is this control checked by default.

Return type:bool
defaultValue

Defatul value of this node.

Return type:Union[List[str], str, int, CSSStyleDeclaration, None]
checked

Getter: Return True if this element has checked attribute. Otherwise return False. Setter: If True, add checked attribute to this element. Otherwise remove checked. Deleter: Remove checked attribute from this element.

Return type:bool
disabled

Getter: Return True if this element has disabled attribute. Otherwise return False. Setter: If True, add disabled attribute to this element. Otherwise remove disabled. Deleter: Remove disabled attribute from this element.

Return type:bool
height

Getter: Get value of height attribute of this element, as string. If height is not defined, return empty string. Setter: Set the value of height attribute of this element. Deleter: Remove height attribute from this element.

Return type:str
multiple

Getter: Return True if this element has multiple attribute. Otherwise return False. Setter: If True, add multiple attribute to this element. Otherwise remove multiple. Deleter: Remove multiple attribute from this element.

Return type:bool
name

Getter: Get value of name attribute of this element, as string. If name is not defined, return empty string. Setter: Set the value of name attribute of this element. Deleter: Remove name attribute from this element.

Return type:str
readonly

Getter: Return True if this element has readonly attribute. Otherwise return False. Setter: If True, add readonly attribute to this element. Otherwise remove readonly. Deleter: Remove readonly attribute from this element.

Return type:bool
required

Getter: Return True if this element has required attribute. Otherwise return False. Setter: If True, add required attribute to this element. Otherwise remove required. Deleter: Remove required attribute from this element.

Return type:bool
src

Getter: Get value of src attribute of this element, as string. If src is not defined, return empty string. Setter: Set the value of src attribute of this element. Deleter: Remove src attribute from this element.

Return type:str
value

Getter: Get value of value attribute of this element, as string. If value is not defined, return empty string. Setter: Set the value of value attribute of this element. Deleter: Remove value attribute from this element.

Return type:str
width

Getter: Get value of width attribute of this element, as string. If width is not defined, return empty string. Setter: Set the value of width attribute of this element. Deleter: Remove width attribute from this element.

Return type:str
class wdom.element.HTMLLabelElement(*args: typing.Any, style: str = None, **kwargs: typing.Any) → None[source]

Bases: wdom.element.HTMLElement, wdom.element.FormControlMixin

HTMLLabelElement class (<label></label> tag).

htmlFor

Retrun for attribute value.

Return type:Union[List[str], str, int, CSSStyleDeclaration, None]
control

Return related HTMLElement object.

Return type:Optional[HTMLElement]
class wdom.element.HTMLOptGroupElement(*args: typing.Any, style: str = None, **kwargs: typing.Any) → None[source]

Bases: wdom.element.HTMLElement, wdom.element.FormControlMixin

HTMLOptionElement class (<optgroup></optgroup> tag).

disabled

Getter: Return True if this element has disabled attribute. Otherwise return False. Setter: If True, add disabled attribute to this element. Otherwise remove disabled. Deleter: Remove disabled attribute from this element.

Return type:bool
label

Getter: Get value of label attribute of this element, as string. If label is not defined, return empty string. Setter: Set the value of label attribute of this element. Deleter: Remove label attribute from this element.

Return type:str
class wdom.element.HTMLOptionElement(*args: typing.Any, style: str = None, **kwargs: typing.Any) → None[source]

Bases: wdom.element.HTMLElement, wdom.element.FormControlMixin

HTMLOptionElement class (<option></option> tag).

defaultSelected

Getter: Return True if this element has defaultSelected attribute. Otherwise return False. Setter: If True, add defaultSelected attribute to this element. Otherwise remove defaultSelected. Deleter: Remove defaultSelected attribute from this element.

Return type:bool
disabled

Getter: Return True if this element has disabled attribute. Otherwise return False. Setter: If True, add disabled attribute to this element. Otherwise remove disabled. Deleter: Remove disabled attribute from this element.

Return type:bool
label

Getter: Get value of label attribute of this element, as string. If label is not defined, return empty string. Setter: Set the value of label attribute of this element. Deleter: Remove label attribute from this element.

Return type:str
selected

Getter: Return True if this element has selected attribute. Otherwise return False. Setter: If True, add selected attribute to this element. Otherwise remove selected. Deleter: Remove selected attribute from this element.

Return type:bool
value

Getter: Get value of value attribute of this element, as string. If value is not defined, return empty string. Setter: Set the value of value attribute of this element. Deleter: Remove value attribute from this element.

Return type:str
class wdom.element.HTMLScriptElement(*args: typing.Any, style: str = None, **kwargs: typing.Any) → None[source]

Bases: wdom.element.HTMLElement

HTMLScriptElement class (<script></script> tag).

In this tag, all inner contents are not escaped.

async

Getter: Return True if this element has async attribute. Otherwise return False. Setter: If True, add async attribute to this element. Otherwise remove async. Deleter: Remove async attribute from this element.

Return type:bool
charset

Getter: Get value of charset attribute of this element, as string. If charset is not defined, return empty string. Setter: Set the value of charset attribute of this element. Deleter: Remove charset attribute from this element.

Return type:str
defer

Getter: Return True if this element has defer attribute. Otherwise return False. Setter: If True, add defer attribute to this element. Otherwise remove defer. Deleter: Remove defer attribute from this element.

Return type:bool
src

Getter: Get value of src attribute of this element, as string. If src is not defined, return empty string. Setter: Set the value of src attribute of this element. Deleter: Remove src attribute from this element.

Return type:str
class wdom.element.HTMLSelectElement(*args: typing.Any, **kwargs: typing.Any) → None[source]

Bases: wdom.element.HTMLElement, wdom.element.FormControlMixin

HTMLSelectElement class (<select></select> tag).

on_event_pre(e)[source]

Set values set on browser before calling event listeners.

Return type:None
length

Return number of options in this node.

Return type:int
disabled

Getter: Return True if this element has disabled attribute. Otherwise return False. Setter: If True, add disabled attribute to this element. Otherwise remove disabled. Deleter: Remove disabled attribute from this element.

Return type:bool
multiple

Getter: Return True if this element has multiple attribute. Otherwise return False. Setter: If True, add multiple attribute to this element. Otherwise remove multiple. Deleter: Remove multiple attribute from this element.

Return type:bool
name

Getter: Get value of name attribute of this element, as string. If name is not defined, return empty string. Setter: Set the value of name attribute of this element. Deleter: Remove name attribute from this element.

Return type:str
options

Return all option nodes in this node.

Return type:NodeList[]
required

Getter: Return True if this element has required attribute. Otherwise return False. Setter: If True, add required attribute to this element. Otherwise remove required. Deleter: Remove required attribute from this element.

Return type:bool
size

Getter: Get value of size attribute of this element, as string. If size is not defined, return empty string. Setter: Set the value of size attribute of this element. Deleter: Remove size attribute from this element.

Return type:str
value

Getter: Get value of value attribute of this element, as string. If value is not defined, return empty string. Setter: Set the value of value attribute of this element. Deleter: Remove value attribute from this element.

Return type:str
selectedOptions

Return all selected option nodes.

Return type:NodeList[]
class wdom.element.HTMLStyleElement(*args: typing.Any, style: str = None, **kwargs: typing.Any) → None[source]

Bases: wdom.element.HTMLElement

HTMLStyleElement class (<style></style> tag).

In this tag, all inner contents are not escaped.

disabled

Getter: Return True if this element has disabled attribute. Otherwise return False. Setter: If True, add disabled attribute to this element. Otherwise remove disabled. Deleter: Remove disabled attribute from this element.

Return type:bool
scoped

Getter: Return True if this element has scoped attribute. Otherwise return False. Setter: If True, add scoped attribute to this element. Otherwise remove scoped. Deleter: Remove scoped attribute from this element.

Return type:bool
class wdom.element.HTMLTextAreaElement(*args: typing.Any, style: str = None, **kwargs: typing.Any) → None[source]

Bases: wdom.element.HTMLElement, wdom.element.FormControlMixin

HTMLTextAreaElement class (<textarea></textarea> tag).

disabled

Getter: Return True if this element has disabled attribute. Otherwise return False. Setter: If True, add disabled attribute to this element. Otherwise remove disabled. Deleter: Remove disabled attribute from this element.

Return type:bool
height

Getter: Get value of height attribute of this element, as string. If height is not defined, return empty string. Setter: Set the value of height attribute of this element. Deleter: Remove height attribute from this element.

Return type:str
name

Getter: Get value of name attribute of this element, as string. If name is not defined, return empty string. Setter: Set the value of name attribute of this element. Deleter: Remove name attribute from this element.

Return type:str
src

Getter: Get value of src attribute of this element, as string. If src is not defined, return empty string. Setter: Set the value of src attribute of this element. Deleter: Remove src attribute from this element.

Return type:str
value

Getter: Get value of value attribute of this element, as string. If value is not defined, return empty string. Setter: Set the value of value attribute of this element. Deleter: Remove value attribute from this element.

Return type:str
width

Getter: Get value of width attribute of this element, as string. If width is not defined, return empty string. Setter: Set the value of width attribute of this element. Deleter: Remove width attribute from this element.

Return type:str
defaultValue

Return text contents of this node and all chid nodes.

When any value is set to this property, all child nodes are removed and new value is set as a text node.

Return type:str
on_event_pre(e)[source]

Set values set on browser before calling event listeners.

Return type:None

Node Collectoin Classes

class wdom.node.NodeList(nodes: typing.Sequence[wdom.node.Node]) → None[source]

Bases: typing.Sequence

Collection of Node objects.

Initialize NodeList by iterable nodes.

length

Return number of nodes in this list.

Return type:int
item(index)[source]

Return item with the index.

If the index is negative number or out of the list, return None.

Return type:Optional[Node]
index(node)[source]

Get index of the node.

Return type:int
class wdom.element.DOMTokenList(owner: typing.Union[wdom.node.Node, typing.Type[_ForwardRef('HTMLElement')]], *args: typing.Union[str, _ForwardRef('DOMTokenList')]) → None[source]

Bases: typing.MutableSequence

Collection of DOM token strings.

DOM token is a string which does not contain spases. This class is mainly used for class list.

Initialize with owner node (maybe type of node) and initial values.

Parameters:
  • owner – Node/Node-class which has this collection.
  • args – space-separated string or iterable of tokens.
length

Get number of DOM token in this list.

Return type:int
add(*tokens)[source]

Add new tokens to list.

Return type:None
remove(*tokens)[source]

Remove tokens from list.

Return type:None
toggle(token)[source]

Add or remove token to/from list.

If token is in this list, the token will be removed. Otherwise add it to list.

Return type:None
item(index)[source]

Return the token of the index.

index must be 0 or positive integer. If index is out of range, return None.

Return type:Optional[str]
insert(index, item)[source]

Not implemented.

Return type:None
contains(token)[source]

Return if the token is in the list or not.

Return type:bool
toString()[source]

Return string representation of this list.

Actually it will be a spase-separated tokens.

Return type:str
class wdom.element.NamedNodeMap(owner: wdom.node.Node) → None[source]

Bases: collections.UserDict

Collection of Attr objects.

Initialize with owner node.

Parameters:owner (Node) – owner node of this object.
length

Return number of Attrs in this collection.

Return type:int
getNamedItem(name)[source]

Get Attr object which has name.

If does not have name attr, return None.

Return type:Optional[Attr]
setNamedItem(item)[source]

Set Attr object in this collection.

Return type:None
removeNamedItem(item)[source]

Set Attr object and return it (if exists).

Return type:Optional[Attr]
item(index)[source]

Return index-th attr node.

Return type:Optional[Attr]
toString()[source]

Return string representation of collections.

Return type:str

Abstract classes

class wdom.node.ParentNode[source]

Bases: wdom.node.AbstractNode

Mixin class for Node classes which can have child nodes.

This class is inherited by Document, DocumentFragment, and Element class.

children

Return list of child nodes.

Currently this is not a live object.

Return type:NodeList[]
firstElementChild

First Element child node.

If this node has no element child, return None.

Return type:Optional[AbstractNode]
lastElementChild

Last Element child node.

If this node has no element child, return None.

Return type:Optional[AbstractNode]
prepend(*nodes)[source]

Insert new nodes before first child node.

Return type:None
append(*nodes)[source]

Append new nodes after last child node.

Return type:None
query(relativeSelectors)[source]

Not Implemented.

Return type:AbstractNode
queryAll(relativeSelectors)[source]

Not Implemented.

Return type:NodeList[]
querySelector(selectors)[source]

Not Implemented.

Return type:AbstractNode
querySelectorAll(selectors)[source]

Not Implemented.

Return type:NodeList[]
class wdom.node.NonDocumentTypeChildNode[source]

Bases: wdom.node.AbstractNode

Mixin class for CharacterData and DocumentType class.

previousElementSibling

Previous Element Node.

If this node has no previous element node, return None.

Return type:Optional[AbstractNode]
nextElementSibling

Next Element Node.

If this node has no next element node, return None.

Return type:Optional[AbstractNode]
class wdom.node.ChildNode[source]

Bases: wdom.node.AbstractNode

Mixin class for Node classes which can have parent node.

This class is inherited by DocumentType, Element, and CharacterData (super class of Text, Comment, and RawHtml) classes.

before(*nodes)[source]

Insert nodes before this node.

If nodes contains str, it will be converted to Text node.

Return type:None
after(*nodes)[source]

Append nodes after this node.

If nodes contains str, it will be converted to Text node.

Return type:None
replaceWith(*nodes)[source]

Replace this node with nodes.

If nodes contains str, it will be converted to Text node.

Return type:None
remove()[source]

Remove this node from the parent node.

Return type:None
class wdom.node.CharacterData(text: str = '', parent: wdom.node.Node = None) → None[source]

Bases: wdom.node.Node, wdom.node.ChildNode, wdom.node.NonDocumentTypeChildNode

Abstract class for classes which wraps text data.

This class is a super class of Text and Comment.

html

Return html representation of this node.

Return type:str
length

Return length of content.

Return type:int
appendData(string)[source]

Add string to end of this node.

Return type:None
insertData(offset, string)[source]

Insert string at offset on this node.

Return type:None
deleteData(offset, count)[source]

Delete data by offset to count letters.

Return type:None
replaceData(offset, count, string)[source]

Replace data from offset to count by string.

Return type:None
childNodes

Return child nodes.

This node can’t have child, so return empty NodeList object.

Return type:NodeList[]
appendChild(node)[source]

Not supported.

Return type:Node
insertBefore(node, ref_node)[source]

Not supported.

Return type:Node
hasChildNodes()[source]

Return false.

Return type:bool
removeChild(node)[source]

Not supported.

Return type:Node
replaceChild(new_child, old_child)[source]

Not supported.

Return type:Node
hasAttributes()[source]

Return false.

Return type:bool

WdomElement class (base class of Tag)

class wdom.web_node.WdomElement(*args: typing.Any, parent: typing.Union[wdom.web_node.WdomElement, NoneType] = None, wdom_id: typing.Union[int, str] = None, **kwargs: typing.Any) → None[source]

Bases: wdom.element.HTMLElement, wdom.event.WebEventTarget

WdomElement class.

This class provides main features to synchronously control browser DOM node.

Additionally, this class provides shortcut properties to handle class attributes.

class_ = ''

str and list of strs are acceptale.

inherit_class = True

Inherit classes defined in super class or not. By default, this variable is True.

wdom_id

Get wdom_id attribute.

This attribute is used to relate python node and browser DOM node.

Return type:str
rimo_id

[Deprecated] Alias to wdom_id.

rimo_id is renamed to wdom_id.

Return type:str
connected

When this instance has any connection, return True.

Return type:bool
classmethod get_class_list()[source]

Get class-level class list, including all super class’s.

Return type:DOMTokenList[]
addClass(*classes)[source]

[Not Standard] Add classes to this node.

Return type:None
hasClass(class_)[source]

[Not Standard] Return if this node has class_ class or not.

Return type:bool
hasClasses()[source]

[Not Standard] Return if this node has any classes or not.

Return type:bool
removeClass(*classes)[source]

[Not Standard] Remove classes from this node.

Return type:None
remove()[source]

Remove this node from parent’s DOM tree.

Return type:None
empty()[source]

Remove all child nodes from this node.

Return type:None
appendChild(child)[source]

Append child node at the last of child nodes.

If this instance is connected to the node on browser, the child node is also added to it.

Return type:Node
insertBefore(child, ref_node)[source]

Insert new child node before the reference child node.

If the reference node is not a child of this node, raise ValueError. If this instance is connected to the node on browser, the child node is also added to it.

Return type:Node
removeChild(child)[source]

Remove the child node from this node.

If the node is not a child of this node, raise ValueError.

Return type:Node
replaceChild(new_child, old_child)[source]

Replace child nodes.

Return type:Node
getBoundingClientRect()[source]

Get size of this node on browser.

Return type:None
textContent

Return text contents of this node and all chid nodes.

When any value is set to this property, all child nodes are removed and new value is set as a text node.

Return type:str
innerHTML

Return HTML representation of child nodes.

Return type:str
html_noid

Get html representation of this node without wdom_id.

Return type:str
click()[source]

Send click event.

Return type:None
exec(script)[source]

Execute JavaScript on the related browser node.

Return type:None
show()[source]

[Not Standard] Show this node on browser.

Return type:None
hide()[source]

[Not Standard] Hide this node on browser.

Return type:None