src/console/simpleyui.js
function(node, content, where) {
        var nodeParent = node.parentNode,
            newNode;
            
        if (content !== undefined && content !== null) {
            if (content.nodeType) { // domNode
                newNode = content;
            } else { // create from string and cache
                newNode = Y.DOM.create(content);
            }
        }

        if (where) {
            if (where.nodeType) { // insert regardless of relationship to node
                // TODO: check if node.contains(where)?
                where.parentNode.insertBefore(newNode, where);
            } else {
                switch (where) {
                    case 'replace':
                        while (node.firstChild) {
                            node.removeChild(node.firstChild);
                        }
                        if (newNode) { // allow empty content to clear node
                            node.appendChild(newNode);
                        }
                        break;
                    case 'before':
                        nodeParent.insertBefore(newNode, node);
                        break;
                    case 'after':
                        if (node.nextSibling) { // IE errors if refNode is null
                            nodeParent.insertBefore(newNode, node.nextSibling);
                        } else {
                            nodeParent.appendChild(newNode);
                        }
                        break;
                    default:
                        node.appendChild(newNode);
                }
            }
        } else {
            node.appendChild(newNode);
        }

        return newNode;
    }
function(node, content, where) {
        var nodeParent = node.parentNode,
            newNode;
            
        if (content !== undefined && content !== null) {
            if (content.nodeType) { // domNode
                newNode = content;
            } else { // create from string and cache
                newNode = Y.DOM.create(content);
            }
        }

        if (where) {
            if (where.nodeType) { // insert regardless of relationship to node
                // TODO: check if node.contains(where)?
                where.parentNode.insertBefore(newNode, where);
            } else {
                switch (where) {
                    case 'replace':
                        while (node.firstChild) {
                            node.removeChild(node.firstChild);
                        }
                        if (newNode) { // allow empty content to clear node
                            node.appendChild(newNode);
                        }
                        break;
                    case 'before':
                        nodeParent.insertBefore(newNode, node);
                        break;
                    case 'after':
                        if (node.nextSibling) { // IE errors if refNode is null
                            nodeParent.insertBefore(newNode, node.nextSibling);
                        } else {
                            nodeParent.appendChild(newNode);
                        }
                        break;
                    default:
                        node.appendChild(newNode);
                }
            }
        } else {
            node.appendChild(newNode);
        }

        return newNode;
    }
function ( node , content , where ) { var nodeParent = node . parentNode , newNode ; if ( content !== undefined && content !== null ) { if ( content . nodeType ) { // domNode newNode = content ; } else { // create from string and cache newNode = Y . DOM . create ( content ) ; } } if ( where ) { if ( where . nodeType ) { // insert regardless of relationship to node // TODO: check if node.contains(where)? where . parentNode . insertBefore ( newNode , where ) ; } else { switch ( where ) { case 'replace' : while ( node . firstChild ) { node . removeChild ( node . firstChild ) ; } if ( newNode ) { // allow empty content to clear node node . appendChild ( newNode ) ; } break ; case 'before' : nodeParent . insertBefore ( newNode , node ) ; break ; case 'after' : if ( node . nextSibling ) { // IE errors if refNode is null nodeParent . insertBefore ( newNode , node . nextSibling ) ; } else { nodeParent . appendChild ( newNode ) ; } break ; default : node . appendChild ( newNode ) ; } } } else { node . appendChild ( newNode ) ; } return newNode ; }
Inserts content in a node at the given location
@method addHTML
@param {HTMLElement} node The node to insert into
@param {String | HTMLElement} content The content to be inserted
@param {String | HTMLElement} where Where to insert the content
If no "where" is given, content is appended to the node
Possible values for "where"
<dl>
<dt>HTMLElement</dt>
<dd>The element to insert before</dd>
<dt>"replace"</dt>
<dd>Replaces the existing HTML</dd>
<dt>"before"</dt>
<dd>Inserts before the existing HTML</dd>
<dt>"before"</dt>
<dd>Inserts content before the node</dd>
<dt>"after"</dt>
<dd>Inserts content after the node</dd>
</dl>
Inserts content in a node at the given location