Skip to content

Commit

Permalink
Make cloning more explicit regarding attributes. Fixes #30.
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk committed Aug 4, 2015
1 parent 7936feb commit 39e6a33
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 80 deletions.
68 changes: 32 additions & 36 deletions dom.bs
Expand Up @@ -3459,40 +3459,34 @@ run these steps:
dom-Range-extractContents, dom-Range-cloneContents -->

<ol>
<li>If <var>document</var> is not given, let <var>document</var> be
<var>node</var>'s <a>node document</a>.

<li>Let <var>copy</var> be a <a>node</a>
that implements the same interfaces as <var>node</var>.
<li><p>If <var>document</var> is not given, let <var>document</var> be <var>node</var>'s
<a>node document</a>.

<li>
If <var>copy</var> is a
<a>document</a>, set its
<a>node document</a> and
<var>document</var> to <var>copy</var>.
Otherwise, set <var>copy</var>'s
<a>node document</a> to
<var>document</var>.
<p>Let <var>copy</var> be a <a>node</a> that implements the same interfaces as
<var>node</var>, and fulfills these additional requirements, switching on
<var>node</var>:

<li>
Copy the following from <var>node</var> to <var>copy</var>, depending on
the type of <var>node</var>:
<dl class=switch>
<dt>{{Document}}
<dd>Its <a for=Document>encoding</a>,
<a for=Document>content type</a>,
<a for=Document>URL</a>, <a for=Document>type</a>, and <a for=Document>mode</a>.
<dd>
<p>Set <var>copy</var>'s <a for=Document>encoding</a>,
<a for=Document>content type</a>, <a for=Document>URL</a>, <a for=Document>type</a>,
and <a for=Document>mode</a>, to those of <var>node</var>.

<dt>{{DocumentType}}
<dd>Its <a for=DocumentType>name</a>,
<a>public ID</a>, and
<a>system ID</a>.
<dd><p>Set <var>copy</var>'s <a for=DocumentType>name</a>, <a>public ID</a>, and
<a>system ID</a>, to those of <var>node</var>.

<dt>{{Element}}
<dd>Its <a for=Element>namespace</a>,
<a for=Element>namespace prefix</a>,
<a for=Element>local name</a>, and its
<a for=Element>attribute list</a>.
<dd>
<p>Set <var>copy</var>'s <a for=Element>namespace</a>,
<a for=Element>namespace prefix</a>, and <a for=Element>local name</a>, to those of
<var>node</var>.

<p>For each <a>attribute</a> in <var>node</var>'s <a for=Element>attribute list</a>,

This comment has been minimized.

Copy link
@domenic

domenic Aug 4, 2015

Member

What is a copy of an attribute?

This comment has been minimized.

Copy link
@annevk

annevk Aug 4, 2015

Author Member

The same kind of weasel-wording as "implements the same interface". I don't really feel like fixing this in a better way until IDL has a bunch improvements and we settle on how to define objects, their internal slots, their associated algorithms, etc.

This comment has been minimized.

Copy link
@domenic

domenic Aug 4, 2015

Member

C'mon, this isn't blocked on IDL in any way. Create a new attribute; set its local name to X; set its namespace to Y; ...

This comment has been minimized.

Copy link
@annevk

annevk Aug 4, 2015

Author Member

You win this time: 1d24476.

in order, <a lt="append an attribute">append</a> a copy to <var>copy</var>'s
<a for=Element>attribute list</a>.

<!--AttrExodus
<dt>{{Attr}}
Expand All @@ -3501,25 +3495,27 @@ dom-Range-extractContents, dom-Range-cloneContents -->

<dt>{{Text}}
<dt>{{Comment}}
<dd>Its <a>data</a>.
<dd>Set <var>copy</var>'s <a>data</a>, to that of <var>node</var>.

<dt>{{ProcessingInstruction}}
<dd>Its <a for=ProcessingInstruction>target</a> and <a>data</a>.
<dd>Set <var>copy</var>'s <a for=ProcessingInstruction>target</a> and <a>data</a> to
those of <var>node</var>.

<dt>Any other node
<dd>&mdash;
</dl>

<li>Run any <a>cloning steps</a>
defined for <var>node</var> in <a>other applicable specifications</a> and
pass <var>copy</var>, <var>node</var>, <var>document</var> and the
<i>clone children flag</i> if set, as parameters.
<li><p>Set <var>copy</var>'s <a>node document</a> and <var>document</var> to
<var>copy</var>, if <var>copy</var> is a <a>document</a>, and set <var>copy</var>'s
<a>node document</a> to <var>document</var> otherwise.

