## Modules
domv
domv/lib/Component

This is the super class for your components.

It contains a handful of methods that simplify using the DOM.

domv/lib/Exception

The base class for any exception that originates from this library

domv/lib/HtmlDocument

Represents a full document in html, including the root node html.

## domv **Author:** Joris van der Wel * [domv](#module_domv) * _static_ * [.NodeType](#module_domv.NodeType) : enum * [.Component](#module_domv.Component) : [Component](#exp_module_domv/lib/Component--Component) * [.HtmlDocument](#module_domv.HtmlDocument) : [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) * [.Exception](#module_domv.Exception) : [Exception](#exp_module_domv/lib/Exception--Exception) * [.isSupported(document, [checkAll])](#module_domv.isSupported) ⇒ boolean * [.isParseHTMLDocumentSupported()](#module_domv.isParseHTMLDocumentSupported) ⇒ boolean * [.mayContainChildren(node, [doThrow])](#module_domv.mayContainChildren) ⇒ boolean * [.wrap(node_, [ComponentConstructor], ...constructorArguments)](#module_domv.wrap) ⇒ [Component](#exp_module_domv/lib/Component--Component) | [Array.<Component>](#exp_module_domv/lib/Component--Component) * [.unlive(nodeList)](#module_domv.unlive) ⇒ Array * [.create(document_, nodeName, className, ...content)](#module_domv.create) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.shorthand(document_, [tagName_], ...initialAttributes)](#module_domv.shorthand) ⇒ domv/lib/CreateShortHand * [.text(document_, ...text)](#module_domv.text) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.createHtmlDomDocument([minimal])](#module_domv.createHtmlDomDocument) ⇒ [Document](#external_Document) * [.parseHTMLDocument(markup, ownerDocument)](#module_domv.parseHTMLDocument) ⇒ [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) * [.parseHTMLSnippit(ownerDocument, markup)](#module_domv.parseHTMLSnippit) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.cssStringEscape([str], [wrapInQuotes])](#module_domv.cssStringEscape) ⇒ String * [.isLeftMouseButton(event)](#module_domv.isLeftMouseButton) ⇒ boolean * _inner_ * [~domv/lib/CreateShortHand](#module_domv..domv/lib/CreateShortHand) : function * [~Node](#external_Node) * [~Element](#external_Element) * [~Document](#external_Document) * [.createEvent()](#external_Document+createEvent) * [~CSSStyleDeclaration](#external_CSSStyleDeclaration) * [~Event](#external_Event) * [~ServerResponse](#external_ServerResponse) ### domv.NodeType : enum All of the valid node types in DOM (excluding the ones that are deprecated). **Kind**: static enum property of [domv](#module_domv) **Properties** | Name | Type | Default | | --- | --- | --- | | ELEMENT | number | 1 | | TEXT | number | 3 | | PROCESSING_INSTRUCTION | number | 7 | | COMMENT | number | 8 | | DOCUMENT | number | 9 | | DOCUMENT_TYPE | number | 10 | | DOCUMENT_FRAGMENT | number | 11 | ### domv.Component : [Component](#exp_module_domv/lib/Component--Component) **Kind**: static constant of [domv](#module_domv) ### domv.HtmlDocument : [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Kind**: static constant of [domv](#module_domv) ### domv.Exception : [Exception](#exp_module_domv/lib/Exception--Exception) **Kind**: static constant of [domv](#module_domv) ### domv.isSupported(document, [checkAll]) ⇒ boolean Test if the current environment / browser / DOM library supports everything that is needed for the domv library. **Kind**: static method of [domv](#module_domv) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) For invalid arguments | Param | Type | Default | Description | | --- | --- | --- | --- | | document | [Document](#external_Document) | | | | [checkAll] | boolean | false | If true, also check [isParseHTMLDocumentSupported()](#module_domv.isParseHTMLDocumentSupported) | ### domv.isParseHTMLDocumentSupported() ⇒ boolean Test if the current environment / browser / DOM library supports parsing the markup of an entire html document (including doctype, html, head, tags etc). **Kind**: static method of [domv](#module_domv) **See**: [parseHTMLDocument()](#module_domv.parseHTMLDocument) ### domv.mayContainChildren(node, [doThrow]) ⇒ boolean Is the given node or component able to have children?. **Kind**: static method of [domv](#module_domv) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If doThrow=true | Param | Type | Default | Description | | --- | --- | --- | --- | | node | [domv/lib/Component](#module_domv/lib/Component) | [Node](#external_Node) | | | | [doThrow] | boolean | false | If true, throw instead of returning false upon failure. | ### domv.wrap(node_, [ComponentConstructor], ...constructorArguments) ⇒ [Component](#exp_module_domv/lib/Component--Component) | [Array.<Component>](#exp_module_domv/lib/Component--Component) Wraps a plain DOM Node so that you can use the same API as you would on a Component. If you pass a NodeList, an array (that is not live) with Component's will be returned. Passing a falsy value will also return a falsy value instead of a Component **Kind**: static method of [domv](#module_domv) **Returns**: [Component](#exp_module_domv/lib/Component--Component) | [Array.<Component>](#exp_module_domv/lib/Component--Component) - Only null if "node" was also null **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If an unsupported argument is passed, or if more than 10 constructor arguments have been passed | Param | Type | Default | Description | | --- | --- | --- | --- | | node_ | [Node](#external_Node) | [Array.<Node>](#external_Node) | | | | [ComponentConstructor] | function | module:domv/lib/Component | The constructor to use to wrap the given Node, by default the Node is wrapped in a plain Component, but it is also possible to specify your own constructor. The first argument is always the node being wrapped. | | ...constructorArguments | \* | | Further arguments to be passed to the constructor | **Example** ```js domv.wrap(document.body).prependChild(...); ``` **Example** ```js domv.wrap(someNode, MyPictureGallery).addPicture(...); ``` ### domv.unlive(nodeList) ⇒ Array Returns an array copy of a NodeList so that it is no longer live. This makes it easier to properly modify the DOM while traversing a node list. The actual content of the array is identical (the nodes are not wrapped) **Kind**: static method of [domv](#module_domv) | Param | Type | Description | | --- | --- | --- | | nodeList | \* | Any array like object. | **Example** ```js var list = require('domv').unlive(document.getElementsByTagName('*')); ``` ### domv.create(document_, nodeName, className, ...content) ⇒ [Component](#exp_module_domv/lib/Component--Component) Convenient function to create a wrapped Node including its attributes (for elements). **Kind**: static method of [domv](#module_domv) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) For invalid arguments | Param | Type | Description | | --- | --- | --- | | document_ | [Document](#external_Document) | | | nodeName | string | | | className | string | [Node](#external_Node) | [domv/lib/Component](#module_domv/lib/Component) | Object.<string, string> |

If a string is passed, and the nodeName represents an element tag, the string is set as the class attribute. If not an element, the string is appended to the node data.

