DomConvenienceFunctions

Undocumented in source.

Members

Functions

addChild
Element addChild(string tagName, string childInfo, string childInfo2)

convenience function to quickly add a tag with some text or other relevant info (for example, it's a src for an <img> element instead of inner text)

addChild
Element addChild(Element e)
Undocumented in source. Be warned that the author may not have intended to support it.
addChild
Element addChild(string tagName, Element firstChild, string info2)

.

addChild
Element addChild(string tagName, Html innerHtml, string info2)
Undocumented in source.
addChildren
void addChildren(T t)

Convenience function to append text intermixed with other children. For example: div.addChildren("You can visit my website by ", new Link("mysite.com", "clicking here"), "."); or div.addChildren("Hello, ", user.name, "!"); See also: appendHtml. This might be a bit simpler though because you don't have to think about escaping.

addClass
Element addClass(string c)

Adds a string to the class attribute. The class attribute is used a lot in CSS.

addSibling
Element addSibling(string tagName, string childInfo, string childInfo2)

Another convenience function. Adds a child directly after the current one, returning the new child.

addSibling
Element addSibling(Element e)
Undocumented in source. Be warned that the author may not have intended to support it.
appendChildren
void appendChildren(Element[] children)

.

classNames
string[] classNames()

Splits the className into an array of each class given

firstInnerText
string firstInnerText()

Fetches the first consecutive nodes, if text nodes, concatenated together

hasClass
bool hasClass(string c)

Returns whether the given class appears in this element.

removeAllChildren
void removeAllChildren()

Removes all inner content from the tag; all child text and elements are gone.

removeClass
Element removeClass(string c)

Removes a particular class name.

removeFromTree
Element removeFromTree()

shorthand for this.parentNode.removeChild(this) with parentNode null check if the element already isn't in a tree, it does nothing.

reparent
void reparent(Element newParent)

.

replaceWith
Element replaceWith(Element e)

Replaces this element with something else in the tree.

requireElementById
SomeElementType requireElementById(string id, string file, size_t line)

Calls getElementById, but throws instead of returning null if the element is not found. You can also ask for a specific subclass of Element to dynamically cast to, which also throws if it cannot be done.

requireSelector
SomeElementType requireSelector(string selector, string file, size_t line)

ditto but with selectors instead of ids

stripOut
void stripOut()

Strips this tag out of the document, putting its inner html as children of the parent.

wrapIn
Element wrapIn(Element what)

Wraps this element inside the given element. It's like this.replaceWith(what); what.appendchild(this);

Properties

classes
string[] classes [@property getter]

get all the classes on this element

directText
string directText [@property getter]

Returns the text directly under this element, not recursively like innerText.

directText
string directText [@property setter]

Sets the direct text, keeping the same place.

Meta