Constructor
new ElementWrapper(elementType)
Construct the wrapper. If a tag name is provided, a new element is created, otherwise the provided element is wrapped.
Parameters:
| Name | Type | Description |
|---|---|---|
elementType |
string | HTMLElement | Tag name or the actual element to be wrapped. |
- Source:
Members
(protected, readonly) _element :Element
The wrapped element. This is protected and is only intended for use by the domTools module.
Type:
- Element
- Source:
(readonly) classList :DOMTokenList
The classList.
Type:
- DOMTokenList
- Source:
- See:
className :string
The class name.
Type:
- string
- Source:
- See:
(readonly) offsetHeight :number
Element's offset height.
Type:
- number
- Source:
(readonly) offsetWidth :number
Element's offset width.
Type:
- number
- Source:
(readonly) parentElement :string
The parent element.
Type:
- string
- Source:
- See:
(readonly) style :CSSStyleProperties
Element's style.
Type:
- CSSStyleProperties
- Source:
- See:
Methods
addEventListener(eventType, listener, optionsOrUseCapture)
Add event listener.
Parameters:
| Name | Type | Description |
|---|---|---|
eventType |
string | Event type to listen to |
listener |
function | Object | Handler of the event |
optionsOrUseCapture |
Object | boolean | Additional options |
- Source:
- See:
appendChild(child)
Append child.
Parameters:
| Name | Type | Description |
|---|---|---|
child |
Element | ElementWrapper | Element to append |
- Source:
- See:
appendTo(parentElement)
Append to a parent element. Note, if it is already a child, this call is ignored. This method is provided to allow callers to adust hierarchies without needing access to the protected wrapped element. Note that the method will silently return if parentElement is not provided.
Parameters:
| Name | Type | Description |
|---|---|---|
parentElement |
module:hcje/domTools~ElementWrapper | HTMLElement | The element to which the wrapped element should be appended. |
- Source:
blur()
Remove the element's focus.
- Source:
focus()
Give the element focus.
- Source:
remove()
Remove the element from the DOM. The instance wrapping the element still exists if a reference to it is maintained.
- Source:
removeAllChildren()
Remove all children.
- Source:
(protected, static) _toElement(item) → {Element}
Get a wrapper's to underlying element.
Parameters:
| Name | Type | Description |
|---|---|---|
item |
Element | ElementWrapper | The object to return as an Element. |
- Source:
Returns:
- Type
- Element