dojo/html (version 1.10)

Summary

TODOC

See the dojo/html reference documentation for more information.

Method Summary

  • _ContentSetter()
  • _emptyNode(node) safely removes all children of the node.
  • _secureForInnerHtml(cont) removes !DOCTYPE and title elements from the html string. khtml is picky about dom faults, you can't attach a style or <title> node as child of body must go into head, so we need to cut out those tags
  • _setNodeContent(node,cont) inserts the given content into the given node
  • set(node,cont,params) inserts (replaces) the given content into the given node. dojo/dom-construct.place(cont, node, "only") may be a better choice for simple HTML insertion.

Methods

_ContentSetter()
Defined by dojo/html
_emptyNode(node)
Defined by dojo/html

safely removes all children of the node.

Parameter Type Description
node DOMNode | String

a reference to a DOM node or an id.

Examples

Example 1

Destroy node's children byId:

require(["dojo/dom-construct"], function(domConstruct){
    domConstruct.empty("someId");
});
_secureForInnerHtml(cont)
Defined by dojo/html

removes !DOCTYPE and title elements from the html string.

khtml is picky about dom faults, you can't attach a style or <title> node as child of body must go into head, so we need to cut out those tags

Parameter Type Description
cont String

An html string for insertion into the dom

Returns:undefined
_setNodeContent(node,cont)
Defined by dojo/html

inserts the given content into the given node

Parameter Type Description
node DomNode

the parent element

cont String | DomNode | NodeList
Returns:DomNode

the parent element

set(node,cont,params)
Defined by dojo/html

inserts (replaces) the given content into the given node. dojo/dom-construct.place(cont, node, "only") may be a better choice for simple HTML insertion.

Unless you need to use the params capabilities of this method, you should use dojo/dom-construct.place(cont, node, "only"). dojo/dom-construct..place() has more robust support for injecting an HTML string into the DOM, but it only handles inserting an HTML string as DOM elements, or inserting a DOM node. dojo/dom-construct..place does not handle NodeList insertions dojo/dom-construct.place(cont, node, "only"). dojo/dom-construct.place() has more robust support for injecting an HTML string into the DOM, but it only handles inserting an HTML string as DOM elements, or inserting a DOM node. dojo/dom-construct.place does not handle NodeList insertions or the other capabilities as defined by the params object for this method.

Parameter Type Description
node DomNode

the parent element that will receive the content

cont String | DomNode | NodeList

the content to be set on the parent element. This can be an html string, a node reference or a NodeList, dojo/NodeList, Array or other enumerable list of nodes

params Object
Optional

Optional flags/properties to configure the content-setting. See dojo/html/_ContentSetter

Returns:undefined

Examples

Example 1

A safe string/node/nodelist content replacement/injection with hooks for extension Example Usage:

html.set(node, "some string");
html.set(node, contentNode, {options});
html.set(node, myNode.childNodes, {options});
Error in the documentation? Can’t find what you are looking for? Let us know!