<li>Run any <a>cloning steps</a> defined for <var>node</var> in
<a>other applicable specifications</a> and pass <var>copy</var>, <var>node</var>,
<var>document</var> and the <i>clone children flag</i> if set, as parameters.

<li>If the <i>clone children flag</i> is set,
<a lt="clone a node">clone</a> all the
<a>children</a> of <var>node</var> and
append them to <var>copy</var>, with <var>document</var>
as specified and the <i>clone children flag</i> being set.
<li>If the <i>clone children flag</i> is set, <a lt="clone a node">clone</a> all the
<a>children</a> of <var>node</var> and append them to <var>copy</var>, with
<var>document</var> as specified and the <i>clone children flag</i> being set.

<li>Return <var>copy</var>.
</ol>
Expand Down
90 changes: 46 additions & 44 deletions dom.html
Expand Up @@ -88,7 +88,7 @@
<h1 class="p-name no-ref allcaps" id="title">DOM</h1>

<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Living Standard — Last Updated
<time class="dt-updated" datetime="2015-08-03">3 August 2015</time></span></h2>
<time class="dt-updated" datetime="2015-08-04">4 August 2015</time></span></h2>

<div data-fill-with="spec-metadata">
<dl>
Expand Down Expand Up @@ -4525,64 +4525,63 @@ <h3 class="heading settled" data-level="4.4" id="interface-node"><span class="se

<ol>

<li>If <var>document</var> is not given, let <var>document</var> be
<var>node</var>’s <a data-link-type="dfn" href="#concept-node-document">node document</a>.


<li>Let <var>copy</var> be a <a data-link-type="dfn" href="#concept-node">node</a>
that implements the same interfaces as <var>node</var>.


<li>
If <var>copy</var> is a
<a data-link-type="dfn" href="#concept-document">document</a>, set its
<a data-link-type="dfn" href="#concept-node-document">node document</a> and
<var>document</var> to <var>copy</var>.
Otherwise, set <var>copy</var>’s
<a data-link-type="dfn" href="#concept-node-document">node document</a> to
<var>document</var>.
<p>If <var>document</var> is not given, let <var>document</var> be <var>node</var>’s
<a data-link-type="dfn" href="#concept-node-document">node document</a>.


</p>
<li>
Copy the following from <var>node</var> to <var>copy</var>, depending on
the type of <var>node</var>:

<p>Let <var>copy</var> be a <a data-link-type="dfn" href="#concept-node">node</a> that implements the same interfaces as
<var>node</var>, and fulfills these additional requirements, switching on
<var>node</var>:

</p>
<dl class="switch">

<dt><code class="idl"><a data-link-type="idl" href="#document">Document</a></code>

<dd>Its <a data-link-type="dfn" href="#concept-document-encoding">encoding</a>,
<a data-link-type="dfn" href="#concept-document-content-type">content type</a>,
<a data-link-type="dfn" href="#concept-document-url">URL</a>, <a data-link-type="dfn" href="#concept-document-type">type</a>, and <a data-link-type="dfn" href="#concept-document-mode">mode</a>.
<dd>

<p>Set <var>copy</var>’s <a data-link-type="dfn" href="#concept-document-encoding">encoding</a>,
<a data-link-type="dfn" href="#concept-document-content-type">content type</a>, <a data-link-type="dfn" href="#concept-document-url">URL</a>, <a data-link-type="dfn" href="#concept-document-type">type</a>,
and <a data-link-type="dfn" href="#concept-document-mode">mode</a>, to those of <var>node</var>.


</p>
<dt><code class="idl"><a data-link-type="idl" href="#documenttype">DocumentType</a></code>

<dd>Its <a data-link-type="dfn" href="#concept-doctype-name">name</a>,
<a data-link-type="dfn" href="#concept-doctype-publicid">public ID</a>, and
<a data-link-type="dfn" href="#concept-doctype-systemid">system ID</a>.
<dd>
<p>Set <var>copy</var>’s <a data-link-type="dfn" href="#concept-doctype-name">name</a>, <a data-link-type="dfn" href="#concept-doctype-publicid">public ID</a>, and
<a data-link-type="dfn" href="#concept-doctype-systemid">system ID</a>, to those of <var>node</var>.


</p>
<dt><code class="idl"><a data-link-type="idl" href="#element">Element</a></code>

