public/javascripts/yui/element/element.js
function(parent, before) {
        parent = (parent.get) ?  parent.get('element') : Dom.get(parent);
        
        this.fireEvent('beforeAppendTo', {
            type: 'beforeAppendTo',
            target: parent
        });
        
        
        before = (before && before.get) ? 
                before.get('element') : Dom.get(before);
        var element = this.get('element');
        
        if (!element) {
            return false;
        }
        
        if (!parent) {
            return false;
        }
        
        if (element.parent != parent) {
            if (before) {
                parent.insertBefore(element, before);
            } else {
                parent.appendChild(element);
            }
        }
        
        
        this.fireEvent('appendTo', {
            type: 'appendTo',
            target: parent
        });

        return element;
    }
function(parent, before) {
        parent = (parent.get) ?  parent.get('element') : Dom.get(parent);
        
        this.fireEvent('beforeAppendTo', {
            type: 'beforeAppendTo',
            target: parent
        });
        
        
        before = (before && before.get) ? 
                before.get('element') : Dom.get(before);
        var element = this.get('element');
        
        if (!element) {
            return false;
        }
        
        if (!parent) {
            return false;
        }
        
        if (element.parent != parent) {
            if (before) {
                parent.insertBefore(element, before);
            } else {
                parent.appendChild(element);
            }
        }
        
        
        this.fireEvent('appendTo', {
            type: 'appendTo',
            target: parent
        });

        return element;
    }
function ( parent , before ) { parent = ( parent . get ) ? parent . get ( 'element' ) : Dom . get ( parent ) ; this . fireEvent ( 'beforeAppendTo' , { type : 'beforeAppendTo' , target : parent } ) ; before = ( before && before . get ) ? before . get ( 'element' ) : Dom . get ( before ) ; var element = this . get ( 'element' ) ; if ( ! element ) { return false ; } if ( ! parent ) { return false ; } if ( element . parent != parent ) { if ( before ) { parent . insertBefore ( element , before ) ; } else { parent . appendChild ( element ) ; } } this . fireEvent ( 'appendTo' , { type : 'appendTo' , target : parent } ) ; return element ; }
Appends the HTMLElement into either the supplied parentNode.
@method appendTo
@param {HTMLElement | Element} parentNode The node to append to
@param {HTMLElement | Element} before An optional node to insert before
@return {HTMLElement} The appended DOM element.
Appends the HTMLElement into either the supplied parentNode .