Skip to content

Cloning nodes using XQUF upper-cases the name of HTML elementsΒ #667

@bwrrp

Description

@bwrrp

The native HTML DOM has the quirky behavior of upper-casing the nodeName property of any element in the HTML namespace. Unfortunately, by default FontoXPath uses the nodeName in order to clone elements (see https://github.com/FontoXML/fontoxpath/blob/master/src/domClone/deepCloneNode.ts#L42). The result is that when run against a DOM implementation that follows this behavior, such as the native DOM in browsers, cloned nodes unintentionally have their localName and (if applicable) prefix upper-cased relative to their originals.

Consider the following example, ran against the XPath playground with e aliased to evaluateUpdatingExpression (using a temporary breakpoint):

(await e('//*:fds-state-message', document.documentElement)).xdmValue[0].localName
> "fds-state-message" 

(await e('<div>{//*:fds-state-message}</div>', document.documentElement)).xdmValue[0].firstChild.localName
> "FDS-STATE-MESSAGE" 

I think the easiest way to avoid this would be to re-implement the nodeName construction ourselves in DomFacade#getNodeName (https://github.com/FontoXML/fontoxpath/blob/master/src/domFacade/DomFacade.ts#L244), at least for element nodes, by combining the node's prefix (if present) with its localName.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions