new GoBrain.Dom(root)
A scoped DOM wrapper, adding convenience functionality used to manipulate the element and restricts access to anything above the root element.
A scoped DOM wrapper, adding convenience functionality used to manipulate the element and restricts access to anything above the root element.
| Name | Type | Description |
|---|---|---|
root |
HTMLElement |
The root element to work against. |
Members
-
SettingsString
-
Properties:
Name Type Default Description IdPrefixString gobrain-id- This namespace is prepended to all ids set with the .goBrainId() function or searched for with the .getNodeByGoBrainId() function.
TemplatePrefixString gobrain-template- TemplateVariablePrefixString gobrain-template-variable-
Methods
-
addClass(clazz, element){GoBrain.Node}
GoBrain.Core/src/dom.js, line 50Adds a css class if it doesn't already exist.
-
Adds a css class if it doesn't already exist.
Name Type Description clazzString The class to add.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node -
addCssRule(selector, rules, sheet, index){GoBrain.Node}
GoBrain.Core/src/dom.js, line 63Adds a css rule to a style sheet.
-
Adds a css rule to a style sheet.
Name Type Description selectorString Selector for the rule.
rulesString The rules to add.
sheetCSSStyleSheet optional The style sheet to use.
indexNumber optional The position in the style sheet to insert the rule at.
Returns:
Type Description GoBrain.Node -
addEventListener(event, handler, options, element){GoBrain.Node}
GoBrain.Core/src/dom.js, line 86Adds an event listener.
-
Adds an event listener.
Name Type Description eventString Event to listen to.
handlerfunction Handler to invoke when event occurs.
optionsBoolean | Object Options to use to add the event handler. If boolean, whether or not to add handler as passive, if supported.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node -
addResizeListener(handler, element){GoBrain.Node}
GoBrain.Core/src/dom.js, line 736Adds a resize listener.
-
Adds a resize listener.
Name Type Description handlerfunction Handler to invoke when resize occurs.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node -
appendChild(child, parent){GoBrain.Node}
GoBrain.Core/src/dom.js, line 101Appends a child node/element.
-
Appends a child node/element.
Name Type Description childGoBrain.Node | HTMLElement The child to append.
parentGoBrain.Node | HTMLElement optional The parent node/element to use instead of the root.
Returns:
Type Description GoBrain.Node -
attribute(attribute, value, element){GoBrain.Node|String}
GoBrain.Core/src/dom.js, line 114Gets or sets node attribute.
-
Gets or sets node attribute.
Name Type Description attributeString The name of the data attribute.
valueString optional The value of the data attribute.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node | String -
children(element){Array.<GoBrain.Node>}
GoBrain.Core/src/dom.js, line 128Gets children of node.
-
Gets children of node.
Name Type Description elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description Array.<GoBrain.Node> -
content(content, element){GoBrain.Node|*}
GoBrain.Core/src/dom.js, line 140Gets or sets node content.
-
Gets or sets node content.
Name Type Description content* optional The content to set.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node | * -
context(){GoBrain.Node}
GoBrain.Core/src/dom.js, line 153Gets the element that the dom instance was created with.
-
Gets the element that the dom instance was created with.
Returns:
Type Description GoBrain.Node -
createNode(tag, data){GoBrain.Node}
GoBrain.Core/src/dom.js, line 164Creates an element wrapped in a node.
-
Creates an element wrapped in a node.
Name Type Default Description tagString div optional The type of element to create.
dataString optional The data for the new node. Only used when creating 'text' nodes.
Returns:
Type Description GoBrain.Node -
createStyleSheet(){CSSStyleSheet}
GoBrain.Core/src/dom.js, line 177Creates a style sheet and appends it to the DOM.
-
Creates a style sheet and appends it to the DOM.
Returns:
Type Description CSSStyleSheet -
css(styles, element){GoBrain.Node}
GoBrain.Core/src/dom.js, line 195Sets node style properties.
-
Sets node style properties.
Name Type Description stylesObject.<String, *> The style properties to set.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node -
data(property, value, element){GoBrain.Node|String}
GoBrain.Core/src/dom.js, line 208Gets or sets data attribute.
-
Gets or sets data attribute.
Name Type Description propertyString The name of the data attribute.
valueString optional The value of the data attribute.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node | String -
getNodeByClass(clazz, element){GoBrain.Node|null}
GoBrain.Core/src/dom.js, line 222Gets first node beneath node that has a matching css class.
-
Gets first node beneath node that has a matching css class.
Name Type Description clazzString The class to look for.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node | null -
getNodeByGoBrainId(id, element){GoBrain.Node|null}
GoBrain.Core/src/dom.js, line 235Gets first node beneath node that has a matching GoBrain id.
-
Gets first node beneath node that has a matching GoBrain id.
Name Type Description idString The id to look for.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node | null -
getNodeById(id, element){GoBrain.Node|null}
GoBrain.Core/src/dom.js, line 250Gets first node beneath node that has a matching id.
-
Gets first node beneath node that has a matching id.
Name Type Description idString The id to look for.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node | null -
getNodesByAttributeAndValue(attribute, value, element){Array.<GoBrain.Node>}
GoBrain.Core/src/dom.js, line 263Gets all elements beneath node that have a matching attribute value pair.
-
Gets all elements beneath node that have a matching attribute value pair.
Name Type Description attributeString The attribute to look for.
valueString The attribute value to look for.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description Array.<GoBrain.Node> -
getNodesByClass(clazz, element){Array.<GoBrain.Node>}
GoBrain.Core/src/dom.js, line 277Gets all nodes beneath node that have a matching css class.
-
Gets all nodes beneath node that have a matching css class.
Name Type Description clazzString The class to look for.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description Array.<GoBrain.Node> -
getNodesById(id, element){Array.<GoBrain.Node>}
GoBrain.Core/src/dom.js, line 290Gets all nodes beneath node that have a matching id.
-
Gets all nodes beneath node that have a matching id.
Name Type Description idString The id to look for.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description Array.<GoBrain.Node> -
getTemplate(templateName, element){function}
GoBrain.Core/src/dom.js, line 303Finds and processes a markup template and creates a function that will create new instances of the template when called.
-
Finds and processes a markup template and creates a function that will create new instances of the template when called.
Name Type Description templateNameString The name of the template.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description function -
goBrainId(id, element){HTMLElement|null}
GoBrain.Core/src/dom.js, line 351Sets a node GoBrain id.
-
Sets a node GoBrain id. This id must be unique.
Name Type Description idString The unique id to set.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description HTMLElement | null -
hasAncestor(ancestor, element){Boolean}
GoBrain.Core/src/dom.js, line 375Checks if the node has a specific element as ancestor.
-
Checks if the node has a specific element as ancestor.
Name Type Description ancestorGoBrain.Node | HTMLElement The potential ancestor to check against.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description Boolean -
hasAttribute(attribute, element){Boolean}
GoBrain.Core/src/dom.js, line 388Checks if the node has a specific element as first level child.
-
Checks if the node has a specific element as first level child.
Name Type Description attributeString The attribute to look for.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description Boolean -
hasChild(child, element){Boolean}
GoBrain.Core/src/dom.js, line 401Checks if the node has a specific element as first level child.
-
Checks if the node has a specific element as first level child.
Name Type Description childGoBrain.Node | HTMLElement The potential child to check against.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description Boolean -
hasClass(clazz, element){Boolean}
GoBrain.Core/src/dom.js, line 414Checks if the node has a specific css class.
-
Checks if the node has a specific css class.
Name Type Description clazzString The css class to look for.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description Boolean -
hasDescendant(descendant, element){Boolean}
GoBrain.Core/src/dom.js, line 427Checks if the node has a specific element as descendant.
-
Checks if the node has a specific element as descendant.
Name Type Description descendantGoBrain.Node | HTMLElement The potential descendant to check against.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description Boolean -
height(value, element){GoBrain.Node|Number}
GoBrain.Core/src/dom.js, line 440Gets or sets the node height.
-
Gets or sets the node height.
Name Type Description valueNumber | String optional The new height.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node | Number -
hide(element){GoBrain.Node}
GoBrain.Core/src/dom.js, line 453Hides the node.
-
Hides the node.
Name Type Description elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node -
innerContent(content, element){GoBrain.Node|*}
GoBrain.Core/src/dom.js, line 465Gets or sets node inner content.
-
Gets or sets node inner content.
Name Type Description content* optional The content to set.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node | * -
insertAfter(newElement, element){GoBrain.Node}
GoBrain.Core/src/dom.js, line 478Inserts a node/element after the node.
-
Inserts a node/element after the node.
Name Type Description newElementGoBrain.Node | HTMLElement The node element to insert.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node -
insertBefore(newElement, element){GoBrain.Node}
GoBrain.Core/src/dom.js, line 491Inserts a node/element before the node.
-
Inserts a node/element before the node.
Name Type Description newElementGoBrain.Node | HTMLElement The node element to insert.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node -
isFullscreen(){Boolean}
GoBrain.Core/src/dom.js, line 504Checks whether the application is currently in fullscreen or not.
-
Checks whether the application is currently in fullscreen or not.
Returns:
Type Description Boolean -
matches(selector, element){Boolean}
GoBrain.Core/src/dom.js, line 528Checks if the node matches a selector.
-
Checks if the node matches a selector.
Name Type Description selectorString The selector to check against.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description Boolean -
nextSibling(element){GoBrain.Node|null}
GoBrain.Core/src/dom.js, line 541Gets the node's next sibling.
-
Gets the node's next sibling.
Name Type Description elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node | null -
parent(element){GoBrain.Node}
GoBrain.Core/src/dom.js, line 553Gets the node's parent node.
-
Gets the node's parent node.
Name Type Description elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node -
previousSibling(element){GoBrain.Node|null}
GoBrain.Core/src/dom.js, line 565Gets the node's previous sibling.
-
Gets the node's previous sibling.
Name Type Description elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node | null -
query(query, element){Array.<GoBrain.Node>}
GoBrain.Core/src/dom.js, line 577Gets all nodes beneath node that have a matching query.
-
Gets all nodes beneath node that have a matching query.
Name Type Description queryString The query to look for.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description Array.<GoBrain.Node> -
remove(element){null}
GoBrain.Core/src/dom.js, line 590Removes the node.
-
Removes the node.
Name Type Description elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description null -
removeChild(child, parent){GoBrain.Node}
GoBrain.Core/src/dom.js, line 602Removes a child from the node.
-
Removes a child from the node.
Name Type Description childGoBrain.Node | HTMLElement The child to remove.
parentGoBrain.Node | HTMLElement optional The parent node/element to use instead of the root.
Returns:
Type Description GoBrain.Node -
removeClass(clazz, element){GoBrain.Node}
GoBrain.Core/src/dom.js, line 615Removes a css class from the node.
-
Removes a css class from the node.
Name Type Description clazzString The css class to remove.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node -
removeEventListener(event, handler, options, element){GoBrain.Node}
GoBrain.Core/src/dom.js, line 628Removes an event listener.
-
Removes an event listener.
Name Type Description eventString Event to remove listener from.
handlerfunction Handler to remove.
optionsBoolean | Object Options to use to remove the event handler. If boolean, whether or not to remove passive handler, if supported.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node -
removeResizeListener(handler, element)
GoBrain.Core/src/dom.js, line 776Removes a resize listener.
-
Removes a resize listener.
Name Type Description handlerfunction Handler to remove.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
-
show(element){GoBrain.Node}
GoBrain.Core/src/dom.js, line 643Shows the node.
-
Shows the node.
Name Type Description elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node -
style(property, value, element){GoBrain.Node|*}
GoBrain.Core/src/dom.js, line 655Gets or sets a node style property.
-
Gets or sets a node style property.
Name Type Description propertyString The style property name.
value* optional The style property value.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node | * -
toggleClass(clazz, element){GoBrain.Node}
GoBrain.Core/src/dom.js, line 669Toggles a css class, if the node has the class it will be removed otherwise it will be added.
-
Toggles a css class, if the node has the class it will be removed otherwise it will be added.
Name Type Description clazzString The css class to toggle.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node -
width(value, element){GoBrain.Node|Number}
GoBrain.Core/src/dom.js, line 682Gets or sets the node width.
-
Gets or sets the node width.
Name Type Description valueNumber | String optional The new width.
elementGoBrain.Node | HTMLElement optional The node/element to use instead of the root.
Returns:
Type Description GoBrain.Node | Number