cloneNodes

cloneNodes

仕様書

処理

[15] Chrome では文書の起源も複製されるようです。

cloning steps

[3] 要素依存の clone の処理がいくつかあり、 cloning steps と呼ばれています。

歴史

W3C DOM 時代

[19] Elementdeep = falsecloneNode すると、既定属性が自動的に作られるのかは明確ではありません。

[20] UserDataHandler がいつ呼び出されるのかはよくわかりません。 各節点が複製される度に呼ばれるのか、それとも全節点が複製されてから順に呼んでもいいのか。

[21] Firefox 3.1 for developers - MDC ( 版) <https://developer.mozilla.org/ja/Firefox_3.1_for_developers#.E6.96.B0.E3.81.97.E3.81.8F.E3.82.B5.E3.83.9D.E3.83.BC.E3.83.88.E3.81.95.E3.82.8C.E3.81.9F.E6.A9.9F.E8.83.BD_2>

HTML ノードでの cloneNode ( bug 42976 )。

[22] IEにおけるcloneNodeの問題点 - dhrnameの開発日誌 ( 版) <http://d.hatena.ne.jp/dhrname/20080621/p1>

DOMのcloneNodeはノードを複製できますし、IEもそれに従っています。しかしながら、IEでは、setAttributeなどで、後から付け足された属性は複製しない特徴を持っています。

[18] Returns a duplicate of the node, i.e. serves as a generic

      copy constructor for nodes.

      - The duplicate node has no parent, i.e. <A::Node.parentNode>
        is <DOM::null>.  <SRC::DOM1, DOM2, DOM3>
      - The duplicate node has no user data, i.e. user data
        associated to the node is not carried over.  However,
        if any <IF::UserDataHandlers> has been specified along with
        the associated data, those handlers will be called with
        the appropriate parameters before the method returns.  <SRC::DOM3>
      - If the node is an <IF::Element>, all attributes and their values,
        including those representing defaulted attributes (i.e.
        attributes whose <A::Attr.specified> are <DOM::false>),
but the method does not copy any children it contains
        unless it is a deep clone (i.e. <P::deep> is <DOM::true>).
        <SRC::DOM1, DOM2, DOM3>
      - Cloning an <IF::Attr> directly, as oppsed to be cloned
        as part of an <IF::Element> cloning operation, returns
        a specified attribute (i.e. its <A::Attr.specified> is
        set to <DOM::true>).  <SRC::DOM1, DOM2, DOM3>
      - Cloning an <IF::Attr> always clones its children, since
        they represent its value, no matter whether this is a
        deep clone or not.  <SRC::DOM3>
      - Cloning an <IF::tx|EntityReference> automatically constructs
        its subtree if a corresponding <IF::tx|Entity> is available,
        no matter whether this is a deep clone or not.  <SRC::DOM3>
- Cloning an <IF::Attr> always clones its children, since
        they represent its value, no matter whether this is a
        deep clone or not.  <SRC::DOM3>
      - Cloning an <IF::tx|EntityReference> automatically constructs
        its subtree if a corresponding <IF::tx|Entity> is available,
        no matter whether this is a deep clone or not.  <SRC::DOM3>
      - Cloning any other type of node simply returns a copy of the node.
        <SRC::DOM1, DOM2, DOM3>
      - Cloning <IF::Document>, <IF::tx|DocumentType>, <IF::tx|Entity>,
        <IF::tx|Notation> nodes is implementation dependent.
        <SRC::DOM1SE, DOM2, DOM3>
      - Cloning an immutable subtree results in a mutable copy, but
        the children of an <IF::tx|EntityReference> clone are
        read-only.  <SRC::DOM2, DOM3>
