Strophe.js
    Preparing search index...

    Function getNamespace

    • Return the XML namespace of an element.

      Prefers the serialized xmlns attribute and falls back to the DOM namespaceURI, because the two diverge depending on how the element was built and neither is reliable on its own:

      • Locally-built stanzas ($iq, stx, Builder) are created with createElement and carry their namespace only in the xmlns attribute; their namespaceURI is null.
      • Stanzas received over the XEP-0114 component transport are built with createElementNS and carry their namespace only on namespaceURI; the redundant xmlns attribute is omitted.
      • WebSocket / BOSH stanzas parsed by DOMParser carry both, except on child elements that inherit the default namespace without redeclaring it (those have only namespaceURI).

      Checking both is the transport-agnostic way to read an element's namespace.

      Parameters

      • elem: Element

        The element whose namespace is wanted.

      Returns string

      The namespace URI, or null if the element has none.

      Strophe.getNamespace