Node interfaces/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
-
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 argumentElement
, 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:
-
getElementsByClassName
(class_name)¶ Get child nodes which has
class_name
class attribute.Return type: NodeList
[]
-
doctype
¶ Return DocumentType element of this document.
Return type: DocumentType
-
characterSet
¶ Get/Set charset of this document.
Return type: str
-
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
-
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 argumentElement
, 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:
-
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 toposition
.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
]
-
id
¶ Getter: Get value of
id
attribute of this element, as string. If id is not defined, return empty string. Setter: Set the value ofid
attribute of this element. Deleter: Removeid
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
]
Getter: Return True if this element has
hidden
attribute. Otherwise return False. Setter: If True, addhidden
attribute to this element. Otherwise removehidden
. Deleter: Removehidden
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 oftitle
attribute of this element. Deleter: Removetitle
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 oftype
attribute of this element. Deleter: Removetype
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. -
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 ofhref
attribute of this element. Deleter: Removehref
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 ofname
attribute of this element. Deleter: Removename
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 ofrel
attribute of this element. Deleter: Removerel
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 ofsrc
attribute of this element. Deleter: Removesrc
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 oftarget
attribute of this element. Deleter: Removetarget
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, adddisabled
attribute to this element. Otherwise removedisabled
. Deleter: Removedisabled
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 ofname
attribute of this element. Deleter: Removename
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 ofvalue
attribute of this element. Deleter: Removevalue
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 ofname
attribute of this element. Deleter: Removename
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 ofheight
attribute of this element. Deleter: Removeheight
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 ofname
attribute of this element. Deleter: Removename
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 ofsrc
attribute of this element. Deleter: Removesrc
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 oftarget
attribute of this element. Deleter: Removetarget
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 ofwidth
attribute of this element. Deleter: Removewidth
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).
-
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, addchecked
attribute to this element. Otherwise removechecked
. Deleter: Removechecked
attribute from this element.Return type: bool
-
disabled
¶ Getter: Return True if this element has
disabled
attribute. Otherwise return False. Setter: If True, adddisabled
attribute to this element. Otherwise removedisabled
. Deleter: Removedisabled
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 ofheight
attribute of this element. Deleter: Removeheight
attribute from this element.Return type: str
-
multiple
¶ Getter: Return True if this element has
multiple
attribute. Otherwise return False. Setter: If True, addmultiple
attribute to this element. Otherwise removemultiple
. Deleter: Removemultiple
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 ofname
attribute of this element. Deleter: Removename
attribute from this element.Return type: str
-
readonly
¶ Getter: Return True if this element has
readonly
attribute. Otherwise return False. Setter: If True, addreadonly
attribute to this element. Otherwise removereadonly
. Deleter: Removereadonly
attribute from this element.Return type: bool
-
required
¶ Getter: Return True if this element has
required
attribute. Otherwise return False. Setter: If True, addrequired
attribute to this element. Otherwise removerequired
. Deleter: Removerequired
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 ofsrc
attribute of this element. Deleter: Removesrc
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 ofvalue
attribute of this element. Deleter: Removevalue
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 ofwidth
attribute of this element. Deleter: Removewidth
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, adddisabled
attribute to this element. Otherwise removedisabled
. Deleter: Removedisabled
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 oflabel
attribute of this element. Deleter: Removelabel
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, adddefaultSelected
attribute to this element. Otherwise removedefaultSelected
. Deleter: RemovedefaultSelected
attribute from this element.Return type: bool
-
disabled
¶ Getter: Return True if this element has
disabled
attribute. Otherwise return False. Setter: If True, adddisabled
attribute to this element. Otherwise removedisabled
. Deleter: Removedisabled
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 oflabel
attribute of this element. Deleter: Removelabel
attribute from this element.Return type: str
-
selected
¶ Getter: Return True if this element has
selected
attribute. Otherwise return False. Setter: If True, addselected
attribute to this element. Otherwise removeselected
. Deleter: Removeselected
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 ofvalue
attribute of this element. Deleter: Removevalue
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, addasync
attribute to this element. Otherwise removeasync
. Deleter: Removeasync
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 ofcharset
attribute of this element. Deleter: Removecharset
attribute from this element.Return type: str
-
defer
¶ Getter: Return True if this element has
defer
attribute. Otherwise return False. Setter: If True, adddefer
attribute to this element. Otherwise removedefer
. Deleter: Removedefer
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 ofsrc
attribute of this element. Deleter: Removesrc
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).
-
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, adddisabled
attribute to this element. Otherwise removedisabled
. Deleter: Removedisabled
attribute from this element.Return type: bool
-
multiple
¶ Getter: Return True if this element has
multiple
attribute. Otherwise return False. Setter: If True, addmultiple
attribute to this element. Otherwise removemultiple
. Deleter: Removemultiple
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 ofname
attribute of this element. Deleter: Removename
attribute from this element.Return type: str
-
required
¶ Getter: Return True if this element has
required
attribute. Otherwise return False. Setter: If True, addrequired
attribute to this element. Otherwise removerequired
. Deleter: Removerequired
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 ofsize
attribute of this element. Deleter: Removesize
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 ofvalue
attribute of this element. Deleter: Removevalue
attribute from this element.Return type: str
-
-
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, adddisabled
attribute to this element. Otherwise removedisabled
. Deleter: Removedisabled
attribute from this element.Return type: bool
-
scoped
¶ Getter: Return True if this element has
scoped
attribute. Otherwise return False. Setter: If True, addscoped
attribute to this element. Otherwise removescoped
. Deleter: Removescoped
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, adddisabled
attribute to this element. Otherwise removedisabled
. Deleter: Removedisabled
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 ofheight
attribute of this element. Deleter: Removeheight
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 ofname
attribute of this element. Deleter: Removename
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 ofsrc
attribute of this element. Deleter: Removesrc
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 ofvalue
attribute of this element. Deleter: Removevalue
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 ofwidth
attribute of this element. Deleter: Removewidth
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
-
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
-
-
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
-
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
-
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 hasname
.If does not have
name
attr, return None.Return type: Optional
[Attr
]
-
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.
-
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
]
-
query
(relativeSelectors)[source]¶ Not Implemented.
Return type: AbstractNode
-
querySelector
(selectors)[source]¶ Not Implemented.
Return type: AbstractNode
-
-
class
wdom.node.
NonDocumentTypeChildNode
[source]¶ Bases:
wdom.node.AbstractNode
Mixin class for
CharacterData
andDocumentType
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
-
-
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
andComment
.-
html
¶ Return html representation of this node.
Return type: str
-
length
¶ Return length of content.
Return type: int
-
replaceData
(offset, count, string)[source]¶ Replace data from offset to count by string.
Return type: None
-
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
[]
-
hasClass
(class_)[source]¶ [Not Standard] Return if this node has
class_
class or not.Return type: bool
-
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
-
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
-