{@inheritDoc}
()
| 415 | * {@inheritDoc} |
| 416 | */ |
| 417 | @Override |
| 418 | public void normalize() { |
| 419 | for (DomNode child = getFirstChild(); child != null; child = child.getNextSibling()) { |
| 420 | if (child instanceof DomText) { |
| 421 | final StringBuilder dataBuilder = new StringBuilder(); |
| 422 | DomNode toRemove = child; |
| 423 | DomText firstText = null; |
| 424 | //IE removes all child text nodes, but FF preserves the first |
| 425 | while (toRemove instanceof DomText && !(toRemove instanceof DomCDataSection)) { |
| 426 | final DomNode nextChild = toRemove.getNextSibling(); |
| 427 | dataBuilder.append(toRemove.getTextContent()); |
| 428 | if (firstText != null) { |
| 429 | toRemove.remove(); |
| 430 | } |
| 431 | if (firstText == null) { |
| 432 | firstText = (DomText) toRemove; |
| 433 | } |
| 434 | toRemove = nextChild; |
| 435 | } |
| 436 | if (firstText != null) { |
| 437 | firstText.setData(dataBuilder.toString()); |
| 438 | } |
| 439 | } |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | /** |
| 444 | * {@inheritDoc} |
no test coverage detected