Skip to content

Commit

Permalink
Upstream the outerHTML property from DOM Parsing and Serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewarlow committed Apr 18, 2024
1 parent 95cb883 commit e63884f
Showing 1 changed file with 75 additions and 8 deletions.
83 changes: 75 additions & 8 deletions source
Expand Up @@ -3193,8 +3193,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<dfn data-x-href="https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-descendant">shadow-including inclusive descendant</dfn>, and
<dfn data-x-href="https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-ancestor">shadow-including inclusive ancestor</dfn> concepts</li>
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-tree-first-child">first child</dfn>,
<dfn data-x-href="https://dom.spec.whatwg.org/#concept-tree-next-sibling">next sibling</dfn>, and
<dfn data-x-href="https://dom.spec.whatwg.org/#concept-tree-previous-sibling">previous sibling</dfn> concepts</li>
<dfn data-x-href="https://dom.spec.whatwg.org/#concept-tree-next-sibling">next sibling</dfn>,
<dfn data-x-href="https://dom.spec.whatwg.org/#concept-tree-previous-sibling">previous sibling</dfn>, and
<dfn data-x-href="https://dom.spec.whatwg.org/#concept-tree-parent">parent</dfn> concepts</li>
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#parent-element">parent element</dfn> concept</li>
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#document-element">document element</dfn> concept</li>
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#in-a-document-tree">in a document tree</dfn>, <dfn data-x-href="https://dom.spec.whatwg.org/#in-a-document">in a document</dfn> (legacy), and <dfn data-x-href="https://dom.spec.whatwg.org/#connected">connected</dfn> concepts</li>
Expand Down Expand Up @@ -3369,7 +3370,6 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<ref>DOMPARSING</ref></p>

<ul class="brief">
<li><dfn data-x="dom-outerHTML" data-x-href="https://w3c.github.io/DOM-Parsing/#dom-element-outerhtml"><code>outerHTML</code></dfn></li>
<li><dfn data-x="xml-serialization" data-x-href="https://w3c.github.io/DOM-Parsing/#dfn-xml-serialization"><code>XML serialization</code></dfn></li>
</ul>

Expand Down Expand Up @@ -61875,8 +61875,8 @@ interface <dfn interface>HTMLScriptElement</dfn> : <span>HTMLElement</span> {
<p class="note">When inserted using the <code data-x="dom-document-write">document.write()</code>
method, <code>script</code> elements <a href="#document-written-scripts-intervention">usually</a>
execute (typically blocking further script execution or HTML parsing). When inserted using the
<code data-x="dom-element-innerHTML">innerHTML</code> and <code data-x="dom-outerHTML">outerHTML</code>
attributes, they do not execute at all.</p>
<code data-x="dom-element-innerHTML">innerHTML</code> and <code
data-x="dom-element-outerHTML">outerHTML</code> attributes, they do not execute at all.</p>

<p>The <code data-x="attr-script-defer">defer</code> attribute may be specified even if the <code
data-x="attr-script-async">async</code> attribute is specified, to cause legacy web browsers that
Expand Down Expand Up @@ -63293,10 +63293,9 @@ not-slash = %x0000-002E / %x0030-10FFFF
<li>Let <var>s</var> be the <span>child text content</span> of the <code>noscript</code>
element.</li>

<li>Set the <code data-x="dom-outerHTML">outerHTML</code> attribute of the
<li>Set the <code data-x="dom-element-outerHTML">outerHTML</code> attribute of the
<code>noscript</code> element to the value of <var>s</var>. (This, as a side-effect, causes
the <code>noscript</code> element to be removed from the document.)
<ref>DOMPARSING</ref></li>
the <code>noscript</code> element to be removed from the document.)</li>
</ol>
</li>
</ol>
Expand Down Expand Up @@ -112353,6 +112352,7 @@ document.body.appendChild(frame)</code></pre>
DOMString <span data-x="dom-Element-getHTML">getHTML</span>(optional <span>GetHTMLOptions</span> options = {});

[<span>CEReactions</span>] attribute [<span>LegacyNullToEmptyString</span>] <span data-x="tt-htmlstring">HTMLString</span> <span data-x="dom-Element-innerHTML">innerHTML</span>;
[<span>CEReactions</span>] attribute [<span>LegacyNullToEmptyString</span>] <span data-x="tt-htmlstring">HTMLString</span> <span data-x="dom-Element-outerHTML">outerHTML</span>;
};

partial interface <span id="ShadowRoot-partial">ShadowRoot</span> {
Expand Down Expand Up @@ -112794,6 +112794,73 @@ enum <dfn enum>DOMParserSupportedType</dfn> {

</div>

<h4>The <code data-x="dom-element-outerHTML">outerHTML</code> property</h4>

<p class="XXX">The <code data-x="dom-element-outerHTML">outerHTML</code> property 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.</p>

<dl class="domintro">
<dt><code data-x=""><var>element</var>.<span subdfn data-x="dom-Element-outerHTML">outerHTML</span></code></dt>
<dd>
<p>Returns a fragment of HTML or XML that represents the element and its contents.</p>

<p>In the case of an XML document, throws a <span>"<code>InvalidStateError</code>"</span>
<code>DOMException</code> if the element cannot be serialized to XML.</p>
</dd>

<dt><code data-x=""><var>element</var>.<span data-x="dom-Element-outerHTML">outerHTML</span> = <var>value</var></code></dt>
<dd>
<p>Replaces the element with nodes parsed from the given string.</p>

<p>In the case of an XML document, throws a <span>"<code>SyntaxError</code>"</span>
<code>DOMException</code> if the given string is not well-formed.</p>

<p>Throws a <span>"<code>NoModificationAllowedError</code>"</span> <code>DOMException</code> if
the parent of the element is a <span><code>Document</code></span>.</p>
</dd>
</dl>

<p class="warning">This property's setter performs no sanitization to remove potentially-dangerous
elements and attributes like <code>script</code> or <span>event handler content
attributes</span>.</p>

<div w-nodev>

<p><code>Element</code>'s <dfn attribute for="Element"><code
data-x="dom-Element-outerHTML">outerHTML</code></dfn> getter steps are:</p>

<ol>
<li><p>Let <var>element</var> be a fictional node whose only child is <span>this</span>.</p></li>
<li><p>Return the result of running <span>fragment serializing algorithm steps</span> with
<var>element</var> and true.
</ol>

<p><code>Element</code>'s <code data-x="dom-Element-outerHTML">outerHTML</code> setter steps
are:</p>

<ol>
<li><p>Let <var>parent</var> be <span>this</span>'s <span>parent</span>.</p></li>

<li><p>If <var>parent</var> is null, return. There would be no way to obtain a
reference to the nodes created even if the remaining steps were run.</p></li>

<li><p>If <var>parent</var> is a <code>Document</code>, throw a
<span>"<code>NoModificationAllowedError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>If <var>parent</var> is a <code>DocumentFragment</code>, set <var>parent</var> to the
result of <span data-x="create an element">creating an element</span> given <span>this</span>'s
<span>node document</span>, <code>body</code>, and the <span>HTML namespace</span>.</p></li>

<li><p>Let <var>fragment</var> be the result of invoking the <span>fragment parsing algorithm
steps</span> given <var>parent</var> and the given value.</p></li>

<li><p><span data-x="concept-node-replace">Replace</span> <span>this</span> with
<var>fragment</var> within <span>this</span>'s <span>parent</span>.</p></li>
</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

0 comments on commit e63884f

Please sign in to comment.