| 283 | if ( lastNode.equals( firstNode ) ) |
| 284 | { |
| 285 | // If the last node is the same as the the first one, we must move |
| 286 | // it to the next one, otherwise the first one will not be |
| 287 | // processed. |
| 288 | lastNode = lastNode.getNextSourceNode( true ); |
| 289 | |
| 290 | // It may happen that there are no more nodes after it (the end of |
| 291 | // the document), so we must add something there to make our code |
| 292 | // simpler. |
| 293 | if ( !lastNode ) |
| 294 | { |
| 295 | lastNode = document.createText( '' ); |
| 296 | lastNode.insertAfter( firstNode ); |
| 297 | } |
| 298 | } |
| 299 | |