<dd>Its <a data-link-type="dfn" href="#concept-element-namespace">namespace</a>,
<a data-link-type="dfn" href="#concept-element-namespace-prefix">namespace prefix</a>,
<a data-link-type="dfn" href="#concept-element-local-name">local name</a>, and its
<a data-link-type="dfn" href="#concept-element-attribute">attribute list</a>.
<dd>

<p>Set <var>copy</var>’s <a data-link-type="dfn" href="#concept-element-namespace">namespace</a>,
<a data-link-type="dfn" href="#concept-element-namespace-prefix">namespace prefix</a>, and <a data-link-type="dfn" href="#concept-element-local-name">local name</a>, to those of
<var>node</var>.


</p>
<p>For each <a data-link-type="dfn" href="#concept-attribute">attribute</a> in <var>node</var>’s <a data-link-type="dfn" href="#concept-element-attribute">attribute list</a>,
in order, <a data-link-type="dfn" href="#concept-element-attributes-append">append</a> a copy to <var>copy</var>’s
<a data-link-type="dfn" href="#concept-element-attribute">attribute list</a>.



</p>
<dt><code class="idl"><a data-link-type="idl" href="#text">Text</a></code>

<dt><code class="idl"><a data-link-type="idl" href="#comment">Comment</a></code>

<dd>Its <a data-link-type="dfn" href="#concept-CD-data">data</a>.
<dd>Set <var>copy</var>’s <a data-link-type="dfn" href="#concept-CD-data">data</a>, to that of <var>node</var>.


<dt><code class="idl"><a data-link-type="idl" href="#processinginstruction">ProcessingInstruction</a></code>

<dd>Its <a data-link-type="dfn" href="#concept-PI-target">target</a> and <a data-link-type="dfn" href="#concept-CD-data">data</a>.
<dd>Set <var>copy</var>’s <a data-link-type="dfn" href="#concept-PI-target">target</a> and <a data-link-type="dfn" href="#concept-CD-data">data</a> to
those of <var>node</var>.


<dt>Any other node
Expand All @@ -4593,17 +4592,20 @@ <h3 class="heading settled" data-level="4.4" id="interface-node"><span class="se



<li>Run any <a data-link-type="dfn" href="#concept-node-clone-ext">cloning steps</a>
defined for <var>node</var> in <a data-link-type="dfn" href="#other-applicable-specifications">other applicable specifications</a> and
pass <var>copy</var>, <var>node</var>, <var>document</var> and the
<i>clone children flag</i> if set, as parameters.
<li>
<p>Set <var>copy</var>’s <a data-link-type="dfn" href="#concept-node-document">node document</a> and <var>document</var> to
<var>copy</var>, if <var>copy</var> is a <a data-link-type="dfn" href="#concept-document">document</a>, and set <var>copy</var>’s
<a data-link-type="dfn" href="#concept-node-document">node document</a> to <var>document</var> otherwise.

</p>
<li>Run any <a data-link-type="dfn" href="#concept-node-clone-ext">cloning steps</a> defined for <var>node</var> in
<a data-link-type="dfn" href="#other-applicable-specifications">other applicable specifications</a> and pass <var>copy</var>, <var>node</var>,
<var>document</var> and the <i>clone children flag</i> if set, as parameters.


<li>If the <i>clone children flag</i> is set,
<a data-link-type="dfn" href="#concept-node-clone">clone</a> all the
<a data-link-type="dfn" href="#concept-tree-child">children</a> of <var>node</var> and
append them to <var>copy</var>, with <var>document</var>
as specified and the <i>clone children flag</i> being set.
<li>If the <i>clone children flag</i> is set, <a data-link-type="dfn" href="#concept-node-clone">clone</a> all the
<a data-link-type="dfn" href="#concept-tree-child">children</a> of <var>node</var> and append them to <var>copy</var>, with
<var>document</var> as specified and the <i>clone children flag</i> being set.


<li>Return <var>copy</var>.
Expand Down Expand Up @@ -5766,7 +5768,7 @@ <h3 class="heading settled" data-level="4.5" id="interface-document"><span class
for the <a data-link-type="dfn" href="#context-object">context object</a>.</p>


<div class="example" id="example-48a90db5"><a class="self-link" href="#example-48a90db5"></a>
<div class="example" id="example-04d99d7d"><a class="self-link" href="#example-04d99d7d"></a>
Given the following XHTML fragment:


Expand Down

0 comments on commit 39e6a33

Please sign in to comment.