Generally, you don't want to call this yourself - use Element.make or document.createElement instead.
Convenience constructor when you don't care about the parentDocument. Note this might break things on the document. Note also that without a parent document, elements are always in strict, case-sensitive mode.
Returns a helper object to work with classes, just like javascript.
Returns elements that match the given CSS selector
Fetch the inside text, with all tags stripped out.
These properties are useless in most cases, but if you write a layout engine on top of this lib, they may be good +////ditt
Family of convenience functions 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). They forward to Element.make then calls appendChild.
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.
Adds a string to the class attribute. The class attribute is used a lot in CSS.
Adds a form field to this element, normally a <input> but type can also be "textarea".
Another convenience function. Adds a child directly after the current one, returning the new child.
Adds a form field to this element, normally a <input> but type can also be "textarea".
Appends the given element to this one. If it already has a parent, it is removed from that tree and moved to this one.
Appends the list of children to this element.
Appends the given html to the element, returning the elements appended
Adds a sibling element before or after this one in the dom.
Appends the given to the node.
Clones the node. If deepClone is true, clone all inner tags too. If false, only do this tag (and its attributes), but it will have no contents.
Returns itself or the closest parent that matches the given selector, or null if none found
Fetches the first consecutive text nodes concatenated together.
Gets the given attribute value, or null if the attribute is not set.
Searches this element and the tree of elements under it for one matching the given id attribute.
Returns child elements that have the given class name or tag name.
Returns if the attribute exists.
Returns whether the given class appears in this element.
Inserts the given element what as a sibling of the this element, after the element where in the parent node.
Inserts the second element to this node, right before the first param
Inserts a child under this element after the element where.
Returns if the node would be printed to string as <tag /> or <tag></tag>. In other words, if it has no non-empty text nodes and no element nodes. Please note that whitespace text nodes are NOT considered empty; Html("<tag> </tag>").isEmpty == false.
If the element matches the given selector. Previously known as matchesSelector.
the next or previous element you would encounter if you were reading it in the source. May be a text node or other special non-tag object if you enabled them.
W3C DOM interface. Only really meaningful on TextNode instances, but the interface is present on the base class.
Returns a collection of elements by selector. See: Document.opIndex
Returns the child node with the particular index.
If a matching selector is found, it returns that Element. Otherwise, the returned object returns null for all methods.
Returns the parent node in the tree this element is attached to.
Puts the current element first in our children list. The given element must not have a parent already.
Adds a sibling element before or after this one in the dom.
the next or previous element you would encounter if you were reading it in the source. May be a text node or other special non-tag object if you enabled them.
Returns a child element that matches the given selector.
Returns elements that match the given CSS selector
Removes all inner content from the tag; all child text and elements are gone.
Removes the given attribute from the element.
Removes the given child from this list.
This removes all the children from this element, returning the old list.
Removes a particular class name.
shorthand for this.parentNode.removeChild(this) with parentNode null check if the element already isn't in a tree, it does nothing.
Removes this element form its current parent and appends it to the given newParent.
Replaces the element find, which must be a child of this, with the element replace, which must have no parent.
Replaces the given element with a whole group.
Replaces this element with something else in the tree.
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.
ditto but with selectors instead of ids
Sets an attribute. Returns this for easy chaining
Reparents all the child elements of e to this, leaving e childless.
Strips this tag out of the document, putting its inner html as children of the parent.
swaps one child for a new thing. Returns the old child which is now parentless.
Writes out with formatting. Be warned: formatting changes the contents. Use ONLY for eyeball debugging.
Turns the whole element, including tag, attributes, and children, into a string which could be pasted into an XML file.
Gets the element's visible text, similar to how it would look assuming the document was HTML being displayed by a browser. This means it will attempt whitespace normalization (unless it is a <pre> tag), add \n characters for <br> tags, and I reserve the right to make it process additional css and tags in the future.
Wraps this element inside the given element. It's like this.replaceWith(what); what.appendchild(this);
This is the actual implementation used by toString. You can pass it a preallocated buffer to save some time. Note: the ordering of attributes in the string is undefined. Returns the string it creates.
Gives dot/opIndex access to attributes
Returns child elements which are of a tag type (excludes text, comments, etc.).
Returns the element's children.
Returns a helper object to work with classes, just like javascript.
Gets or sets the class attribute's contents. Returns an empty string if it has no class.
get all the classes on this element
This is a full clone of the element. Alias for cloneNode(true) now. Don't extend it.
Don't use this. It can try to parse out the style element but it isn't complete and if I get back to it, it won't be for a while.
HTML5's dataset property. It is an alternate view into attributes with the data- prefix. Given <a data-my-property="cool" />, we get assert(a.dataset.myProperty == "cool");
Returns the text directly under this element.
Sets the direct text, without modifying other child nodes.
Returns the first child of this element. If it has no children, returns null. Remember, text nodes are children too.
Returns a string containing all child elements, formatted such that it could be pasted into an XML file.
Takes some html and replaces the element's children with the tree made from the string.
This sets the inner content of the element *without* trying to parse it. You can inject any code in there; this serves as an escape hatch from the dom.
Fetch the inside text, with all tags stripped out.
Sets the inside text, replacing all children. You don't have to worry about entity encoding.
Returns the last child of the element, or null if it has no children. Remember, text nodes are children too.
Returns the next or previous sibling that is not a text node. Please note: the behavior with comments is subject to change. Currently, it will return a comment or other nodes if it is in the tree (if you enabled it with Document.enableAddingSpecialTagsToDom or Document.parseSawComment) and not if you didn't, but the implementation will probably change at some point to skip them regardless.
Returns the next or previous sibling matching the tagName filter. The default filter of null will return the first sibling it sees, even if it is a comment or text node, or anything else. A filter of "*" will match any tag with a name. Otherwise, the string must match the tagName of the sibling you want to find.
.
Provides easy access to common HTML attributes, object style.
Old access to attributes. Use attrs instead.
Replaces this node with the given html string, which is parsed
Returns all the html for this element, including the tag itself.
Strips this node out of the document, replacing it with the given text
Same result as innerText; the tag with all inner tags stripped out
Get the parent Document object that contains this element. It may be null, so remember to check for that.
Returns the next or previous sibling that is not a text node. Please note: the behavior with comments is subject to change. Currently, it will return a comment or other nodes if it is in the tree (if you enabled it with Document.enableAddingSpecialTagsToDom or Document.parseSawComment) and not if you didn't, but the implementation will probably change at some point to skip them regardless.
Returns the next or previous sibling matching the tagName filter. The default filter of null will return the first sibling it sees, even if it is a comment or text node, or anything else. A filter of "*" will match any tag with a name. Otherwise, the string must match the tagName of the sibling you want to find.
Provides both string and object style (like in Javascript) access to the style attribute.
This sets the style attribute with a string.
Returns a lazy range of all its children, recursively.
Convenience function to try to do the right thing for HTML. This is the main way I create elements.
The object classList returns.
This is where the attributes are actually stored. You should use getAttribute, setAttribute, and hasAttribute instead.
These properties are useless in most cases, but if you write a layout engine on top of this lib, they may be good +////ditt
These properties are useless in most cases, but if you write a layout engine on top of this lib, they may be good +////ditt
These properties are useless in most cases, but if you write a layout engine on top of this lib, they may be good +////ditt
These properties are useless in most cases, but if you write a layout engine on top of this lib, they may be good +////ditt
These properties are useless in most cases, but if you write a layout engine on top of this lib, they may be good +////ditt
These properties are useless in most cases, but if you write a layout engine on top of this lib, they may be good +////ditt
These properties are useless in most cases, but if you write a layout engine on top of this lib, they may be good +////ditt
The name of the tag. Remember, changing this doesn't change the dynamic type of the object.
These properties are useless in most cases, but if you write a layout engine on top of this lib, they may be good +////ditt
This represents almost everything in the DOM and offers a lot of inspection and manipulation functions. Element, or its subclasses, are what makes the dom tree.