public final TextImpl minimize ( ) { if ( getLength ( ) == 0 ) { parent . removeChild ( this ) ; return null ; } Node previous = getPreviousSibling ( ) ; if ( previous == null || previous . getNodeType ( ) != Node . TEXT_NODE ) { return this ; } TextImpl previousText = ( TextImpl ) previous ; previousText . buffer . append ( buffer ) ; parent . removeChild ( this ) ; return previousText ; }
Tries to remove this node using itself and the previous node as context . If this node s text is empty this node is removed and null is returned . If the previous node exists and is a text node this node s text will be appended to that node s text and this node will be removed .