MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit / normalize

Method normalize

src/main/java/org/htmlunit/html/DomNode.java:417–441  ·  view source on GitHub ↗

{@inheritDoc}

()

Source from the content-addressed store, hash-verified

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}

Callers 1

normalizeDocumentMethod · 0.45

Calls 7

getFirstChildMethod · 0.95
getNextSiblingMethod · 0.95
getTextContentMethod · 0.95
removeMethod · 0.95
appendMethod · 0.45
setDataMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected