Skip to content

Commit

Permalink
Editorial: createDocument should not invoke createElementNS directly
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk committed Apr 8, 2016
1 parent 2168da2 commit 4d5ae94
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 39 deletions.
51 changes: 25 additions & 26 deletions dom.bs
Expand Up @@ -4699,9 +4699,8 @@ invoked, must run these steps:
<li>Return <var>element</var>.
</ol>

The
<dfn method for=Document><code>createElementNS(<var>namespace</var>, <var>qualifiedName</var>, <var>options</var>)</code></dfn>
method, when invoked, must run these steps:
<p>The <dfn>internal <code>createElementNS</code> steps</dfn>, given <var>document</var>,
<var>namespace</var>, <var>qualifiedName</var>, and <var>options</var>, are as follows:

<ol>
<li>Let <var>namespace</var>, <var>prefix</var>, and <var>localName</var> be the result of passing
Expand All @@ -4718,16 +4717,22 @@ method, when invoked, must run these steps:
<li>If <var>is</var> is non-null and <var>definition</var> is null, then <a>throw</a> a
{{NotFoundError}}.

<li>Let <var>element</var> be the result of <a>creating an element</a> given the
<a>context object</a>, <var>localName</var>, <var>prefix</var>, <var>namespace</var>,
<var>is</var>, and with the <var>synchronous custom elements</var> flag set. Rethrow any exceptions.
<li><p>Let <var>element</var> be the result of <a>creating an element</a> given
<var>document</var>, <var>localName</var>, <var>prefix</var>, <var>namespace</var>, <var>is</var>,
and with the <var>synchronous custom elements</var> flag set. Rethrow any exceptions.

<li>If <var>is</var> is non-null, then <a>set an attribute value</a> for <var>element</var> using
"<code>is</code>" and <var>is</var>.

<li>Return <var>element</var>.
</ol>

<p>The
<dfn method for=Document><code>createElementNS(<var>namespace</var>, <var>qualifiedName</var>, <var>options</var>)</code></dfn>
method, when invoked, must return the result of running the
<a>internal <code>createElementNS</code> steps</a>, given <a>context object</a>,
<var>namespace</var>, <var>qualifiedName</var>, and <var>options</var>.