Otherwise the argument is parsed using [parseShorthandArgument](#module_domv/lib/Component--Component+parseShorthandArgument)

| | ...content | string | [Node](#external_Node) | [domv/lib/Component](#module_domv/lib/Component) | Object.<string, string> | Parsed using [parseShorthandArgument](#module_domv/lib/Component--Component+parseShorthandArgument) | **Example** ```js var wrappedDiv = require('domv').create(document, 'div', 'myDiv', 'This is my div!', {'data-test': 'foo'}); console.log(wrappedDiv.outerNode.outerHTML); //
This is my div!
``` ### domv.shorthand(document_, [tagName_], ...initialAttributes) ⇒ domv/lib/CreateShortHand Generate a short hand function wich lets you quickly create a wrapped Element including its attributes. **Kind**: static method of [domv](#module_domv) | Param | Type | Default | Description | | --- | --- | --- | --- | | document_ | [Document](#external_Document) | | | | [tagName_] | string | "'div'" | | | ...initialAttributes | string | Object.<string, string> | |

If a string is passed, a text node is appended.

If a node or component is passed, it is simply appended.

If an object of key value pairs is passed, it sets those as attributes. (see [attr](#module_domv/lib/Component--Component+attr))

| **Example** ```js var a = require('domv').shorthand(document, 'a'); var link = a('readmore', {'href': something()}, 'Click here to readmore!'); // Click here to readmore! ``` ### domv.text(document_, ...text) ⇒ [Component](#exp_module_domv/lib/Component--Component) Creates a new wrapped TextNode. **Kind**: static method of [domv](#module_domv) | Param | Type | Description | | --- | --- | --- | | document_ | [Document](#external_Document) | | | ...text | string | Extra arguments will be joined using a space | **Example** ```js var wrappedDiv = require('domv').create(document, 'div'); var wrappedText = require('domv').text(document, 'Hi!'); wrappedDiv.appendChild(wrappedText); console.log(wrappedDiv.outerNode.outerHTML); //
Hi!
``` ### domv.createHtmlDomDocument([minimal]) ⇒ [Document](#external_Document) Create a new Document Node, including html, head, title and body tags. **Kind**: static method of [domv](#module_domv) | Param | Type | Default | Description | | --- | --- | --- | --- | | [minimal] | Boolean | false | If true, only a doctype and a element is created. | ### domv.parseHTMLDocument(markup, ownerDocument) ⇒ [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) Parse the given html markup text as a complete html docuemnt and return the outer "html" node. Optionally an ownerDocument may be given which will specify what Document the new nodes belong to. **Kind**: static method of [domv](#module_domv) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If a dom html parser implementation is not available | Param | Type | | --- | --- | | markup | string | | ownerDocument | [Document](#external_Document) | ### domv.parseHTMLSnippit(ownerDocument, markup) ⇒ [Component](#exp_module_domv/lib/Component--Component) Parse the given html markup text and return a (wrapped) DocumentFragment containing the nodes the markup represents. The given markup must not be a full html document, otherwise the html, head and body nodes will not be present, only their content. An ownerDocument must be given which will specify what Document the new nodes belong to. **Kind**: static method of [domv](#module_domv) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If a dom html parser implementation is not available | Param | Type | | --- | --- | | ownerDocument | [Document](#external_Document) | | markup | string | ### domv.cssStringEscape([str], [wrapInQuotes]) ⇒ String Escape a string so that you can use it as a CSS String, such as a selector. **Kind**: static method of [domv](#module_domv) **See**: [http://www.w3.org/TR/CSS21/syndata.html#strings](http://www.w3.org/TR/CSS21/syndata.html#strings) | Param | Type | Default | Description | | --- | --- | --- | --- | | [str] | String | 'undefined' | | | [wrapInQuotes] | boolean | true | If true, surround the result with quotes: "something" | **Example** ```js myComponent.selectorAll('a[href=' + domv.cssStringEscape(somevar) + ']'); ``` ### domv.isLeftMouseButton(event) ⇒ boolean Given that 'event' is a mouse event, is the left mouse button being held down?. **Kind**: static method of [domv](#module_domv) **Returns**: boolean - True if the left mouse button is down **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) For invalid arguments | Param | Type | | --- | --- | | event | [Event](#external_Event) | ### domv~domv/lib/CreateShortHand : function **Kind**: inner typedef of [domv](#module_domv) | Param | Type | Description | | --- | --- | --- | | className | string | | | [...content] | string | [Node](#external_Node) | [domv/lib/Component](#module_domv/lib/Component) | Object.<string, string> |

If a string is passed, a text node is appended.

If a node or component is passed, it is simply appended.

If an object of key value pairs is passed, it sets those as attributes. (see [attr](#module_domv/lib/Component--Component+attr))

| ### domv~Node

The Node interface is the primary datatype for the entire Document Object Model. It represents a single node in the document tree. While all objects implementing the Node interface expose methods for dealing with children, not all objects implementing the Node interface may have children. For example, Text nodes may not have children, and adding children to such nodes results in a DOMException being raised.

The attributes nodeName, nodeValue and attributes are included as a mechanism to get at node information without casting down to the specific derived interface. In cases where there is no obvious mapping of these attributes for a specific nodeType (e.g., nodeValue for an Element or attributes for a Comment), this returns null. Note that the specialized interfaces may contain additional and more convenient mechanisms to get and set the relevant information.

**Kind**: inner external of [domv](#module_domv) **See** - [https://developer.mozilla.org/en-US/docs/Web/API/Node](https://developer.mozilla.org/en-US/docs/Web/API/Node) - [http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-1950641247](http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-1950641247) ### domv~Element The Element interface represents an element in an HTML or XML document. Elements may have attributes associated with them; since the Element interface inherits from Node, the generic Node interface attribute attributes may be used to retrieve the set of all attributes for an element. There are methods on the Element interface to retrieve either an Attr object by name or an attribute value by name. In XML, where an attribute value may contain entity references, an Attr object should be retrieved to examine the possibly fairly complex sub-tree representing the attribute value. On the other hand, in HTML, where all attributes have simple string values, methods to directly access an attribute value can safely be used as a convenience. **Kind**: inner external of [domv](#module_domv) **See** - [https://developer.mozilla.org/en-US/docs/Web/API/Element](https://developer.mozilla.org/en-US/docs/Web/API/Element) - [http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-745549614](http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-745549614) ### domv~Document

The Document interface represents the entire HTML or XML document. Conceptually, it is the root of the document tree, and provides the primary access to the document's data.

Since elements, text nodes, comments, processing instructions, etc. cannot exist outside the context of a Document, the Document interface also contains the factory methods needed to create these objects. The Node objects created have a ownerDocument attribute which associates them with the Document within whose context they were created.

**Kind**: inner external of [domv](#module_domv) **See** - [https://developer.mozilla.org/en-US/docs/Web/API/document](https://developer.mozilla.org/en-US/docs/Web/API/document) - [http://www.w3.org/TR/DOM-Level-3-Core/core.html#i-Document](http://www.w3.org/TR/DOM-Level-3-Core/core.html#i-Document) #### document.createEvent() Creates an event object of the type specified. Returns the newly created object. **Kind**: instance method of [Document](#external_Document) **See** - [https://developer.mozilla.org/en-US/docs/Web/API/document.createEvent](https://developer.mozilla.org/en-US/docs/Web/API/document.createEvent) - [http://www.w3.org/TR/DOM-Level-3-Events/#widl-DocumentEvent-createEvent](http://www.w3.org/TR/DOM-Level-3-Events/#widl-DocumentEvent-createEvent) ### domv~CSSStyleDeclaration

The CSSStyleDeclaration interface represents a CSS declaration block, including its underlying state, where this underlying state depends upon the source of the CSSStyleDeclaration instance.

**Kind**: inner external of [domv](#module_domv) **See** - [https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration) - [http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface](http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface) ### domv~Event The Event interface is used to provide contextual information about an event to the handler processing the event. An object which implements the Event interface is generally passed as the first parameter to an event handler. More specific context information is passed to event handlers by deriving additional interfaces from Event which contain information directly relating to the type of event they accompany. These derived interfaces are also implemented by the object passed to the event listener. **Kind**: inner external of [domv](#module_domv) **See** - [https://developer.mozilla.org/en-US/docs/Web/API/Event](https://developer.mozilla.org/en-US/docs/Web/API/Event) - [http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-Event](http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-Event) ### domv~ServerResponse This object is created internally by a HTTP server (node.js), not by the user. It is passed as the second parameter to the 'request' event. The response implements the Writable Stream interface **Kind**: inner external of [domv](#module_domv) **See**: [http://nodejs.org/api/http.html#http_class_http_serverresponse](http://nodejs.org/api/http.html#http_class_http_serverresponse) ## domv/lib/Component This is the super class for your components.

It contains a handful of methods that simplify using the DOM.

**Author:** Joris van der Wel * [domv/lib/Component](#module_domv/lib/Component) * [Component](#exp_module_domv/lib/Component--Component) ⏏ * [new Component(node, [defaultNodeName], [wrapDocument])](#new_module_domv/lib/Component--Component_new) * [.document](#module_domv/lib/Component--Component+document) : [Document](#external_Document) * [.outerNode](#module_domv/lib/Component--Component+outerNode) : [Node](#external_Node) * [.outerNodeWrapped](#module_domv/lib/Component--Component+outerNodeWrapped) : [Component](#exp_module_domv/lib/Component--Component) * [.innerNode](#module_domv/lib/Component--Component+innerNode) : [Node](#external_Node) * [.innerNodeWrapped](#module_domv/lib/Component--Component+innerNodeWrapped) : [Component](#exp_module_domv/lib/Component--Component) * [.style](#module_domv/lib/Component--Component+style) : [CSSStyleDeclaration](#external_CSSStyleDeclaration) * [.children](#module_domv/lib/Component--Component+children) : [Array.<Component>](#exp_module_domv/lib/Component--Component) * [.childElementCount](#module_domv/lib/Component--Component+childElementCount) : Number * [.childrenIndex](#module_domv/lib/Component--Component+childrenIndex) : int * [.childNodes](#module_domv/lib/Component--Component+childNodes) : [Array.<Component>](#exp_module_domv/lib/Component--Component) * [.childNodeCount](#module_domv/lib/Component--Component+childNodeCount) : Number * [.childNodesIndex](#module_domv/lib/Component--Component+childNodesIndex) : int * [.isEmpty](#module_domv/lib/Component--Component+isEmpty) : boolean * [.firstChild](#module_domv/lib/Component--Component+firstChild) : [Component](#exp_module_domv/lib/Component--Component) * [.lastChild](#module_domv/lib/Component--Component+lastChild) : [Component](#exp_module_domv/lib/Component--Component) * [.firstElementChild](#module_domv/lib/Component--Component+firstElementChild) : [Component](#exp_module_domv/lib/Component--Component) * [.lastElementChild](#module_domv/lib/Component--Component+lastElementChild) : [Component](#exp_module_domv/lib/Component--Component) * [.nextSibling](#module_domv/lib/Component--Component+nextSibling) : [Component](#exp_module_domv/lib/Component--Component) * [.previousSibling](#module_domv/lib/Component--Component+previousSibling) : [Component](#exp_module_domv/lib/Component--Component) * [.nextElementSibling](#module_domv/lib/Component--Component+nextElementSibling) : [Component](#exp_module_domv/lib/Component--Component) * [.previousElementSibling](#module_domv/lib/Component--Component+previousElementSibling) : [Component](#exp_module_domv/lib/Component--Component) * [.parentNode](#module_domv/lib/Component--Component+parentNode) : [Component](#exp_module_domv/lib/Component--Component) * [.textContent](#module_domv/lib/Component--Component+textContent) : string * [.value](#module_domv/lib/Component--Component+value) : string * [.value](#module_domv/lib/Component--Component+value) : string * [.checked](#module_domv/lib/Component--Component+checked) : boolean * [.selected](#module_domv/lib/Component--Component+selected) : boolean * [.focus](#module_domv/lib/Component--Component+focus) : boolean * [.hasFocus](#module_domv/lib/Component--Component+hasFocus) : boolean * [.outerNodeType](#module_domv/lib/Component--Component+outerNodeType) : [NodeType](#module_domv.NodeType) * [.innerNodeType](#module_domv/lib/Component--Component+innerNodeType) : [NodeType](#module_domv.NodeType) * [.outerNodeName](#module_domv/lib/Component--Component+outerNodeName) : string * [.innerNodeName](#module_domv/lib/Component--Component+innerNodeName) : string * [.isDOMVComponent](#module_domv/lib/Component--Component+isDOMVComponent) : boolean * [.isCreationConstructor(node, [wrapDocument])](#module_domv/lib/Component--Component+isCreationConstructor) ⇒ boolean * [.parseShorthandArgument(arg)](#module_domv/lib/Component--Component+parseShorthandArgument) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.type(type)](#module_domv/lib/Component--Component+type) ⇒ Component * [.on(event, listener, [useCapture], [thisObject])](#module_domv/lib/Component--Component+on) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.addListener(event, listener, [useCapture], [thisObject])](#module_domv/lib/Component--Component+addListener) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.removeListener(event, listener, [useCapture], [thisObject])](#module_domv/lib/Component--Component+removeListener) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.clearListeners()](#module_domv/lib/Component--Component+clearListeners) * [.emit(name, [data])](#module_domv/lib/Component--Component+emit) ⇒ boolean * [.isOuterNodeEqual(node)](#module_domv/lib/Component--Component+isOuterNodeEqual) ⇒ boolean * [.isInnerNodeEqual(node)](#module_domv/lib/Component--Component+isInnerNodeEqual) ⇒ boolean * [.isNodeEqual(node)](#module_domv/lib/Component--Component+isNodeEqual) ⇒ boolean * [.create(nodeName, className, [...content])](#module_domv/lib/Component--Component+create) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.text(...text_)](#module_domv/lib/Component--Component+text) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.shorthand([tagName], ...initialAttributes)](#module_domv/lib/Component--Component+shorthand) ⇒ domv/lib/CreateShortHand * [.textShorthand()](#module_domv/lib/Component--Component+textShorthand) ⇒ function * [.appendChild(...node_)](#module_domv/lib/Component--Component+appendChild) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.prependChild(...node_)](#module_domv/lib/Component--Component+prependChild) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.siblingBefore(...node_)](#module_domv/lib/Component--Component+siblingBefore) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.siblingAfter(...node_)](#module_domv/lib/Component--Component+siblingAfter) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.removeNode()](#module_domv/lib/Component--Component+removeNode) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.removeChildren()](#module_domv/lib/Component--Component+removeChildren) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.addClass(...cls)](#module_domv/lib/Component--Component+addClass) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.removeClass(...cls)](#module_domv/lib/Component--Component+removeClass) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.hasClass(...cls)](#module_domv/lib/Component--Component+hasClass) ⇒ boolean * [.assertHasClass(...cls)](#module_domv/lib/Component--Component+assertHasClass) * [.toggleClass(cls, force)](#module_domv/lib/Component--Component+toggleClass) ⇒ boolean * [.attr(name, value)](#module_domv/lib/Component--Component+attr) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.getAttr(name)](#module_domv/lib/Component--Component+getAttr) ⇒ string * [.selector(selector, [ComponentConstructor])](#module_domv/lib/Component--Component+selector) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.assertSelector(selector, [ComponentConstructor])](#module_domv/lib/Component--Component+assertSelector) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.selectorAll(selector, [ComponentConstructor])](#module_domv/lib/Component--Component+selectorAll) ⇒ [Array.<Component>](#exp_module_domv/lib/Component--Component) * [.adoptAllAttributes(from)](#module_domv/lib/Component--Component+adoptAllAttributes) * [.swapNode(node)](#module_domv/lib/Component--Component+swapNode) * [.isAllWhiteSpace([checkChildElements])](#module_domv/lib/Component--Component+isAllWhiteSpace) ⇒ boolean * [.stringifyAsHtml()](#module_domv/lib/Component--Component+stringifyAsHtml) ⇒ string * [.sendResponseAsHtml(response)](#module_domv/lib/Component--Component+sendResponseAsHtml) * [.splice()](#module_domv/lib/Component--Component+splice) * [.updateConsoleHack()](#module_domv/lib/Component--Component+updateConsoleHack) ### Component ⏏ **Kind**: Exported class #### new Component(node, [defaultNodeName], [wrapDocument]) Each Component has two constructors, one is used to wrap existing DOM nodes, the other is used to create new elements. Both constructors should result in the same DOM structure. Which constructor is used depends on the type of the node argument, [isCreationConstructor](#module_domv/lib/Component--Component+isCreationConstructor) is used to test for this. A DOCUMENT_NODE will result in the creation constructor, any other node will result in the wrapping constructor. Any subclass should accept a Node as their first argument in their constructors. This library does not care about any other argument in your constructors. **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If an invalid or unsupported node is passed. | Param | Type | Default | Description | | --- | --- | --- | --- | | node | [Node](#external_Node) | [domv/lib/Component](#module_domv/lib/Component) | | Any kind of node or a component with an outerNode,this parameter determines which constructor is used using [isCreationConstructor](#module_domv/lib/Component--Component+isCreationConstructor). | | [defaultNodeName] | string | "'div'" | If the creation constructor is used, this will be the tag that gets used to create the default element. This is a convenience for subclasses. | | [wrapDocument] | boolean | false |

Used by [wrap](#module_domv.wrap)

If false, passing a DOCUMENT_NODE as "node" will result in an empty tag being created instead of wrapping the DOCUMENT_NODE. This behaviour is more convenient when subclassing Component because it lets you treat subclasses and subsubclasses in the same way. (e.g. the subclass Menu adds the class 'Menu' and common menu items. The subsubclass EventMenu adds the class 'EventMenu' and further event menu items.)

If true, a document will always wrap.

| **Example** ```js new Component(document.createElement('p')); // wraps a "p" element ``` **Example** ```js new Component(document); // Creates an empty "div" element as a default ``` **Example** ```js new Component(document, true); // Wraps the Document Node instead of creating an empty "div" ``` #### component.document : [Document](#external_Document) The Document Node that the nodes of this Component are associated with. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If an invalid value is set #### component.outerNode : [Node](#external_Node) The "outer" DOM Node for this component.

This node is used to apply attributes or when adding this component as the child of another.

This property is usually set by the Component constructor

**Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If an invalid value is set #### component.outerNodeWrapped : [Component](#exp_module_domv/lib/Component--Component) The outer DOM node wrapped as a new component. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.innerNode : [Node](#external_Node) The "inner" DOM Node for this component.

This is used when adding nodes or other components as the child of this Component. E.g. when using methods such as appendChild() and prependChild() or properties such as childNodes or firstChild

This property is usually set by the Component constructor, or by your subclass constructor

If this property is set to null, children are not allowed for this component. Note that innerNode may also reference nodes that do not allow children because of their type (such as a TextNode)

**Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If an invalid value is set #### component.innerNodeWrapped : [Component](#exp_module_domv/lib/Component--Component) The inner DOM node wrapped as a new component. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.style : [CSSStyleDeclaration](#external_CSSStyleDeclaration) The inline style for the outer node. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.children : [Array.<Component>](#exp_module_domv/lib/Component--Component) The (wrapped) child elements of the inner node. The returned list is not live. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.childElementCount : Number The number of immediate child elements that belong to the inner node. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.childrenIndex : int The index of the outerNode in the "children" attribute of the parentNode. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) **Example** ```js myParent.children[3].childrenIndex === 3 ``` #### component.childNodes : [Array.<Component>](#exp_module_domv/lib/Component--Component) The (wrapped) child nodes of the inner node. The returned list is not live. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.childNodeCount : Number The number of immediate child nodes that belong to the inner node. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.childNodesIndex : int The index of the outerNode in the "childNodes" attribute of the parentNode. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) **Example** ```js myParent.childNodes[3].childNodesIndex === 3 ``` #### component.isEmpty : boolean Is the inner node empty? For Element nodes this means that there are 0 child nodes. For CharacterData nodes, the text content must be of 0 length. Other nodes are never considered empty **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.firstChild : [Component](#exp_module_domv/lib/Component--Component) The first (wrapped) child node of the inner node. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.lastChild : [Component](#exp_module_domv/lib/Component--Component) The first (wrapped) child node of the inner node. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.firstElementChild : [Component](#exp_module_domv/lib/Component--Component) The first (wrapped) child node of the inner node that is an element. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.lastElementChild : [Component](#exp_module_domv/lib/Component--Component) The last (wrapped) child node of the inner node that is an element. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.nextSibling : [Component](#exp_module_domv/lib/Component--Component) The next (wrapped) sibling of the outer node. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.previousSibling : [Component](#exp_module_domv/lib/Component--Component) The previous (wrapped) sibling of the outer node. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.nextElementSibling : [Component](#exp_module_domv/lib/Component--Component) The next (wrapped) sibling of the outer node that is an element. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.previousElementSibling : [Component](#exp_module_domv/lib/Component--Component) The previous (wrapped) sibling of the outer node that is an element. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.parentNode : [Component](#exp_module_domv/lib/Component--Component) The (wrapped) parent node of the outer node. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.textContent : string The textual content of an element and all its descendants. Or for Text, Comment, etc nodes it represents the nodeValue. Setting this property on an element removes all of its children and replaces them with a single text node with the given value. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.value : string The value of this node. For most nodes this property is undefined, for input fields this contains the current value. (The attribute "value" does not change by user input). **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.value : string The default value of this node. For most nodes this property is undefined, for input fields this contains the default value. (This is identical to the "value" attribute). **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.checked : boolean The checked state of this node. For most nodes this property is undefined, for input elements this contains the checked state. (The attribute "checked" does not change by user input). **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.selected : boolean The selected state of this node. For most nodes this property is undefined, for option elements this contains the current selected state. (The attribute "selected" does not change by user input). **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.focus : boolean Set or get the focus state of the inner node. Only one Element can have focus, setting the focus to this element might unset it on an other element. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) When setting this property if the inner node is not an Element node. #### component.hasFocus : boolean Returns true if this node or any of its descendants has the focus state. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.outerNodeType : [NodeType](#module_domv.NodeType) The node type of the outer node. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.innerNodeType : [NodeType](#module_domv.NodeType) The node type of the inner node. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.outerNodeName : string The node name of the outer node. (element tag names always in lowercase) **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.innerNodeName : string The node name of the inner node. **Kind**: instance property of [Component](#exp_module_domv/lib/Component--Component) #### component.isDOMVComponent : boolean Always true for instances of this class.

Use this attribute to determine if an object is a Component. This would let you create an object compatible with this API, without having to use Component as a super type.

**Kind**: instance constant of [Component](#exp_module_domv/lib/Component--Component) #### component.isCreationConstructor(node, [wrapDocument]) ⇒ boolean **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Returns**: boolean - If the creation constructor should be used instead of the wrapping constructor. | Param | Type | Default | Description | | --- | --- | --- | --- | | node | [Node](#external_Node) | [domv/lib/Component](#module_domv/lib/Component) | | A DOCUMENT_NODE will result in the creation constructor, any other node will result in the wrapping constructor. A falsy value will also result in the creation constructor and it used in Component subclasses that know how to create their own DOCUMENT_NODE (e.g. [domv/lib/HtmlDocument](#module_domv/lib/HtmlDocument). | | [wrapDocument] | boolean | false |

If false, passing a DOCUMENT_NODE as "node" will result in an empty tag being created instead of wrapping the DOCUMENT_NODE. This behaviour is more convenient when subclassing Component because it lets you treat subclasses and subsubclasses in the same way. (e.g. the subclass Menu adds the class 'Menu' and common menu items. The subsubclass EventMenu adds the class 'EventMenu' and further event menu items.)

If true, a document will always wrap.

| #### component.parseShorthandArgument(arg) ⇒ [Component](#exp_module_domv/lib/Component--Component) This method is used by domv.create() and Component.prototype.shorthand() to assign attributes and children to nodes with a shorthand syntax.

If arg is undefined or null, no action is taken.

If arg is a string, the string is appened as a text node.

If arg is an object, all key value pairs are set as attributes.

Any DOM Node or domv Component is appended as a child.

If arg is an array, parseShorthandArgument is called for each item.

**Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this | Param | Type | | --- | --- | | arg | string | [Node](#external_Node) | [domv/lib/Component](#module_domv/lib/Component) | Object.<string, string> | #### component.type(type) ⇒ Component Used in Component constructors to mark this object to be an instance of the given type. The "type argument" is used to add a html class and to overwrite the "data-type" attribute. Effectively, this means that you can use .hasClass('Foo') to check if the Component is a direct instance or an instance of a super class of a Foo component. And that `.getAttr('data-type') === 'Bar'` can be used to check if the Component is a direct instance of Bar (any instances of super or subclasses will fail this check). **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Returns**: Component - this | Param | Type | | --- | --- | | type | String | **Example** ```js this.type('TextField'); ``` #### component.on(event, listener, [useCapture], [thisObject]) ⇒ [Component](#exp_module_domv/lib/Component--Component) Adds a listener to the DOM. **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) For invalid arguments | Param | Type | Default | Description | | --- | --- | --- | --- | | event | string | | | | listener | function | | | | [useCapture] | boolean | false | Use the capture phase (for dom events) | | [thisObject] | \* | this | The this object of "listener". By default the "this" object of this method is used | #### component.addListener(event, listener, [useCapture], [thisObject]) ⇒ [Component](#exp_module_domv/lib/Component--Component) Adds a listener to the DOM or to the internal EventEmmiter, depending on the type of the event (see [module:domv.isDOMEvent](module:domv.isDOMEvent)) **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this | Param | Type | Default | Description | | --- | --- | --- | --- | | event | string | | | | listener | function | | | | [useCapture] | boolean | false | Use the capture phase (for dom events) | | [thisObject] | \* | this | The this object of "listener". By default the "this" object of this method is used | #### component.removeListener(event, listener, [useCapture], [thisObject]) ⇒ [Component](#exp_module_domv/lib/Component--Component) Removes a listener from the DOM. All of the parameters must equal the parameters that were used in addListener. **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this | Param | Type | Default | | --- | --- | --- | | event | string | | | listener | function | | | [useCapture] | boolean | false | | [thisObject] | \* | this | #### component.clearListeners() Removes all (DOM) listeners from the outerNode. **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) #### component.emit(name, [data]) ⇒ boolean Emits a DOM custom Event on the outerNode with optional data. The listeners are passed an Event object as their first argument which has this data set **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Returns**: boolean - False if any of the event listeners has called preventDefault(), otherwise true **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) For invalid arguments | Param | Type | Default | Description | | --- | --- | --- | --- | | name | String | | The event name, a prefix should be added to prevent name clashes with any new event names in web browsers. (e.g. "domv-somethinghappened" | | [data] | Object | {} | Key value pairs to set on the Event object | | [data.bubbles] | boolean | true | | | [data.cancelable] | boolean | true | | #### component.isOuterNodeEqual(node) ⇒ boolean Is the outer DOM node equal to the given node?. If a Component is given the outer nodes of both components must match. **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) | Param | Type | | --- | --- | | node | [Node](#external_Node) | [domv/lib/Component](#module_domv/lib/Component) | #### component.isInnerNodeEqual(node) ⇒ boolean Is the inner DOM node equal to the given node?. If a Component is given the inner nodes of both components must match. **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) | Param | Type | | --- | --- | | node | [Node](#external_Node) | [domv/lib/Component](#module_domv/lib/Component) | #### component.isNodeEqual(node) ⇒ boolean Are the outer and inner node equal to the given node? If a Component is given the outer and inner nodes of both components must match. **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) | Param | Type | | --- | --- | | node | [Node](#external_Node) | [domv/lib/Component](#module_domv/lib/Component) | #### component.create(nodeName, className, [...content]) ⇒ [Component](#exp_module_domv/lib/Component--Component) Convenient function to create a wrapped Node including its attributes (for elements). **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) For invalid arguments | Param | Type | Description | | --- | --- | --- | | nodeName | string | | | className | string | | | [...content] | string | [Node](#external_Node) | [domv/lib/Component](#module_domv/lib/Component) | Object.<string, string> |

If a string is passed, a text node is appended.

If a node or component is passed, it is simply appended.

If an object of key value pairs is passed, it sets those as attributes.

| #### component.text(...text_) ⇒ [Component](#exp_module_domv/lib/Component--Component) Creates a new wrapped TextNode. **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) | Param | Type | Description | | --- | --- | --- | | ...text_ | string | Extra arguments will be joined using a space | **Example** ```js var wrappedDiv = require('domv').create(document, 'div'); var wrappedText = require('domv').text(document, 'Hi!'); wrappedDiv.appendChild(wrappedText); console.log(wrappedDiv.outerNode.outerHTML); //
Hi!
``` #### component.shorthand([tagName], ...initialAttributes) ⇒ domv/lib/CreateShortHand Generate a short hand function wich lets you quickly create new elements (wrapped) including attributes. **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) For invalid arguments | Param | Type | Default | Description | | --- | --- | --- | --- | | [tagName] | string | "'div'" | | | ...initialAttributes | string | Object.<string, string> | |

If a string is passed, a text node is appended.

If an object of key value pairs is passed, it sets those as attributes (see [attr](#module_domv/lib/Component--Component+attr)).

| **Example** ```js var a = this.shorthand('a'); var link = a('readmore', {'href': something()}, 'Click here to readmore!'); // Click here to readmore! ``` #### component.textShorthand() ⇒ function Generate a short hand function which lets you quickly create new text nodes (wrapped). **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Example** ```js var text = this.textShorthand(); var wraped = text('bla'); wrapped = text('foo', 'bar'); // 'foo bar' ``` #### component.appendChild(...node_) ⇒ [Component](#exp_module_domv/lib/Component--Component) Add a child node at the end of the inner node. **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If this Component does not support child nodes. | Param | Type | Description | | --- | --- | --- | | ...node_ | [domv/lib/Component](#module_domv/lib/Component) | [Node](#external_Node) | A plain Node or if a Component is passed, the outerNode. | #### component.prependChild(...node_) ⇒ [Component](#exp_module_domv/lib/Component--Component) Add a child node at the beginning of the inner node. **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) Will throw if this Component does not support child nodes. | Param | Type | Description | | --- | --- | --- | | ...node_ | [domv/lib/Component](#module_domv/lib/Component) | [Node](#external_Node) | A plain Node or if a Component is passed, the outerNode. | #### component.siblingBefore(...node_) ⇒ [Component](#exp_module_domv/lib/Component--Component) Add a sibling node before the outer node. (which will become the outer node's previousSibling) **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) Will throw if this Component does not support child nodes. | Param | Type | Description | | --- | --- | --- | | ...node_ | [domv/lib/Component](#module_domv/lib/Component) | [Node](#external_Node) | A plain Node or if a Component is passed, the outerNode. | #### component.siblingAfter(...node_) ⇒ [Component](#exp_module_domv/lib/Component--Component) Add a sibling node after the outer node. (which will become the outer node's nextSibling) **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) Will throw if this Component does not support child nodes. | Param | Type | Description | | --- | --- | --- | | ...node_ | [domv/lib/Component](#module_domv/lib/Component) | [Node](#external_Node) | A plain Node or if a Component is passed, the outerNode. | #### component.removeNode() ⇒ [Component](#exp_module_domv/lib/Component--Component) Removes the outer node from its parentNode. **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this #### component.removeChildren() ⇒ [Component](#exp_module_domv/lib/Component--Component) Removes the all the children of the inner node **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this #### component.addClass(...cls) ⇒ [Component](#exp_module_domv/lib/Component--Component) Add classNames on the outer node. **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If the outer node of this Component does not support attributes; | Param | Type | Description | | --- | --- | --- | | ...cls | string | The classNames to add | #### component.removeClass(...cls) ⇒ [Component](#exp_module_domv/lib/Component--Component) Remove classNames from the outer node. **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If the outer node of this Component does not support attributes; | Param | Type | Description | | --- | --- | --- | | ...cls | string | The classNames to remove | #### component.hasClass(...cls) ⇒ boolean Does the outer node contain all of the given classNames? **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) | Param | Type | Description | | --- | --- | --- | | ...cls | string | The classNames to check. | #### component.assertHasClass(...cls) Does the outer node contain all of the given classNames? **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If the outer node of this Component does not contain all of the given classNames | Param | Type | Description | | --- | --- | --- | | ...cls | string | The classNames to check. | #### component.toggleClass(cls, force) ⇒ boolean Toggle a className on the outer node. **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If the outer node of this Component does not support attributes | Param | Type | Description | | --- | --- | --- | | cls | string | The className to toggle | | force | boolean | If set, force the class name to be added (true) or removed (false). | #### component.attr(name, value) ⇒ [Component](#exp_module_domv/lib/Component--Component) Set/unset an attribute on the outer node. **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If the outer node of this Component does not support attributes; | Param | Type | Description | | --- | --- | --- | | name | string | Object.<string, string> | The attribute name to unset/set. Or an object of key value pairs which sets multiple attributes at the same time, in this case `value` should not be set, or be set to a function that filters the keys. | | value | string | boolean | The value to set. Use boolean false or null to unset the attribute. Use boolean true to set a boolean attribute (e.g. checked="checked"). | **Example** ```js wrapped.attr('title', 'foo'); ``` **Example** ```js wrapped.attr({title: 'foo', class: 'bar'}); ``` **Example** ```js // do not set title: wrapped.attr({title: 'foo', class: 'bar'}, function(key) { return key !== 'title'; }); ``` #### component.getAttr(name) ⇒ string Get the value of a single attribute of the outer node. **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Returns**: string - The attribute value | Param | Type | Description | | --- | --- | --- | | name | string | The attribute name to get. | #### component.selector(selector, [ComponentConstructor]) ⇒ [Component](#exp_module_domv/lib/Component--Component) Returns the first element, or null, that matches the specified selector(s). (applied on the inner node) **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) | Param | Type | Default | Description | | --- | --- | --- | --- | | selector | string | Array.<string> | | A single selector (without a group) or an array of selectors for a selector group | | [ComponentConstructor] | function | module:domv/lib/Component | The constructor to use to wrap the result Node, by default the Node is wrapped in a plain Component, but it is also possible to specify your own constructor. | #### component.assertSelector(selector, [ComponentConstructor]) ⇒ [Component](#exp_module_domv/lib/Component--Component) Returns the first element that matches the specified selector(s). (applied on the inner node) **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If no element was found | Param | Type | Default | Description | | --- | --- | --- | --- | | selector | string | Array.<string> | | A single selector (without a group) or an array of selectors for a selector group | | [ComponentConstructor] | function | module:domv/lib/Component | The constructor to use to wrap the result Node, by default the Node is wrapped in a plain Component, but it is also possible to specify your own constructor. | #### component.selectorAll(selector, [ComponentConstructor]) ⇒ [Array.<Component>](#exp_module_domv/lib/Component--Component) Returns a list of all elements that matches the specified selector(s). (applied on the inner node) **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) | Param | Type | Default | Description | | --- | --- | --- | --- | | selector | string | Array.<string> | | A single selector (without a group) or an array of selectors for a selector group | | [ComponentConstructor] | function | module:domv/lib/Component | The constructor to use to wrap the resulting Nodes, by default the Nodes are wrapped in a plain Component, but it is also possible to specify your own constructor. | #### component.adoptAllAttributes(from) Copy all attributes from the given element to our outer node. **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If the outer node or the given element is not an element | Param | Type | Description | | --- | --- | --- | | from | [domv/lib/Component](#module_domv/lib/Component) | [Element](#external_Element) | A DOM Element or if a Component is passed, the outerNode. | #### component.swapNode(node) Move over all child nodes of the inner node to the given "node" and replace the outer node with the given "node". **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If the outer node or the given element is not an element | Param | Type | Description | | --- | --- | --- | | node | Element | [domv/lib/Component](#module_domv/lib/Component) | The node to replace our outer node with. If not set, the children of our inner node are added to the parent of the outer node. | **Example** ```js var container = document.createElement('div'); container.innerHTML = '
abc

defghjklm

nop
'; domv.wrap(container).selector('p').swap(document.createElement('h1')); console.log(container.innerHTML); // '
abc

defghjklm

nop
' ``` #### component.isAllWhiteSpace([checkChildElements]) ⇒ boolean Does the innerNode (and its (grand)children) of this component only consist of whitespace? Text nodes that only consist of spaces, newlines and horizontal tabs are whitespace. Comment nodes are whitespace. Empty text, comment, element nodes are whitespace. Certain content elements such as for example img, video, input, etc are not whitespace. **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) | Param | Type | Default | Description | | --- | --- | --- | --- | | [checkChildElements] | boolean | false | If false any element node (e.g. an empty div) that is encountered will fail the whitespace check. If true those elements are checked recursively for whitepspace | #### component.stringifyAsHtml() ⇒ string Stringify the outerNode and all its children as html markup. **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) #### component.sendResponseAsHtml(response) Stringify the outerNode and all its children as html markup, and send it as a http response in node.js with the proper Content-Type and Content-Length. Other headers can be set by calling setHeader() on the response before calling this method. The status code can be set by setting response.statusCode in the same fashion (the default is 200). This method uses this.stringifyAsHtml() to generate the markup (which can be overridden). **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) | Param | Type | | --- | --- | | response | [ServerResponse](#external_ServerResponse) | #### component.splice() This method does nothing, it is used so that firebug and chrome displays Component objects as an array. This method is not used by this library, feel free to override this method. **Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) #### component.updateConsoleHack()

Called whenever an inner/outer node changes. This enables pretty formatting of Component instances in the firebug and chrome console.

Firebug will display instances as:

"Object["BaseDocument", html.BaseDocument, div.content]"

Chrome will display instances as:

["BaseDocument", <html class=​"BaseDocument">​...​</html>​, <div class=​"content">​…</div>​...​</div>​]

This hack works by setting the attributes "length", "0", "1" and "2" ("splice" is set on the prototype also). Override this method to do nothing in your subclass to disable this hack.

**Kind**: instance method of [Component](#exp_module_domv/lib/Component--Component) ## domv/lib/Exception The base class for any exception that originates from this library **Author:** Joris van der Wel * [domv/lib/Exception](#module_domv/lib/Exception) * [Exception](#exp_module_domv/lib/Exception--Exception) ⇐ Error ⏏ * [new Exception(wrapped)](#new_module_domv/lib/Exception--Exception_new) ### Exception ⇐ Error ⏏ **Kind**: Exported class **Extends:** Error #### new Exception(wrapped) Construct a simple domv.Exception | Param | Type | | --- | --- | | wrapped | Error | **Example** ```js new domv.Exception(new Error('Hrm')); ``` ## domv/lib/HtmlDocument Represents a full document in html, including the root node html. **Author:** Joris van der Wel * [domv/lib/HtmlDocument](#module_domv/lib/HtmlDocument) * [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) ⇐ [domv/lib/Component](#module_domv/lib/Component) ⏏ * [new HtmlDocument(node)](#new_module_domv/lib/HtmlDocument--HtmlDocument_new) * [.head](#module_domv/lib/HtmlDocument--HtmlDocument+head) : [Component](#exp_module_domv/lib/Component--Component) * [.body](#module_domv/lib/HtmlDocument--HtmlDocument+body) : [Component](#exp_module_domv/lib/Component--Component) * [.baseWrapped](#module_domv/lib/HtmlDocument--HtmlDocument+baseWrapped) : [Component](#exp_module_domv/lib/Component--Component) * [.titleWrapped](#module_domv/lib/HtmlDocument--HtmlDocument+titleWrapped) : [Component](#exp_module_domv/lib/Component--Component) * [.title](#module_domv/lib/HtmlDocument--HtmlDocument+title) : string * [.baseURI](#module_domv/lib/HtmlDocument--HtmlDocument+baseURI) : string * [.document](#module_domv/lib/Component--Component+document) : [Document](#external_Document) * [.outerNode](#module_domv/lib/Component--Component+outerNode) : [Node](#external_Node) * [.outerNodeWrapped](#module_domv/lib/Component--Component+outerNodeWrapped) : [Component](#exp_module_domv/lib/Component--Component) * [.innerNode](#module_domv/lib/Component--Component+innerNode) : [Node](#external_Node) * [.innerNodeWrapped](#module_domv/lib/Component--Component+innerNodeWrapped) : [Component](#exp_module_domv/lib/Component--Component) * [.style](#module_domv/lib/Component--Component+style) : [CSSStyleDeclaration](#external_CSSStyleDeclaration) * [.children](#module_domv/lib/Component--Component+children) : [Array.<Component>](#exp_module_domv/lib/Component--Component) * [.childElementCount](#module_domv/lib/Component--Component+childElementCount) : Number * [.childrenIndex](#module_domv/lib/Component--Component+childrenIndex) : int * [.childNodes](#module_domv/lib/Component--Component+childNodes) : [Array.<Component>](#exp_module_domv/lib/Component--Component) * [.childNodeCount](#module_domv/lib/Component--Component+childNodeCount) : Number * [.childNodesIndex](#module_domv/lib/Component--Component+childNodesIndex) : int * [.isEmpty](#module_domv/lib/Component--Component+isEmpty) : boolean * [.firstChild](#module_domv/lib/Component--Component+firstChild) : [Component](#exp_module_domv/lib/Component--Component) * [.lastChild](#module_domv/lib/Component--Component+lastChild) : [Component](#exp_module_domv/lib/Component--Component) * [.firstElementChild](#module_domv/lib/Component--Component+firstElementChild) : [Component](#exp_module_domv/lib/Component--Component) * [.lastElementChild](#module_domv/lib/Component--Component+lastElementChild) : [Component](#exp_module_domv/lib/Component--Component) * [.nextSibling](#module_domv/lib/Component--Component+nextSibling) : [Component](#exp_module_domv/lib/Component--Component) * [.previousSibling](#module_domv/lib/Component--Component+previousSibling) : [Component](#exp_module_domv/lib/Component--Component) * [.nextElementSibling](#module_domv/lib/Component--Component+nextElementSibling) : [Component](#exp_module_domv/lib/Component--Component) * [.previousElementSibling](#module_domv/lib/Component--Component+previousElementSibling) : [Component](#exp_module_domv/lib/Component--Component) * [.parentNode](#module_domv/lib/Component--Component+parentNode) : [Component](#exp_module_domv/lib/Component--Component) * [.textContent](#module_domv/lib/Component--Component+textContent) : string * [.value](#module_domv/lib/Component--Component+value) : string * [.checked](#module_domv/lib/Component--Component+checked) : boolean * [.selected](#module_domv/lib/Component--Component+selected) : boolean * [.focus](#module_domv/lib/Component--Component+focus) : boolean * [.hasFocus](#module_domv/lib/Component--Component+hasFocus) : boolean * [.outerNodeType](#module_domv/lib/Component--Component+outerNodeType) : [NodeType](#module_domv.NodeType) * [.innerNodeType](#module_domv/lib/Component--Component+innerNodeType) : [NodeType](#module_domv.NodeType) * [.outerNodeName](#module_domv/lib/Component--Component+outerNodeName) : string * [.innerNodeName](#module_domv/lib/Component--Component+innerNodeName) : string * [.isDOMVComponent](#module_domv/lib/Component--Component+isDOMVComponent) : boolean * [.addCSS(href, media)](#module_domv/lib/HtmlDocument--HtmlDocument+addCSS) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.addJS(href, [async])](#module_domv/lib/HtmlDocument--HtmlDocument+addJS) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.addJSONData(identifier, data)](#module_domv/lib/HtmlDocument--HtmlDocument+addJSONData) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.getJSONData(identifier)](#module_domv/lib/HtmlDocument--HtmlDocument+getJSONData) ⇒ \* * [.isCreationConstructor(node, [wrapDocument])](#module_domv/lib/Component--Component+isCreationConstructor) ⇒ boolean * [.parseShorthandArgument(arg)](#module_domv/lib/Component--Component+parseShorthandArgument) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.type(type)](#module_domv/lib/Component--Component+type) ⇒ Component * [.on(event, listener, [useCapture], [thisObject])](#module_domv/lib/Component--Component+on) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.addListener(event, listener, [useCapture], [thisObject])](#module_domv/lib/Component--Component+addListener) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.removeListener(event, listener, [useCapture], [thisObject])](#module_domv/lib/Component--Component+removeListener) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.clearListeners()](#module_domv/lib/Component--Component+clearListeners) * [.emit(name, [data])](#module_domv/lib/Component--Component+emit) ⇒ boolean * [.isOuterNodeEqual(node)](#module_domv/lib/Component--Component+isOuterNodeEqual) ⇒ boolean * [.isInnerNodeEqual(node)](#module_domv/lib/Component--Component+isInnerNodeEqual) ⇒ boolean * [.isNodeEqual(node)](#module_domv/lib/Component--Component+isNodeEqual) ⇒ boolean * [.create(nodeName, className, [...content])](#module_domv/lib/Component--Component+create) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.text(...text_)](#module_domv/lib/Component--Component+text) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.shorthand([tagName], ...initialAttributes)](#module_domv/lib/Component--Component+shorthand) ⇒ domv/lib/CreateShortHand * [.textShorthand()](#module_domv/lib/Component--Component+textShorthand) ⇒ function * [.appendChild(...node_)](#module_domv/lib/Component--Component+appendChild) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.prependChild(...node_)](#module_domv/lib/Component--Component+prependChild) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.siblingBefore(...node_)](#module_domv/lib/Component--Component+siblingBefore) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.siblingAfter(...node_)](#module_domv/lib/Component--Component+siblingAfter) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.removeNode()](#module_domv/lib/Component--Component+removeNode) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.removeChildren()](#module_domv/lib/Component--Component+removeChildren) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.addClass(...cls)](#module_domv/lib/Component--Component+addClass) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.removeClass(...cls)](#module_domv/lib/Component--Component+removeClass) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.hasClass(...cls)](#module_domv/lib/Component--Component+hasClass) ⇒ boolean * [.assertHasClass(...cls)](#module_domv/lib/Component--Component+assertHasClass) * [.toggleClass(cls, force)](#module_domv/lib/Component--Component+toggleClass) ⇒ boolean * [.attr(name, value)](#module_domv/lib/Component--Component+attr) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.getAttr(name)](#module_domv/lib/Component--Component+getAttr) ⇒ string * [.selector(selector, [ComponentConstructor])](#module_domv/lib/Component--Component+selector) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.assertSelector(selector, [ComponentConstructor])](#module_domv/lib/Component--Component+assertSelector) ⇒ [Component](#exp_module_domv/lib/Component--Component) * [.selectorAll(selector, [ComponentConstructor])](#module_domv/lib/Component--Component+selectorAll) ⇒ [Array.<Component>](#exp_module_domv/lib/Component--Component) * [.adoptAllAttributes(from)](#module_domv/lib/Component--Component+adoptAllAttributes) * [.swapNode(node)](#module_domv/lib/Component--Component+swapNode) * [.isAllWhiteSpace([checkChildElements])](#module_domv/lib/Component--Component+isAllWhiteSpace) ⇒ boolean * [.stringifyAsHtml()](#module_domv/lib/Component--Component+stringifyAsHtml) ⇒ string * [.sendResponseAsHtml(response)](#module_domv/lib/Component--Component+sendResponseAsHtml) * [.splice()](#module_domv/lib/Component--Component+splice) * [.updateConsoleHack()](#module_domv/lib/Component--Component+updateConsoleHack) ### HtmlDocument ⇐ [domv/lib/Component](#module_domv/lib/Component) ⏏ **Kind**: Exported class **Extends:** [domv/lib/Component](#module_domv/lib/Component) #### new HtmlDocument(node) This constructor can be used to either create a new html document (html, head, body), or to wrap an existing html document into this class. **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If an invalid node is passed, or if the existing document is missing the "head" or "body" element. | Param | Type | Description | | --- | --- | --- | | node | [Node](#external_Node) | [domv/lib/Component](#module_domv/lib/Component) | Either null, a document node or an "html" element node | **Example** ```js new HtmlDocument() // create a new Document Node, including html (as its child), head, body. ``` **Example** ```js new HtmlDocument(document); // Create html, head and body elements using the given Document Node, but do not modify the given Document node (constructors should be side-effect free). ``` **Example** ```js new HtmlDocument(document.documentElement); // Associate an existing html document ``` #### htmlDocument.head : [Component](#exp_module_domv/lib/Component--Component) The "head" Element of the document. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.body : [Component](#exp_module_domv/lib/Component--Component) The "body" Element of the document. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.baseWrapped : [Component](#exp_module_domv/lib/Component--Component) The "base" Element of the document. (within the "head" node) **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.titleWrapped : [Component](#exp_module_domv/lib/Component--Component) The "title" Element of the document. (within the head node) **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.title : string The textContent of the "title" Element of this document. (within the "head" node) **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.baseURI : string The base URI that is used to resolve all the relative uri's within this document. (this is get/set using a "base" Element within the "head" element) **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.document : [Document](#external_Document) The Document Node that the nodes of this Component are associated with. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If an invalid value is set #### htmlDocument.outerNode : [Node](#external_Node) The "outer" DOM Node for this component.

This node is used to apply attributes or when adding this component as the child of another.

This property is usually set by the Component constructor

**Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If an invalid value is set #### htmlDocument.outerNodeWrapped : [Component](#exp_module_domv/lib/Component--Component) The outer DOM node wrapped as a new component. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.innerNode : [Node](#external_Node) The "inner" DOM Node for this component.

This is used when adding nodes or other components as the child of this Component. E.g. when using methods such as appendChild() and prependChild() or properties such as childNodes or firstChild

This property is usually set by the Component constructor, or by your subclass constructor

If this property is set to null, children are not allowed for this component. Note that innerNode may also reference nodes that do not allow children because of their type (such as a TextNode)

**Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Overrides:** [innerNode](#module_domv/lib/Component--Component+innerNode) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If an invalid value is set #### htmlDocument.innerNodeWrapped : [Component](#exp_module_domv/lib/Component--Component) The inner DOM node wrapped as a new component. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.style : [CSSStyleDeclaration](#external_CSSStyleDeclaration) The inline style for the outer node. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.children : [Array.<Component>](#exp_module_domv/lib/Component--Component) The (wrapped) child elements of the inner node. The returned list is not live. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.childElementCount : Number The number of immediate child elements that belong to the inner node. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.childrenIndex : int The index of the outerNode in the "children" attribute of the parentNode. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Example** ```js myParent.children[3].childrenIndex === 3 ``` #### htmlDocument.childNodes : [Array.<Component>](#exp_module_domv/lib/Component--Component) The (wrapped) child nodes of the inner node. The returned list is not live. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.childNodeCount : Number The number of immediate child nodes that belong to the inner node. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.childNodesIndex : int The index of the outerNode in the "childNodes" attribute of the parentNode. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Example** ```js myParent.childNodes[3].childNodesIndex === 3 ``` #### htmlDocument.isEmpty : boolean Is the inner node empty? For Element nodes this means that there are 0 child nodes. For CharacterData nodes, the text content must be of 0 length. Other nodes are never considered empty **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.firstChild : [Component](#exp_module_domv/lib/Component--Component) The first (wrapped) child node of the inner node. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.lastChild : [Component](#exp_module_domv/lib/Component--Component) The first (wrapped) child node of the inner node. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.firstElementChild : [Component](#exp_module_domv/lib/Component--Component) The first (wrapped) child node of the inner node that is an element. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.lastElementChild : [Component](#exp_module_domv/lib/Component--Component) The last (wrapped) child node of the inner node that is an element. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.nextSibling : [Component](#exp_module_domv/lib/Component--Component) The next (wrapped) sibling of the outer node. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.previousSibling : [Component](#exp_module_domv/lib/Component--Component) The previous (wrapped) sibling of the outer node. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.nextElementSibling : [Component](#exp_module_domv/lib/Component--Component) The next (wrapped) sibling of the outer node that is an element. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.previousElementSibling : [Component](#exp_module_domv/lib/Component--Component) The previous (wrapped) sibling of the outer node that is an element. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.parentNode : [Component](#exp_module_domv/lib/Component--Component) The (wrapped) parent node of the outer node. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.textContent : string The textual content of an element and all its descendants. Or for Text, Comment, etc nodes it represents the nodeValue. Setting this property on an element removes all of its children and replaces them with a single text node with the given value. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.value : string The value of this node. For most nodes this property is undefined, for input fields this contains the current value. (The attribute "value" does not change by user input). **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Overrides:** [value](#module_domv/lib/Component--Component+value) #### htmlDocument.checked : boolean The checked state of this node. For most nodes this property is undefined, for input elements this contains the checked state. (The attribute "checked" does not change by user input). **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.selected : boolean The selected state of this node. For most nodes this property is undefined, for option elements this contains the current selected state. (The attribute "selected" does not change by user input). **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.focus : boolean Set or get the focus state of the inner node. Only one Element can have focus, setting the focus to this element might unset it on an other element. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) When setting this property if the inner node is not an Element node. #### htmlDocument.hasFocus : boolean Returns true if this node or any of its descendants has the focus state. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.outerNodeType : [NodeType](#module_domv.NodeType) The node type of the outer node. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.innerNodeType : [NodeType](#module_domv.NodeType) The node type of the inner node. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.outerNodeName : string The node name of the outer node. (element tag names always in lowercase) **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.innerNodeName : string The node name of the inner node. **Kind**: instance property of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.isDOMVComponent : boolean Always true for instances of this class.

Use this attribute to determine if an object is a Component. This would let you create an object compatible with this API, without having to use Component as a super type.

**Kind**: instance constant of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.addCSS(href, media) ⇒ [Component](#exp_module_domv/lib/Component--Component) Link a css file to this document. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - The newly created "link" node | Param | Type | Description | | --- | --- | --- | | href | string | An absolute or relative URL | | media | string | The media query to associate with this css file | #### htmlDocument.addJS(href, [async]) ⇒ [Component](#exp_module_domv/lib/Component--Component) Link a javascript file to this document. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - The newly created "script" node | Param | Type | Default | Description | | --- | --- | --- | --- | | href | string | | An absolute or relative URL | | [async] | boolean | true | If true, a webbrowser will continue parsing the document even if the script file has not been fully loaded yet. Use this whenever possible to decrease load times. | #### htmlDocument.addJSONData(identifier, data) ⇒ [Component](#exp_module_domv/lib/Component--Component) Expose JSON data to an interpreter of the HTML document using a script type="application/json" element. The data can be retrieved using getJSONData with the same identifier; **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - The newly created "script" node | Param | Type | Description | | --- | --- | --- | | identifier | string | Must be unique to properly get your JSON data back | | data | \* | Any array, object, boolean, integer, et cetera that is able to be serialized into JSON. | **Example** ```js myDoc.addJSONData('foo', {'abc': 'def'}); // ``` #### htmlDocument.getJSONData(identifier) ⇒ \* Retrieve JSON data previously exposed by addJSONData **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: \* - parsed json data | Param | Type | Description | | --- | --- | --- | | identifier | string | Same identifier as was used in addJSONData | #### htmlDocument.isCreationConstructor(node, [wrapDocument]) ⇒ boolean **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: boolean - If the creation constructor should be used instead of the wrapping constructor. | Param | Type | Default | Description | | --- | --- | --- | --- | | node | [Node](#external_Node) | [domv/lib/Component](#module_domv/lib/Component) | | A DOCUMENT_NODE will result in the creation constructor, any other node will result in the wrapping constructor. A falsy value will also result in the creation constructor and it used in Component subclasses that know how to create their own DOCUMENT_NODE (e.g. [domv/lib/HtmlDocument](#module_domv/lib/HtmlDocument). | | [wrapDocument] | boolean | false |

If false, passing a DOCUMENT_NODE as "node" will result in an empty tag being created instead of wrapping the DOCUMENT_NODE. This behaviour is more convenient when subclassing Component because it lets you treat subclasses and subsubclasses in the same way. (e.g. the subclass Menu adds the class 'Menu' and common menu items. The subsubclass EventMenu adds the class 'EventMenu' and further event menu items.)

If true, a document will always wrap.

| #### htmlDocument.parseShorthandArgument(arg) ⇒ [Component](#exp_module_domv/lib/Component--Component) This method is used by domv.create() and Component.prototype.shorthand() to assign attributes and children to nodes with a shorthand syntax.

If arg is undefined or null, no action is taken.

If arg is a string, the string is appened as a text node.

If arg is an object, all key value pairs are set as attributes.

Any DOM Node or domv Component is appended as a child.

If arg is an array, parseShorthandArgument is called for each item.

**Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this | Param | Type | | --- | --- | | arg | string | [Node](#external_Node) | [domv/lib/Component](#module_domv/lib/Component) | Object.<string, string> | #### htmlDocument.type(type) ⇒ Component Used in Component constructors to mark this object to be an instance of the given type. The "type argument" is used to add a html class and to overwrite the "data-type" attribute. Effectively, this means that you can use .hasClass('Foo') to check if the Component is a direct instance or an instance of a super class of a Foo component. And that `.getAttr('data-type') === 'Bar'` can be used to check if the Component is a direct instance of Bar (any instances of super or subclasses will fail this check). **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: Component - this | Param | Type | | --- | --- | | type | String | **Example** ```js this.type('TextField'); ``` #### htmlDocument.on(event, listener, [useCapture], [thisObject]) ⇒ [Component](#exp_module_domv/lib/Component--Component) Adds a listener to the DOM. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) For invalid arguments | Param | Type | Default | Description | | --- | --- | --- | --- | | event | string | | | | listener | function | | | | [useCapture] | boolean | false | Use the capture phase (for dom events) | | [thisObject] | \* | this | The this object of "listener". By default the "this" object of this method is used | #### htmlDocument.addListener(event, listener, [useCapture], [thisObject]) ⇒ [Component](#exp_module_domv/lib/Component--Component) Adds a listener to the DOM or to the internal EventEmmiter, depending on the type of the event (see [module:domv.isDOMEvent](module:domv.isDOMEvent)) **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this | Param | Type | Default | Description | | --- | --- | --- | --- | | event | string | | | | listener | function | | | | [useCapture] | boolean | false | Use the capture phase (for dom events) | | [thisObject] | \* | this | The this object of "listener". By default the "this" object of this method is used | #### htmlDocument.removeListener(event, listener, [useCapture], [thisObject]) ⇒ [Component](#exp_module_domv/lib/Component--Component) Removes a listener from the DOM. All of the parameters must equal the parameters that were used in addListener. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this | Param | Type | Default | | --- | --- | --- | | event | string | | | listener | function | | | [useCapture] | boolean | false | | [thisObject] | \* | this | #### htmlDocument.clearListeners() Removes all (DOM) listeners from the outerNode. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.emit(name, [data]) ⇒ boolean Emits a DOM custom Event on the outerNode with optional data. The listeners are passed an Event object as their first argument which has this data set **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: boolean - False if any of the event listeners has called preventDefault(), otherwise true **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) For invalid arguments | Param | Type | Default | Description | | --- | --- | --- | --- | | name | String | | The event name, a prefix should be added to prevent name clashes with any new event names in web browsers. (e.g. "domv-somethinghappened" | | [data] | Object | {} | Key value pairs to set on the Event object | | [data.bubbles] | boolean | true | | | [data.cancelable] | boolean | true | | #### htmlDocument.isOuterNodeEqual(node) ⇒ boolean Is the outer DOM node equal to the given node?. If a Component is given the outer nodes of both components must match. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) | Param | Type | | --- | --- | | node | [Node](#external_Node) | [domv/lib/Component](#module_domv/lib/Component) | #### htmlDocument.isInnerNodeEqual(node) ⇒ boolean Is the inner DOM node equal to the given node?. If a Component is given the inner nodes of both components must match. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) | Param | Type | | --- | --- | | node | [Node](#external_Node) | [domv/lib/Component](#module_domv/lib/Component) | #### htmlDocument.isNodeEqual(node) ⇒ boolean Are the outer and inner node equal to the given node? If a Component is given the outer and inner nodes of both components must match. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) | Param | Type | | --- | --- | | node | [Node](#external_Node) | [domv/lib/Component](#module_domv/lib/Component) | #### htmlDocument.create(nodeName, className, [...content]) ⇒ [Component](#exp_module_domv/lib/Component--Component) Convenient function to create a wrapped Node including its attributes (for elements). **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) For invalid arguments | Param | Type | Description | | --- | --- | --- | | nodeName | string | | | className | string | | | [...content] | string | [Node](#external_Node) | [domv/lib/Component](#module_domv/lib/Component) | Object.<string, string> |

If a string is passed, a text node is appended.

If a node or component is passed, it is simply appended.

If an object of key value pairs is passed, it sets those as attributes.

| #### htmlDocument.text(...text_) ⇒ [Component](#exp_module_domv/lib/Component--Component) Creates a new wrapped TextNode. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) | Param | Type | Description | | --- | --- | --- | | ...text_ | string | Extra arguments will be joined using a space | **Example** ```js var wrappedDiv = require('domv').create(document, 'div'); var wrappedText = require('domv').text(document, 'Hi!'); wrappedDiv.appendChild(wrappedText); console.log(wrappedDiv.outerNode.outerHTML); //
Hi!
``` #### htmlDocument.shorthand([tagName], ...initialAttributes) ⇒ domv/lib/CreateShortHand Generate a short hand function wich lets you quickly create new elements (wrapped) including attributes. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) For invalid arguments | Param | Type | Default | Description | | --- | --- | --- | --- | | [tagName] | string | "'div'" | | | ...initialAttributes | string | Object.<string, string> | |

If a string is passed, a text node is appended.

If an object of key value pairs is passed, it sets those as attributes (see [attr](#module_domv/lib/Component--Component+attr)).

| **Example** ```js var a = this.shorthand('a'); var link = a('readmore', {'href': something()}, 'Click here to readmore!'); // Click here to readmore! ``` #### htmlDocument.textShorthand() ⇒ function Generate a short hand function which lets you quickly create new text nodes (wrapped). **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Example** ```js var text = this.textShorthand(); var wraped = text('bla'); wrapped = text('foo', 'bar'); // 'foo bar' ``` #### htmlDocument.appendChild(...node_) ⇒ [Component](#exp_module_domv/lib/Component--Component) Add a child node at the end of the inner node. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If this Component does not support child nodes. | Param | Type | Description | | --- | --- | --- | | ...node_ | [domv/lib/Component](#module_domv/lib/Component) | [Node](#external_Node) | A plain Node or if a Component is passed, the outerNode. | #### htmlDocument.prependChild(...node_) ⇒ [Component](#exp_module_domv/lib/Component--Component) Add a child node at the beginning of the inner node. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) Will throw if this Component does not support child nodes. | Param | Type | Description | | --- | --- | --- | | ...node_ | [domv/lib/Component](#module_domv/lib/Component) | [Node](#external_Node) | A plain Node or if a Component is passed, the outerNode. | #### htmlDocument.siblingBefore(...node_) ⇒ [Component](#exp_module_domv/lib/Component--Component) Add a sibling node before the outer node. (which will become the outer node's previousSibling) **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) Will throw if this Component does not support child nodes. | Param | Type | Description | | --- | --- | --- | | ...node_ | [domv/lib/Component](#module_domv/lib/Component) | [Node](#external_Node) | A plain Node or if a Component is passed, the outerNode. | #### htmlDocument.siblingAfter(...node_) ⇒ [Component](#exp_module_domv/lib/Component--Component) Add a sibling node after the outer node. (which will become the outer node's nextSibling) **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) Will throw if this Component does not support child nodes. | Param | Type | Description | | --- | --- | --- | | ...node_ | [domv/lib/Component](#module_domv/lib/Component) | [Node](#external_Node) | A plain Node or if a Component is passed, the outerNode. | #### htmlDocument.removeNode() ⇒ [Component](#exp_module_domv/lib/Component--Component) Removes the outer node from its parentNode. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this #### htmlDocument.removeChildren() ⇒ [Component](#exp_module_domv/lib/Component--Component) Removes the all the children of the inner node **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this #### htmlDocument.addClass(...cls) ⇒ [Component](#exp_module_domv/lib/Component--Component) Add classNames on the outer node. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If the outer node of this Component does not support attributes; | Param | Type | Description | | --- | --- | --- | | ...cls | string | The classNames to add | #### htmlDocument.removeClass(...cls) ⇒ [Component](#exp_module_domv/lib/Component--Component) Remove classNames from the outer node. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If the outer node of this Component does not support attributes; | Param | Type | Description | | --- | --- | --- | | ...cls | string | The classNames to remove | #### htmlDocument.hasClass(...cls) ⇒ boolean Does the outer node contain all of the given classNames? **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) | Param | Type | Description | | --- | --- | --- | | ...cls | string | The classNames to check. | #### htmlDocument.assertHasClass(...cls) Does the outer node contain all of the given classNames? **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If the outer node of this Component does not contain all of the given classNames | Param | Type | Description | | --- | --- | --- | | ...cls | string | The classNames to check. | #### htmlDocument.toggleClass(cls, force) ⇒ boolean Toggle a className on the outer node. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If the outer node of this Component does not support attributes | Param | Type | Description | | --- | --- | --- | | cls | string | The className to toggle | | force | boolean | If set, force the class name to be added (true) or removed (false). | #### htmlDocument.attr(name, value) ⇒ [Component](#exp_module_domv/lib/Component--Component) Set/unset an attribute on the outer node. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: [Component](#exp_module_domv/lib/Component--Component) - this **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If the outer node of this Component does not support attributes; | Param | Type | Description | | --- | --- | --- | | name | string | Object.<string, string> | The attribute name to unset/set. Or an object of key value pairs which sets multiple attributes at the same time, in this case `value` should not be set, or be set to a function that filters the keys. | | value | string | boolean | The value to set. Use boolean false or null to unset the attribute. Use boolean true to set a boolean attribute (e.g. checked="checked"). | **Example** ```js wrapped.attr('title', 'foo'); ``` **Example** ```js wrapped.attr({title: 'foo', class: 'bar'}); ``` **Example** ```js // do not set title: wrapped.attr({title: 'foo', class: 'bar'}, function(key) { return key !== 'title'; }); ``` #### htmlDocument.getAttr(name) ⇒ string Get the value of a single attribute of the outer node. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Returns**: string - The attribute value | Param | Type | Description | | --- | --- | --- | | name | string | The attribute name to get. | #### htmlDocument.selector(selector, [ComponentConstructor]) ⇒ [Component](#exp_module_domv/lib/Component--Component) Returns the first element, or null, that matches the specified selector(s). (applied on the inner node) **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) | Param | Type | Default | Description | | --- | --- | --- | --- | | selector | string | Array.<string> | | A single selector (without a group) or an array of selectors for a selector group | | [ComponentConstructor] | function | module:domv/lib/Component | The constructor to use to wrap the result Node, by default the Node is wrapped in a plain Component, but it is also possible to specify your own constructor. | #### htmlDocument.assertSelector(selector, [ComponentConstructor]) ⇒ [Component](#exp_module_domv/lib/Component--Component) Returns the first element that matches the specified selector(s). (applied on the inner node) **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If no element was found | Param | Type | Default | Description | | --- | --- | --- | --- | | selector | string | Array.<string> | | A single selector (without a group) or an array of selectors for a selector group | | [ComponentConstructor] | function | module:domv/lib/Component | The constructor to use to wrap the result Node, by default the Node is wrapped in a plain Component, but it is also possible to specify your own constructor. | #### htmlDocument.selectorAll(selector, [ComponentConstructor]) ⇒ [Array.<Component>](#exp_module_domv/lib/Component--Component) Returns a list of all elements that matches the specified selector(s). (applied on the inner node) **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) | Param | Type | Default | Description | | --- | --- | --- | --- | | selector | string | Array.<string> | | A single selector (without a group) or an array of selectors for a selector group | | [ComponentConstructor] | function | module:domv/lib/Component | The constructor to use to wrap the resulting Nodes, by default the Nodes are wrapped in a plain Component, but it is also possible to specify your own constructor. | #### htmlDocument.adoptAllAttributes(from) Copy all attributes from the given element to our outer node. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If the outer node or the given element is not an element | Param | Type | Description | | --- | --- | --- | | from | [domv/lib/Component](#module_domv/lib/Component) | [Element](#external_Element) | A DOM Element or if a Component is passed, the outerNode. | #### htmlDocument.swapNode(node) Move over all child nodes of the inner node to the given "node" and replace the outer node with the given "node". **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Throws**: - [domv/lib/Exception](#module_domv/lib/Exception) If the outer node or the given element is not an element | Param | Type | Description | | --- | --- | --- | | node | Element | [domv/lib/Component](#module_domv/lib/Component) | The node to replace our outer node with. If not set, the children of our inner node are added to the parent of the outer node. | **Example** ```js var container = document.createElement('div'); container.innerHTML = '
abc

defghjklm

nop
'; domv.wrap(container).selector('p').swap(document.createElement('h1')); console.log(container.innerHTML); // '
abc

defghjklm

nop
' ``` #### htmlDocument.isAllWhiteSpace([checkChildElements]) ⇒ boolean Does the innerNode (and its (grand)children) of this component only consist of whitespace? Text nodes that only consist of spaces, newlines and horizontal tabs are whitespace. Comment nodes are whitespace. Empty text, comment, element nodes are whitespace. Certain content elements such as for example img, video, input, etc are not whitespace. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) | Param | Type | Default | Description | | --- | --- | --- | --- | | [checkChildElements] | boolean | false | If false any element node (e.g. an empty div) that is encountered will fail the whitespace check. If true those elements are checked recursively for whitepspace | #### htmlDocument.stringifyAsHtml() ⇒ string Stringify the outerNode and all its children as html markup. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) **Overrides:** [stringifyAsHtml](#module_domv/lib/Component--Component+stringifyAsHtml) #### htmlDocument.sendResponseAsHtml(response) Stringify the outerNode and all its children as html markup, and send it as a http response in node.js with the proper Content-Type and Content-Length. Other headers can be set by calling setHeader() on the response before calling this method. The status code can be set by setting response.statusCode in the same fashion (the default is 200). This method uses this.stringifyAsHtml() to generate the markup (which can be overridden). **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) | Param | Type | | --- | --- | | response | [ServerResponse](#external_ServerResponse) | #### htmlDocument.splice() This method does nothing, it is used so that firebug and chrome displays Component objects as an array. This method is not used by this library, feel free to override this method. **Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument) #### htmlDocument.updateConsoleHack()

Called whenever an inner/outer node changes. This enables pretty formatting of Component instances in the firebug and chrome console.

Firebug will display instances as:

"Object["BaseDocument", html.BaseDocument, div.content]"

Chrome will display instances as:

["BaseDocument", <html class=​"BaseDocument">​...​</html>​, <div class=​"content">​…</div>​...​</div>​]

This hack works by setting the attributes "length", "0", "1" and "2" ("splice" is set on the prototype also). Override this method to do nothing in your subclass to disable this hack.

**Kind**: instance method of [HtmlDocument](#exp_module_domv/lib/HtmlDocument--HtmlDocument)