Strophe.js
    Preparing search index...

    Function stripWhitespace

    • Remove the whitespace which pretty-printing put between an element's tags.

      XML written by hand (or via the Stanza template literal) is usually indented, and parsing it turns each run of indentation into a text node. Those whitespace-only text nodes are formatting, not content, so they're removed. Whitespace which is content is kept:

      • An element whose only child is a text node keeps it, so <body> </body> survives intact.
      • A subtree marked xml:space="preserve" is left alone, per XML 1.0 ยง 2.10, until a descendant sets xml:space="default" again.
      • An XHTML-IM <body>, the one in the XHTML namespace, is left alone, since the whitespace between its inline elements separates words rather than laying them out.

      Whitespace interpolated into an stx template is content as well, but by the time the template has been concatenated into a string it can no longer be told apart from indentation. Stanza therefore marks it before parsing rather than exempting it here.

      Parameters

      • stanza: Element

      Returns Element