Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream XMLSerializer from DOM Parsing spec #11077

Merged
merged 3 commits into from
Feb 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -116300,6 +116300,55 @@ enum <dfn enum>DOMParserSupportedType</dfn> {

</div>

<h4>The <code>XMLSerializer</code> interface</h4>

<p class="XXX">The <code>XMLSerializer</code> interface has a number of outstanding issues in the
<cite>DOM Parsing and Serialization</cite> <a
href="https://github.com/w3c/DOM-Parsing/issues">issue tracker</a>, documenting various problems
with its specification. The remainder of <cite>DOM Parsing and Serialization</cite> will be
gradually upstreamed to this specification.</p>

<dl class="domintro">
<dt><code data-x=""><var>xmlSerializer</var> = new <span subdfn data-x="dom-XMLSerializer-constructor">XMLSerializer</span>()</code></dt>
<dd><p>Constructs a new <code>XMLSerializer</code> object.</p></dd>

<dt><code data-x=""><var>string</var> = <var>xmlSerializer</var>.<span subdfn data-x="dom-XMLSerializer-serializeToString">serializeToString</span>(<var>root</var>)</code></dt>
<dd>
<p>Returns the result of serializing <var>root</var> to XML.</p>

<p>Throws an <span>"<code>InvalidStateError</code>"</span> <code>DOMException</code> if
<var>root</var> cannot be serialized to XML.</p>
</dd>
</dl>

<p class="note">The design of <code>XMLSerializer</code>, as a class that needs to be constructed
and then have its <code data-x="dom-XMLSerializer-serializeToString">serializeToString()</code>
method called, is an unfortunate historical artifact. If we were designing this functionality
today it would be a standalone function.</p>

<pre><code class="idl">[Exposed=Window]
interface <dfn interface>XMLSerializer</dfn> {
<span data-x="dom-XMLSerializer-constructor">constructor</span>();

DOMString <span data-x="dom-XMLSerializer-serializeToString">serializeToString</span>(<code>Node</code> root);
};</code></pre>

<div w-nodev>

<p>The <dfn data-x="dom-XMLSerializer-constructor"><code>new XMLSerializer()</code></dfn>
constructor steps are to do nothing.</p>

<p>The <dfn method for="XMLSerializer"
data-x="dom-XMLSerializer-serializeToString"><code>serializeToString(<var>root</var>)</code></dfn>
method steps are:</p>

<ol>
<li><p>Return the <span data-x="xml-serialization">XML serialization</span> of <var>root</var>
given false.</p></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false is not a variable.

</ol>

</div>

<h3 split-filename="timers-and-user-prompts" id="timers">Timers</h3>

<p>The <code data-x="dom-setTimeout">setTimeout()</code> and <code
Expand Down