The <dfn method for=Document><code>createDocumentFragment()</code></dfn> method, when invoked,
must return a new {{DocumentFragment}} <a>node</a> with its <a>node document</a> set to the
<a>context object</a>.
Expand Down Expand Up @@ -5023,7 +5028,7 @@ interface DOMImplementation {
<a>doctype</a>.

This method throws the same exceptions as the {{createElementNS()}} method, when
invoked with the same arguments.
invoked with <var>namespace</var> and <var>qualifiedName</var>.

<dt><code><var>doc</var> = <var>document</var> . {{Document/implementation}} . <a lt="createHTMLDocument()">createHTMLDocument([<var>title</var>])</a></code>

Expand Down Expand Up @@ -5053,40 +5058,34 @@ method, when invoked, must run these steps:
<code><a type>PubidChar</a></code> production or that <var>systemId</var> does not contain both a
'<code>"</code>' and a "<code>'</code>".

The
<dfn method for="DOMImplementation">createDocument(<var>namespace</var>, <var>qualifiedName</var>, <var>doctype</var>)</dfn>
method must run these steps:
<p>The
<dfn method for=DOMImplementation><code>createDocument(<var>namespace</var>, <var>qualifiedName</var>, <var>doctype</var>)</code></dfn>
method, when invoked, must run these steps:

<ol>
<li>
Let <var>document</var> be a new {{XMLDocument}}.
<p>Let <var>document</var> be a new {{XMLDocument}}.

<p class="note no-backref">This method creates an {{XMLDocument}} rather than a normal
<a>document</a>. They are identical except for the addition of the
{{XMLDocument/load()}} method deployed content relies upon.
[[!HTML]]

<li>Let <var>element</var> be null.
<li><p>Let <var>element</var> be null.

<li>If <var>qualifiedName</var> is not the empty string, set
<var>element</var> to the result of invoking the
{{Document/createElementNS()}} method
with the arguments <var>namespace</var> and
<var>qualifiedName</var> on <var>document</var>. Rethrow any exceptions.
<!-- XXX needs cleanup -->
<li><p>If <var>qualifiedName</var> is not the empty string, then set <var>element</var> to the
result of running the <a>internal <code>createElementNS</code> steps</a>, given
<var>document</var>, <var>namespace</var>, <var>qualifiedName</var>, and an empty dictionary.
Rethrow any exceptions.

<li>If <var>doctype</var> is not null,
<a>append</a>
<var>doctype</var> to <var>document</var>.
<li><p>If <var>doctype</var> is non-null, <a>append</a> <var>doctype</var> to <var>document</var>.

<li>If <var>element</var> is not null,
<a>append</a>
<var>element</var> to <var>document</var>.
<li><p>If <var>element</var> is non-null, <a>append</a> <var>element</var> to <var>document</var>.

<li><var>document</var>'s <a>origin</a> is the <a>origin</a> of the <a>context object</a>'s
<li><p><var>document</var>'s <a>origin</a> is the <a>origin</a> of the <a>context object</a>'s
associated <a>document</a>. [[!HTML]]

<li>Return <var>document</var>.
<li><p>Return <var>document</var>.
</ol>

The
Expand Down
37 changes: 24 additions & 13 deletions dom.html
Expand Up @@ -2609,19 +2609,22 @@ <h3 class="heading settled" data-level="4.5" id="interface-document"><span class
"<code>is</code>" and <var>is</var>.
<li>Return <var>element</var>.
</ol>
<p>The <dfn class="idl-code" data-dfn-for="Document" data-dfn-type="method" data-export="" data-lt="createElementNS(namespace, qualifiedName, options)|createElementNS(namespace, qualifiedName)" id="dom-document-createelementns"><code>createElementNS(<var>namespace</var>, <var>qualifiedName</var>, <var>options</var>)</code><a class="self-link" href="#dom-document-createelementns"></a></dfn> method, when invoked, must run these steps:</p>
<p>The <dfn data-dfn-type="dfn" data-noexport="" id="internal-createelementns-steps">internal <code>createElementNS</code> steps<a class="self-link" href="#internal-createelementns-steps"></a></dfn>, given <var>document</var>, <var>namespace</var>, <var>qualifiedName</var>, and <var>options</var>, are as follows: </p>
<ol>
<li>Let <var>namespace</var>, <var>prefix</var>, and <var>localName</var> be the result of passing <var>namespace</var> and <var>qualifiedName</var> to <a data-link-type="dfn" href="#validate-and-extract">validate and extract</a>. Rethrow any
exceptions.
<li>Let <var>is</var> be the value of <code>is</code> member of <var>options</var>, or null if no
such member exists.
<li>Let <var>definition</var> be the result of <a data-link-type="dfn" href="https://rawgit.com/w3c/webcomponents/15a203c8393aef0df7223ab1d43406aa11a7e71e/spec/custom/index.html#dfn-look-up-custom-element-definition">looking up a custom element definition</a>, given the <a data-link-type="dfn" href="#context-object">context object</a>, <var>namespace</var>, <var>localName</var>, and <var>is</var>.
<li>If <var>is</var> is non-null and <var>definition</var> is null, then <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#notfounderror">NotFoundError</a></code>.
<li>Let <var>element</var> be the result of <a data-link-type="dfn" href="#concept-create-element">creating an element</a> given the <a data-link-type="dfn" href="#context-object">context object</a>, <var>localName</var>, <var>prefix</var>, <var>namespace</var>, <var>is</var>, and with the <var>synchronous custom elements</var> flag set. Rethrow any exceptions.
<li>
<p>Let <var>element</var> be the result of <a data-link-type="dfn" href="#concept-create-element">creating an element</a> given <var>document</var>, <var>localName</var>, <var>prefix</var>, <var>namespace</var>, <var>is</var>,
and with the <var>synchronous custom elements</var> flag set. Rethrow any exceptions. </p>
<li>If <var>is</var> is non-null, then <a data-link-type="dfn" href="#concept-element-attributes-set-value">set an attribute value</a> for <var>element</var> using
"<code>is</code>" and <var>is</var>.
<li>Return <var>element</var>.
</ol>
<p>The <dfn class="idl-code" data-dfn-for="Document" data-dfn-type="method" data-export="" data-lt="createElementNS(namespace, qualifiedName, options)|createElementNS(namespace, qualifiedName)" id="dom-document-createelementns"><code>createElementNS(<var>namespace</var>, <var>qualifiedName</var>, <var>options</var>)</code><a class="self-link" href="#dom-document-createelementns"></a></dfn> method, when invoked, must return the result of running the <a data-link-type="dfn" href="#internal-createelementns-steps">internal <code>createElementNS</code> steps</a>, given <a data-link-type="dfn" href="#context-object">context object</a>, <var>namespace</var>, <var>qualifiedName</var>, and <var>options</var>. </p>
<p>The <dfn class="idl-code" data-dfn-for="Document" data-dfn-type="method" data-export="" id="dom-document-createdocumentfragment"><code>createDocumentFragment()</code><a class="self-link" href="#dom-document-createdocumentfragment"></a></dfn> method, when invoked,
must return a new <code class="idl"><a data-link-type="idl" href="#documentfragment">DocumentFragment</a></code> <a data-link-type="dfn" href="#concept-node">node</a> with its <a data-link-type="dfn" href="#concept-node-document">node document</a> set to the <a data-link-type="dfn" href="#context-object">context object</a>.</p>
<p>The <dfn class="idl-code" data-dfn-for="Document" data-dfn-type="method" data-export="" id="dom-document-createtextnode"><code>createTextNode(<var>data</var>)</code><a class="self-link" href="#dom-document-createtextnode"></a></dfn> method, when
Expand Down Expand Up @@ -2806,7 +2809,7 @@ <h4 class="heading settled" data-level="4.5.1" id="interface-domimplementation">
Returns an <code class="idl"><a data-link-type="idl" href="#xmldocument">XMLDocument</a></code>, with a <a data-link-type="dfn" href="#document-element">document element</a> whose <a data-link-type="dfn" href="#concept-element-local-name">local name</a> is <var>qualifiedName</var> and whose <a data-link-type="dfn" href="#concept-element-namespace">namespace</a> is <var>namespace</var> (unless <var>qualifiedName</var> is the
empty string), and with <var>doctype</var>, if it is given, as its <a data-link-type="dfn" href="#concept-doctype">doctype</a>.
<p>This method throws the same exceptions as the <code class="idl"><a data-link-type="idl" href="#dom-document-createelementns">createElementNS()</a></code> method, when
invoked with the same arguments.</p>
invoked with <var>namespace</var> and <var>qualifiedName</var>.</p>
<dt><code><var>doc</var> = <var>document</var> . <code class="idl"><a data-link-type="idl" href="#dom-document-implementation">implementation</a></code> . <a data-link-type="functionish" href="#dom-domimplementation-createhtmldocument">createHTMLDocument([<var>title</var>])</a></code>
<dd> Returns a <a data-link-type="dfn" href="#concept-document">document</a>, with a basic <a data-link-type="dfn" href="#concept-tree">tree</a> already constructed including a <code><a data-link-type="element" href="https://html.spec.whatwg.org/multipage/semantics.html#the-title-element">title</a></code> element, unless the <var>title</var> argument is omitted.
</dl>
Expand All @@ -2821,19 +2824,26 @@ <h4 class="heading settled" data-level="4.5.1" id="interface-domimplementation">
</ol>
<p class="note" role="note">No check is performed that <var>publicId</var> code points match the <code><a class="css" data-link-type="type" href="https://www.w3.org/TR/xml/#NT-PubidChar">PubidChar</a></code> production or that <var>systemId</var> does not contain both a
'<code>"</code>' and a "<code>'</code>". </p>
<p>The <dfn class="idl-code" data-dfn-for="DOMImplementation" data-dfn-type="method" data-export="" data-lt="createDocument(namespace, qualifiedName, doctype)|createDocument(namespace, qualifiedName)" id="dom-domimplementation-createdocument">createDocument(<var>namespace</var>, <var>qualifiedName</var>, <var>doctype</var>)<a class="self-link" href="#dom-domimplementation-createdocument"></a></dfn> method must run these steps:</p>
<p>The <dfn class="idl-code" data-dfn-for="DOMImplementation" data-dfn-type="method" data-export="" data-lt="createDocument(namespace, qualifiedName, doctype)|createDocument(namespace, qualifiedName)" id="dom-domimplementation-createdocument"><code>createDocument(<var>namespace</var>, <var>qualifiedName</var>, <var>doctype</var>)</code><a class="self-link" href="#dom-domimplementation-createdocument"></a></dfn> method, when invoked, must run these steps: </p>
<ol>
<li>
Let <var>document</var> be a new <code class="idl"><a data-link-type="idl" href="#xmldocument">XMLDocument</a></code>.
<p>Let <var>document</var> be a new <code class="idl"><a data-link-type="idl" href="#xmldocument">XMLDocument</a></code>. </p>
<p class="note no-backref" role="note">This method creates an <code class="idl"><a data-link-type="idl" href="#xmldocument">XMLDocument</a></code> rather than a normal <a data-link-type="dfn" href="#concept-document">document</a>. They are identical except for the addition of the <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/dom.html#dom-xmldocument-load">load()</a></code> method deployed content relies upon. <a data-link-type="biblio" href="#biblio-html">[HTML]</a> </p>
<li>Let <var>element</var> be null.
<li>If <var>qualifiedName</var> is not the empty string, set <var>element</var> to the result of invoking the <code class="idl"><a data-link-type="idl" href="#dom-document-createelementns">createElementNS()</a></code> method
with the arguments <var>namespace</var> and <var>qualifiedName</var> on <var>document</var>. Rethrow any exceptions.
<li>If <var>doctype</var> is not null, <a data-link-type="dfn" href="#concept-node-append">append</a> <var>doctype</var> to <var>document</var>.
<li>If <var>element</var> is not null, <a data-link-type="dfn" href="#concept-node-append">append</a> <var>element</var> to <var>document</var>.
<li><var>document</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#concept-origin">origin</a> is the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#concept-origin">origin</a> of the <a data-link-type="dfn" href="#context-object">context object</a>’s
associated <a data-link-type="dfn" href="#concept-document">document</a>. <a data-link-type="biblio" href="#biblio-html">[HTML]</a>
<li>Return <var>document</var>.
<li>
<p>Let <var>element</var> be null. </p>
<li>
<p>If <var>qualifiedName</var> is not the empty string, then set <var>element</var> to the
result of running the <a data-link-type="dfn" href="#internal-createelementns-steps">internal <code>createElementNS</code> steps</a>, given <var>document</var>, <var>namespace</var>, <var>qualifiedName</var>, and an empty dictionary.
Rethrow any exceptions. </p>
<li>
<p>If <var>doctype</var> is non-null, <a data-link-type="dfn" href="#concept-node-append">append</a> <var>doctype</var> to <var>document</var>. </p>
<li>
<p>If <var>element</var> is non-null, <a data-link-type="dfn" href="#concept-node-append">append</a> <var>element</var> to <var>document</var>. </p>
<li>
<p><var>document</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#concept-origin">origin</a> is the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#concept-origin">origin</a> of the <a data-link-type="dfn" href="#context-object">context object</a>’s
associated <a data-link-type="dfn" href="#concept-document">document</a>. <a data-link-type="biblio" href="#biblio-html">[HTML]</a> </p>
<li>
<p>Return <var>document</var>. </p>
</ol>
<p>The <dfn class="idl-code" data-dfn-for="DOMImplementation" data-dfn-type="method" data-export="" data-lt="createHTMLDocument(title)|createHTMLDocument()" id="dom-domimplementation-createhtmldocument"><code>createHTMLDocument(<var>title</var>)</code><a class="self-link" href="#dom-domimplementation-createhtmldocument"></a></dfn> method, when invoked, must run these steps:</p>
<ol>
Expand Down Expand Up @@ -5413,6 +5423,7 @@ <h3 class="no-num no-ref heading settled" id="index-defined-here"><span class="c
<li><a href="#dom-characterdata-insertdata">insertData(offset, data)</a><span>, in §4.10</span>
<li><a href="#concept-node-insert-ext">insertion steps</a><span>, in §4.2.3</span>
<li><a href="#dom-range-insertnode">insertNode(node)</a><span>, in §5.2</span>
<li><a href="#internal-createelementns-steps">internal createElementNS steps</a><span>, in §4.5</span>
<li><a href="#dom-documenttype-internalsubset">internalSubset</a><span>, in §8.2</span>
<li><a href="#dom-range-intersectsnode">intersectsNode(node)</a><span>, in §5.2</span>
<li><a href="#concept-event-listener-invoke">invoke</a><span>, in §3.8</span>
Expand Down

0 comments on commit 4d5ae94

Please sign in to comment.