Skip to content

XMLDocument.createElement() uppercases element names #2273

Description

@BusfahrerWalter

Describe the bug

XMLDocument.createElement() uppercases element names even though XML element names are case-sensitive.

When parsing a document as text/xml, calling createElement('myNode') results in an element whose nodeName and tagName are "MYNODE" instead of "myNode".

StackBliz

To Reproduce

  1. Create an XML document:

    const doc = new DOMParser().parseFromString('<root/>', 'text/xml');
  2. Create an element:

    const element = doc.createElement('myNode');
  3. Inspect the element:

    console.log(element.nodeName);
    console.log(element.tagName);

Current output:

MYNODE
MYNODE

Expected behavior

The element name should be preserved exactly as provided when using an XMLDocument.

Expected output:

myNode
myNode

This is the behavior defined for XML documents, where element names are case-sensitive.

Device and details:

  • OS: Ubuntu 20.04.0 LTS
  • Node version: 22.22.3
  • Package version: 20.11.1

Additional context

This appears to be HTML createElement() behavior being applied to XMLDocument. Parsing existing XML preserves the original case correctly, but creating new elements programmatically does not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions