NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm · #1372 most downloaded on npm
A pure JavaScript W3C standard-based (XML DOM Level 2 Core) DOMParser and XMLSerializer module.
Last release 1 months ago
21 Aug 2026
Release timing varies
gaps range from 9 days to 7 months
Nearly every release is documented
notes for 2 of 2 stable releases
52 versions withdrawn
withdrawn after publishing
5 years old
54 releases · first in 2021
One column per quarter.
Security: parsing a deeply or repeatedly namespaced document no longer consumes quadratic memory; the in-scope namespace map is inherited through the
DOMParser.parseFromString with default options. Serialized output is byte-identical. GHSA-965w-775f-mr7gNamedNodeMap parse-time dedup path uses a null-prototype membership index, so a well-formed document with a hostile number of duplicate attributes can no longer wedge the parse. Attribute order and duplicate resolution (last value wins, first position kept) are byte-identical, preserving the XML no-duplicate-attributes well-formedness constraint. GHSA-8344-3jmq-59r6GHSA-6mj3-qw4j-hgrw<, and Node.prototype.normalize() merges adjacent text nodes in O(K) instead of O(K²) (also reachable programmatically), per normalize() in the WHATWG DOM spec. DOM output is unchanged; only the reported error text differs. GHSA-93r5-fhx6-vmg9XMLSerializer.serializeToString() under { requireWellFormed: true } now rejects a DocType name that is not a valid XML Name, throwing InvalidStateError — matching the sibling publicId/systemId/internalSubset checks and preventing XML injection via DocumentType.name. GHSA-27p8-2357-5qqvXMLSerializer.serializeToString() under { requireWellFormed: true } now validates a processing-instruction target as an XML NCName and rejects a case-insensitive xml, throwing InvalidStateError — preventing PI-target injection via >, ?, or whitespace. GHSA-c7q8-3ch8-vqpvDocument.createEntityReference() now rejects an invalid XML Name at creation, and XMLSerializer.serializeToString() under { requireWellFormed: true } validates an EntityReference nodeName as an XML Name, throwing InvalidStateError — preventing XML injection via an entity-reference name. GHSA-6gmq-8vp8-gcm6requireWellFormed serializer's element- and attribute-name validators no longer treat an interior line terminator as satisfying the name anchors, so a name containing a line terminator is rejected with InvalidStateError — closing a bypass of the XML QName check. GHSA-jxjr-3g7g-3944requireWellFormed serializer's DocType publicId/systemId validators no longer treat an interior line terminator as satisfying the anchor, so an identifier containing an ECMAScript line terminator is rejected with InvalidStateError — closing a bypass of the XML PubidLiteral/SystemLiteral check. GHSA-vr34-hp96-76ppcreateElementNS(), createAttributeNS(), createDocumentType(), and createAttribute() now reject a name containing a line terminator with InvalidCharacterError, because name validation applies to the whole string — closing a creation-time bypass of the XML Name/QName production on the default serialization path. GHSA-3px3-54cx-rmw9error in XML, a warning in HTML) instead of accepting it silently, per the XML ETag production; parsing recovers to the byte-identical DOM. Consumers that want strict rejection can escalate the reported error to fatal via the parser's onError handler. GHSA-6h8r-xr42-gp59DOMExceptions raised during parsing are now reported as a fatalError, and the originating error is preserved as the cause on the resulting ParseError.Thank you,
@ericchiang,
@KarimTantawey,
@bhaswanthc,
@arpitjain099,
@Paranoidgrinch,
for your contributions
Security: XMLSerializer.serializeToString() now also rejects invalid element and attribute names when { requireWellFormed: true } is passed, throwing
XMLSerializer.serializeToString() now also rejects invalid element and attribute names when { requireWellFormed: true } is passed, throwing InvalidStateError for a name that is not a valid XML QName (this covers the namespace prefix, which surfaces in the element qualified name or in a synthesized xmlns: declaration). This prevents XML injection via createElement() / setAttribute(), extending the existing requireWellFormed checks to the serialized name set. GHSA-w2rr-34g9-rvrj GHSA-4w3w-2rp5-g8jm<?… with no closing ?>), preventing a denial-of-service (ReDoS) reachable from DOMParser.parseFromString with default options. GHSA-g53g-w8rj-fmg7CharacterData nodeValue and data are now kept in sync #990Thank you,
@bhaswanthc,
@jmestwa-coder,
@stevenobiajulu,
for your contributions
The splitCDATASections serializer option is deprecated and will be removed in the next breaking release. The automatic splitting of "]]>" in CDATASect…
XMLSerializer.serializeToString() (and Node.toString(), NodeList.toString()) now accept a requireWellFormed option. When { requireWellFormed: true } is passed, the serializer throws InvalidStateError for injection-prone node content, preventing XML injection via attacker-controlled node data. GHSA-j759-j44w-7fr8 GHSA-x6wf-f3px-wcqx GHSA-f6ww-3ggp-fr8h
data contains -- anywhere, ends with -, or contains characters outside the XML Char production: or matches xml (case-insensitive), or data contains characters outside the XML Char production or contains ?>publicId fails PubidLiteral, systemId fails SystemLiteral, or internalSubset contains ]>XMLSerializer.serializeToString(), Node.prototype.normalize(), Node.prototype.cloneNode(true), Document.prototype.importNode(node, true), node.textContent getter, getElementsByTagName() / getElementsByTagNameNS() / getElementsByClassName() / getElementById(), Node.prototype.isEqualNode()) are now iterative. Previously, deeply nested DOM trees would exhaust the JavaScript call stack and throw an unrecoverable RangeError. GHSA-2v35-w6hq-6mfwisEqualNode now correctly returns false for CDATASection nodes with different datasplitCDATASections serializer option is deprecated and will be removed in the next breaking release. The automatic splitting of "]]>" in CDATASection data was introduced as a workaround; use requireWellFormed: true or ensure CDATASection data does not contain "]]>" before serialization.Thank you,
@Jvr2022,
@praveen-kv,
@TharVid,
@decsecre583,
@tlsbollei,
@KarimTantawey,
for your contributions
implement ParentNode.children getter `#960` / `#410`
createCDATASection now throws InvalidCharacterError when data contains "]]>", as required by the WHATWG DOM spec. GHSA-wh4c-j3r5-mjhpXMLSerializer now splits CDATASection nodes whose data contains "]]>" into adjacent CDATA sections at serialization time, preventing XML injection via mutation methods (appendData, replaceData, .data =, .textContent =). GHSA-wh4c-j3r5-mjhpNode.contains #931Code that passes a string containing "]]>" to createCDATASection and relied on the previously unsafe behavior will now receive InvalidCharacterError. Use a mutation method such as appendData if you intentionally need "]]>" in a CDATASection node's data.
Thank you, @stevenobiajulu, @yoshi389111, @thesmartshadow, for your contributions
https://github.com/xmldom/xmldom/discussions/435
fix: replace \u2029 as part of normalizeLineEndings `#839` / `#838`
Implementation of hasAttributes `#804`
hasAttributes #804#802 / #803#817 / #819DOM.compareDocumentPosition #805Thank you, @zorkow, @Ponynjaa, @WesselKroos, for your contributions.
https://github.com/xmldom/xmldom/discussions/435
lower error level for unicode replacement character `#790` / `#794` / `#797`
fix: re-index childNodes on insertBefore `#763` / `#766`
restore performance for large amount of child nodes `#748` / `#760`
#748 / #760warning (#759) #754 / #759#758Thank you, @luffynando, @mattiasw, @JoinerDev, for your contributions.
restore more Node and ProcessingInstruction types `#725` / `#726`
Node and ProcessingInstruction types #725 / #726getElements* methods return LiveNodeList<Element> #731 / #734Node props #728, triggered by unclosed #724Thank you, @Ponynjaa, @ayZagen, @sserdyuk, @wydengyre, @mykola-mokhnach, @benkroeger, for your contributions.
#435
add Element.getElementsByClassName `#722`
Element.getElementsByClassName #722Thank you, @censujiang, @Mathias-S, for your contributions
#435
DOMParser.parseFromString requires mimeType as second argument `#713`
#713isHTMLMimeType in type definition #715 / #712#717 / #285 / #695#710Thank you, @krystofwoldrich, @marvinruder, @amacneil, @defunctzombie, @tjhorner, @danon, for your contributions
feat: expose all DOM level 2 element prototypes `#637` / `#40`
#637 / #40#634 / #633#692#554#550#556#697#546#524#566#644#511Thank you, @kboshold, @edi9999, @apupier, @shunkica, @homer0, @jhauga, @UdayKharatmol, for your contributions
report more non well-formed cases `#519` / `#45` / `#125` / `#467` BREAKING-CHANGE: Reports more not well-formed documents as fatalError and drop brok
#519 / #45 / #125 / #467
BREAKING-CHANGE: Reports more not well-formed documents as fatalError
and drop broken support for optional and unclosed tags in HTML.Thank you, @brodybits, @cbettinger, @josecarlosrx, for your contributions
dom: prevent iteration over deleted items `#514`/ `#499`
preserve DOCTYPE internal subset `#498` / `#497` / `#117`\ BREAKING CHANGES: Many documents that were previously accepted by xmldom, esecially non wel…
#509 / #505#498 / #497 / #117#454Thank you, @cjbarth, @shunkica, @pmahend1, @niklasl, for your contributions
BREAKING CHANGE: Previously it was possible (but not documented) to call Node.removeChild with any node in the tree, and with certain exceptions, it w…
BREAKING CHANGE: Previously it was possible (but not documented) to call Node.removeChild with any node in the tree,
and with certain exceptions, it would work. This is no longer the case: calling Node.removeChild with an argument that is not a direct child of the node that it is called from, will throw a NotFoundError DOMException, as it is described by the specs.
Thank you, @noseworthy, @davidmc24, for your contributions
BREAKING CHANGE: Iteration over attributes now happens in the right order and non-existing attributes now return null instead of undefined. THe same i…
compareDocumentPosition method from level 3 spec. #488getAttribute and getAttributeNS should return null (#477) #46#46#485 / #486#489BREAKING CHANGE: Iteration over attributes now happens in the right order and non-existing attributes now return null instead of undefined. THe same is true for the namepsaceURI and prefix of Attr nodes.
All of the changes are fixing misalignment with the DOM specs, so if you expected it to work as specified,
nothing should break for you.
Thank you, @bulandent, @zorkow, for your contributions
Properly check nodes before replacement `#457` / `#455`
Restore ES5 compatibility `#452` / `#453`
Security: Prevent inserting DOM nodes when they are not well-formed `CVE-2022-39353` In case such a DOM would be created, the part that is not well-fo…
CVE-2022-39353
In case such a DOM would be created, the part that is not well-formed will be transformed into text nodes, in which xml specific characters like < and > are encoded accordingly.
In the upcoming version 0.9.0 those text nodes will no longer be added and an error will be thrown instead.
This change can break your code, if you relied on this behavior, e.g. multiple root elements in the past. We consider it more important to align with the specs that we want to be aligned with, considering the potential security issues that might derive from people not being aware of the difference in behavior.
Related Spec: https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validitylib #448 / #190#447 / #29 / #130Thank you, @XhmikosR, @awwright, @frumioj, @cjbarth, @markgollnick for your contributions
fix: Stop adding tags after incomplete closing tag `#445` / `#416` BREAKING CHANGE: It no longer reports an error when parsing HTML containing incompl…
#445 / #416
BREAKING CHANGE: It no longer reports an error when parsing HTML containing incomplete closing tags, to align the behavior with the one in the browser.
BREAKING CHANGE: If your code relied on not well-formed XML to be parsed and include subsequent tags, this will no longer work.#440#444Thank you, @ACN-kck, @mgerlach for your contributions
Avoid iterating over prototype properties `#437` / `#436`
Thank you, @Supraja9726 for your contributions
BREAKING CHANGE: HTML rules are no longer applied just because of the namespace, but require the mimeType argument passed to DOMParser.parseFromString…
Only use HTML rules if mimeType matches #338, fixes #203
In the living specs for parsing XML and HTML, that this library is trying to implement, there is a distinction between the different types of documents being parsed: There are quite some rules that are different for parsing, constructing and serializing XML vs HTML documents.
So far xmldom was always "detecting" whether "the HTML rules should be applied" by looking at the current namespace. So from the first time an the HTML default namespace (http://www.w3.org/1999/xhtml) was found, every node was treated as being part of an HTML document. This misconception is the root cause for quite some reported bugs.
BREAKING CHANGE: HTML rules are no longer applied just because of the namespace, but require the mimeType argument passed to DOMParser.parseFromString(source, mimeType) to match 'text/html'. Doing so implies all rules for handling casing for tag and attribute names when parsing, creation of nodes and searching nodes.
BREAKING CHANGE: Correct the return type of DOMParser.parseFromString to Document | undefined. In case of parsing errors it was always possible that "the returned Document" has not been created. In case you are using Typescript you now need to handle those cases.
BREAKING CHANGE: The instance property DOMParser.options is no longer available, instead use the individual readonly property per option (assign, domHandler, errorHandler, normalizeLineEndings, locator, xmlns). Those also provides the default value if the option was not passed. The 'locator' option is now just a boolean (default remains true).
BREAKING CHANGE: The following methods no longer allow a (non spec compliant) boolean argument to toggle "HTML rules":
XMLSerializer.serializeToStringNode.toStringDocument.toStringThe following interfaces have been implemented:
DOMImplementation now implements all methods defined in the DOM spec, but not all of the behavior is implemented (see docstring):
createDocument creates an "XML Document" (prototype: Document, property type is 'xml')createHTMLDocument creates an "HTML Document" (type/prototype: Document, property type is 'html').
false no child nodes are createdDocument now has two new readonly properties as specified in the DOM spec:
contentType which is the mime-type that was used to create the documenttype which is either the string literal 'xml' or 'html'MIME_TYPE (/lib/conventions.js):
hasDefaultHTMLNamespace test if the provided string is one of the miem types that implies the default HTML namespace: text/html or application/xhtml+xmlThank you @weiwu-zhang for your contributions
Security: parsing a deeply or repeatedly namespaced document no longer consumes quadratic memory; the in-scope namespace map is inherited through the
DOMParser.parseFromString with default options. Serialized output is byte-identical. GHSA-965w-775f-mr7gNamedNodeMap parse-time dedup path uses a null-prototype membership index, so a well-formed document with a hostile number of duplicate attributes can no longer wedge the parse. Attribute order and duplicate resolution (last value wins, first position kept) are byte-identical, preserving the XML no-duplicate-attributes well-formedness constraint. GHSA-8344-3jmq-59r6ETag) is now anchored so it runs in linear time instead of backtracking quadratically on a long whitespace run, preventing a ReDoS reachable from DOMParser.parseFromString. Trimmed output is byte-identical. GHSA-x4fp-j954-r2f4<, and Node.prototype.normalize() merges adjacent text nodes in O(K) instead of O(K²) (also reachable programmatically), per normalize() in the WHATWG DOM spec. DOM output is unchanged; only the reported error text differs. GHSA-93r5-fhx6-vmg9XMLSerializer.serializeToString() under { requireWellFormed: true } now rejects a DocType name that is not a valid XML Name, throwing InvalidStateError — matching the sibling publicId/systemId/internalSubset checks and preventing XML injection via DocumentType.name. GHSA-27p8-2357-5qqvXMLSerializer.serializeToString() under { requireWellFormed: true } now validates a processing-instruction target as an XML NCName and rejects a case-insensitive xml, throwing InvalidStateError — a check 0.8.x did not previously perform, preventing PI-target injection via >, ?, or whitespace. GHSA-c7q8-3ch8-vqpvDocument.createEntityReference() now rejects an invalid XML Name at creation, and XMLSerializer.serializeToString() under { requireWellFormed: true } validates an EntityReference nodeName as an XML Name, throwing InvalidStateError — preventing XML injection via an entity-reference name. GHSA-6gmq-8vp8-gcm6error instead of accepting it silently, per the XML ETag production; parsing recovers to the byte-identical DOM. Consumers that want strict rejection can escalate the reported error to fatal via the parser's errorHandler. GHSA-6h8r-xr42-gp59Thank you,
@ericchiang,
@bhaswanthc,
@arpitjain099,
@Paranoidgrinch,
for your contributions
Security: XMLSerializer.serializeToString() now also rejects invalid element and attribute names when { requireWellFormed: true } is passed, throwing
XMLSerializer.serializeToString() now also rejects invalid element and attribute names when { requireWellFormed: true } is passed, throwing InvalidStateError for a name that is not a valid XML QName (this covers the namespace prefix, which surfaces in the element qualified name or in a synthesized xmlns: declaration). This prevents XML injection via createElement() / setAttribute(), extending the existing requireWellFormed checks to the serialized name set. GHSA-w2rr-34g9-rvrj GHSA-4w3w-2rp5-g8jmThank you,
@bhaswanthc,
@jmestwa-coder,
for your contributions
Security: XMLSerializer.serializeToString() (and Node.toString() , NodeList.toString() ) now accept a requireWellFormed option (fourth argument, after
XMLSerializer.serializeToString() (and Node.toString(), NodeList.toString()) now accept a requireWellFormed option (fourth argument, after isHtml and nodeFilter). When { requireWellFormed: true } is passed, the serializer throws InvalidStateError for injection-prone node content, preventing XML injection via attacker-controlled node data. GHSA-j759-j44w-7fr8 GHSA-x6wf-f3px-wcqx GHSA-f6ww-3ggp-fr8h
data contains -->data contains ?>publicId fails PubidLiteral, systemId fails SystemLiteral, or internalSubset contains ]>XMLSerializer.serializeToString(), Node.prototype.normalize(), Node.prototype.cloneNode(true), Document.prototype.importNode(node, true), node.textContent getter, getElementsByTagName() / getElementsByTagNameNS() / getElementsByClassName() / getElementById()) are now iterative. Previously, deeply nested DOM trees would exhaust the JavaScript call stack and throw an unrecoverable RangeError. GHSA-2v35-w6hq-6mfwThank you,
@Jvr2022,
@praveen-kv,
@TharVid,
@decsecre583,
@tlsbollei,
@KarimTantawey,
for your contributions
preserve trailing whitespace in ProcessingInstruction data `#962` / `#42`
#962 / #42createCDATASection now throws InvalidCharacterError when data contains "]]>", as required by the WHATWG DOM spec. GHSA-wh4c-j3r5-mjhpXMLSerializer now splits CDATASection nodes whose data contains "]]>" into adjacent CDATA sections at serialization time, preventing XML injection via mutation methods (appendData, replaceData, .data =, .textContent =). GHSA-wh4c-j3r5-mjhpCode that passes a string containing "]]>" to createCDATASection and relied on the previously unsafe behavior will now receive InvalidCharacterError. Use a mutation method such as appendData if you intentionally need "]]>" in a CDATASection node's data.
Thank you, @thesmartshadow, @stevenobiajulu, for your contributions
https://github.com/xmldom/xmldom/discussions/357
update ownerDocument when moving nodes between documents `#933` / `#932`
dom: prevent iteration over deleted items `#514`/ `#499`
Set nodeName property in ProcessingInstruction `#509` / `#505`
extend list of HTML entities `#489`
properly parse closing where the last attribute has no value `#485` / `#486`
Thank you, @bulandent, for your contributions
Properly check nodes before replacement `#457` / `#455` / `#456`
fix: Restore ES5 compatibility `#452` / `#453`
Thank you, @fengxinming, for your contributions
Security: Prevent inserting DOM nodes when they are not well-formed `CVE-2022-39353` In case such a DOM would be created, the part that is not well-fo…
CVE-2022-39353
In case such a DOM would be created, the part that is not well-formed will be transformed into text nodes, in which xml specific characters like < and > are encoded accordingly.
In the upcoming version 0.9.0 those text nodes will no longer be added and an error will be thrown instead.
This change can break your code, if you relied on this behavior, e.g. multiple root elements in the past. We consider it more important to align with the specs that we want to be aligned with, considering the potential security issues that might derive from people not being aware of the difference in behavior.
Related Spec: https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validityThank you, @frumioj, @cjbarth, @markgollnick for your contributions
Avoid iterating over prototype properties `#437` / `#436`
Thank you, @Supraja9726 for your contributions
fix(dom): Serialize > as specified (#395) `#58`
> as specified (#395) #58nodeType values to public interface description #396#317Object.assign ponyfill #379#378Thank you @niklasl, @cburatto, @SheetJSDev, @pyrsmk for your contributions
Only use own properties in entityMap `#374`
Normalize all line endings according to XML specs 1.0 and 1.1 \ BREAKING CHANGE: Certain combination of line break characters are normalized to a sing…
\n before parsing takes place and will no longer be preserved.
#284 / #310 \t, \n or \r in attribute values.
To preserve those you will have to create XML that instead contains the correct numerical (or hexadecimal) equivalent (e.g. 	, 
, 
).DOMImplementation and XMLSerializer from lib/dom-parser.js #53 / #309
BREAKING CHANGE: Use the one provided by the main package export.removeChild #343 / #355#325#111 / #304Thank you @marrus-sh, @victorandree, @mdierolf, @tsabbay, @fatihpense for your contributions
dom: prevent iteration over deleted items `#514`/ `#499`
Set nodeName property in ProcessingInstruction `#509` / `#505`
extend list of HTML entities `#489`
properly parse closing where the last attribute has no value `#485` / `#486`
Thank you, @bulandent, for your contributions
Properly check nodes before replacement `#457` / `#455` / `#456`
fix: Restore ES5 compatibility `#452` / `#453`
Thank you, @fengxinming, for your contributions
Security: Prevent inserting DOM nodes when they are not well-formed `CVE-2022-39353` In case such a DOM would be created, the part that is not well-fo…
CVE-2022-39353
In case such a DOM would be created, the part that is not well-formed will be transformed into text nodes, in which xml specific characters like < and > are encoded accordingly.
In the upcoming version 0.9.0 those text nodes will no longer be added and an error will be thrown instead.
This change can break your code, if you relied on this behavior, e.g. multiple root elements in the past. We consider it more important to align with the specs that we want to be aligned with, considering the potential security issues that might derive from people not being aware of the difference in behavior.
Related Spec: https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validityThank you, @frumioj, @cjbarth, @markgollnick for your contributions
Avoid iterating over prototype properties `#441` / `#437` / `#436`
Preserve default namespace when serializing `#319` / `#321` Thank you @lupestro
Restore ability to parse __prototype__ attributes `#315` Thank you @dsimpsonOMF
Add doctype when parsing from string `#277` / `#301`
Types: Add index.d.ts to packaged files `#288` Thank you @forty
Types: Copy types from DefinitelyTyped `#283` Thank you @kachkaev
Security: Misinterpretation of malicious XML input `CVE-2021-32796`
This is the release of the unscoped xmldom package that was only ever published to github, not to npm due to #271.
For the release of the scoped @xmldom/xmldom package see 0.7.0-scoped.
CVE-2021-32796Document.getElementsByClassName as specified #213, thank you @ChALkeR#268#267DOMImplementation according to recent specs #210#244#168 released in 0.6.0)localName as part of Document.createElement #229, thank you @rrthomasDue to #271 this version was published as
xmldom package to github (git tags 0.7.0 and 0.7.0+unscoped)@xmldom/xmldom package to npm (git tag 0.7.0+scoped)
For more details look at #278CVE-2021-32796Document.getElementsByClassName as specified #213, thank you, @ChALkeR#268#267DOMImplementation according to recent specs #210#244#168 released in 0.6.0)localName as part of Document.createElement #229, thank you, @rrthomasYour coding agent can read these notes before it upgrades. Set up the MCP server →