lib/combiner.js
function merge( elem, callback ) {
		var old = find( destChildren, elem.name ),
			nl;

		// merge with old element
		if ( old ) {
			if ( typeof callback == 'function' ) {
				return callback( old );
			}

			_.merge( old.attribs, elem.attribs );

			if ( elem.children ) {
				combine( old, elem );
			}
			// append new element
		} else {
			if ( dest.children ) {
				utils.appendChild( dest, elem );
			} else {
				utils.prepend( destChildren[ 0 ], elem );
				// fix for domutils issue
				elem.parent = destChildren[ 0 ].parent;
				destChildren.unshift( elem );
				destChildren.splice( destChildren.indexOf( elem ) + 1, 0, nl );
			}
		}
	}
function merge( elem, callback ) {
		var old = find( destChildren, elem.name ),
			nl;

		// merge with old element
		if ( old ) {
			if ( typeof callback == 'function' ) {
				return callback( old );
			}

			_.merge( old.attribs, elem.attribs );

			if ( elem.children ) {
				combine( old, elem );
			}
			// append new element
		} else {
			if ( dest.children ) {
				utils.appendChild( dest, elem );
			} else {
				utils.prepend( destChildren[ 0 ], elem );
				// fix for domutils issue
				elem.parent = destChildren[ 0 ].parent;
				destChildren.unshift( elem );
				destChildren.splice( destChildren.indexOf( elem ) + 1, 0, nl );
			}
		}
	}
function merge ( elem , callback ) { var old = find ( destChildren , elem . name ) , nl ; // merge with old element if ( old ) { if ( typeof callback == 'function' ) { return callback ( old ) ; } _ . merge ( old . attribs , elem . attribs ) ; if ( elem . children ) { combine ( old , elem ) ; } // append new element } else { if ( dest . children ) { utils . appendChild ( dest , elem ) ; } else { utils . prepend ( destChildren [ 0 ] , elem ) ; // fix for domutils issue elem . parent = destChildren [ 0 ] . parent ; destChildren . unshift ( elem ) ; destChildren . splice ( destChildren . indexOf ( elem ) + 1 , 0 , nl ) ; } } }
Merge element with equivalent found in destination
@param {Object}   elem     Source element
@param {Function} callback Callback called when equivalent found
Merge element with equivalent found in destination