- Cloning <IF::Document>, <IF::tx|DocumentType>, <IF::tx|Entity>,
        <IF::tx|Notation> nodes is implementation dependent.
        <SRC::DOM1SE, DOM2, DOM3>
      - Cloning an immutable subtree results in a mutable copy, but
        the children of an <IF::tx|EntityReference> clone are
        read-only.  <SRC::DOM2, DOM3>
      - Cloning a node does not copy the event listeners attached to it.
        <SRC::DOM2 Events, DOM3 Events>
      {NOTE:: <IF::UserDataHandler>s are prohibitted to throw exceptions;
              if a <IF::UserDataHandler> that is registered to the node
              being cloned throws an exception, then the result of
              the method is undefined.

NOT_SUPPORTED_ERR: The node is of type <IF::Document>, <IF::tx|DocumentType>,

          <IF::tx|Entity>, or <IF::tx|Notation> and the implementation
          does not support cloning that type of node.  <SRC::DOM1SE>

          Only in DOM1SE; they are implementation dependent
          in DOM1SE, DOM2, and DOM3.

DOM Standard 時代

[23] (X)HTML5 Tracking ( 版) <http://html5.org/tools/web-apps-tracker?from=3853&to=3854>

[25] [whatwg] cloneNode and HTML elements ( ( 版)) <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2009-September/022960.html>

[26] [whatwg] cloneNode and HTML elements ( ( 版)) <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2009-September/022969.html>

[1] Web Applications 1.0 r6423 DOM Core convergence (cloning) ( ( 版)) <http://html5.org/tools/web-apps-tracker?from=6422&to=6423>

[24] IRC logs: freenode / #whatwg / 20120514 ( ( 版)) <http://krijnhoetmer.nl/irc-logs/whatwg/20120514#l-223>

[27] Sadness. (Default importNode() and cloneNode() to false.) https://www.w3... · 70fdc5f · whatwg/dom ( ( 版)) <https://github.com/whatwg/dom/commit/70fdc5f9030c22c5ceca9e875e06f8b305529ef8>

[12] Define Request/Response clone() methods. Give up on structured clones fo... · ae663b5 · whatwg/fetch ( ( 版)) <https://github.com/whatwg/fetch/commit/ae663b597a72ddd16430bc8ecb4ab566d6bf4714>

[13] Tree was incorrectly created when cloning and extracting a Range · 4b102a2 · whatwg/dom ( ( 版)) <https://github.com/whatwg/dom/commit/4b102a2ba6af3b69244b551cc675dabc9fceb93e>

[14] Range clone algorithm did not set clone children flag where it had to ht... · 5fc973c · whatwg/dom ( ( 版)) <https://github.com/whatwg/dom/commit/5fc973c1d2fda9c92e43dba9c946eba389f8546c>

[28] Make cloning more explicit regarding attributes. Fixes #30. · whatwg/dom@39e6a33 ( 版) <https://github.com/whatwg/dom/commit/39e6a33785b33649ef839d8ad355461a57413963>

[29] Define copying attributes since @domenic almost called me lazy. · whatwg/dom@1d24476 ( 版) <https://github.com/whatwg/dom/commit/1d24476e7faf715bd0edd1f28351cfd8f32e1025>

[16] IRC logs: freenode / #whatwg / 20151021 ( 版) <http://krijnhoetmer.nl/irc-logs/whatwg/20151021>

[30] Make cloneNode() throw for ShadowRoot objects · whatwg/dom@02ec9c7 ( 版) <https://github.com/whatwg/dom/commit/02ec9c7e52cb5a09d4cf7d14a583c635ea6dc38d>

[31] Add support for custom elements · whatwg/dom@7f63535 ( 版) <https://github.com/whatwg/dom/commit/7f63535da39a1cbf7f8f68563abc6f05f760990a>

[32] Add [CEReactions] annotations to mutating methods · whatwg/dom@3cd02d1 ( 版) <https://github.com/whatwg/dom/commit/3cd02d139c159a31fbb400e03932652c72fc7812>

[33] Make Attr inherit from Node again (annevk著, ) <https://github.com/whatwg/dom/commit/625a0747f137454c155a7b577a9e45be1aa35a34>

[34] Add cloning steps for textarea (domenic著, ) <https://github.com/whatwg/html/commit/957fd0c91c6ee3abd77538be3a2b4c5531754f62>

[36] Copy the origin pointer when cloning a document (annevk著, ) <https://github.com/whatwg/dom/commit/623f655c9f58039fa6b30e0f65ee325700e8b977>

[38] Change handling of is="" in element creation and cloning (domenic著, ) <https://github.com/whatwg/dom/commit/fc601be94e75427c3eb35d63ada0f6dc41f9f344>

[37] Change handling of is="" in element creation and cloning by domenic · Pull Request #566 · whatwg/dom () <https://github.com/whatwg/dom/pull/566>

[39] Hide nonce content attribute values (mikewest著, ) <https://github.com/whatwg/html/commit/19f5cce801550d278b9459f8c4797f9f86aae864>

[40] Define cloning steps for an select element · Issue #644 · whatwg/dom () <https://github.com/whatwg/dom/issues/644>