• This function takes a prefix as parameter and returns the namespace URI associated with it on the given node if found (and null if not).

    Different to direct invocation of node.lookupNamespaceURI this method applies a different behavior for an unset prefix (null or empty). Short, it can be summarized as: Try again by retrieving namespaceURI from documentElement and assume that this represents the default namespace, unless documentElement is prefixed.

    In detail, this hides some implementation detail, that is different in browsers (e.g., Chrome 109 vs. Firefox 109): While Chrome will almost never return null for an empty prefix, Firefox will return null almost always despite for an XML document with given prefix (tested for results of DOMParser.parseFromString()).

    Thus, this function forwards to browser behavior, and intervenes, if the fallback algorithm may provide a better result.

    For a non-empty prefix, the behavior is the same as node.lookupNamespaceURI.

    Parameters

    • node: Node

      node to lookup namespace URI at

    • prefix: null | string = null

      prefix to look up; defaults to null

    • force: boolean = false

      if true (defaults to false), always uses the fallback algorithm for empty/unset prefix

    Returns null | string