From 81c6f63737fbf4867d0376d95f7b6f0df91b0f29 Mon Sep 17 00:00:00 2001 From: Masahiro Fujimoto Date: Thu, 4 Nov 2021 19:18:24 +0900 Subject: Document.importNode() の変換準備 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- files/ja/web/api/document/importnode/index.html | 109 ------------------------ files/ja/web/api/document/importnode/index.md | 109 ++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 109 deletions(-) delete mode 100644 files/ja/web/api/document/importnode/index.html create mode 100644 files/ja/web/api/document/importnode/index.md (limited to 'files/ja/web/api/document') diff --git a/files/ja/web/api/document/importnode/index.html b/files/ja/web/api/document/importnode/index.html deleted file mode 100644 index 5484b1b0a0..0000000000 --- a/files/ja/web/api/document/importnode/index.html +++ /dev/null @@ -1,109 +0,0 @@ ---- -title: Document.importNode() -slug: Web/API/Document/importNode -tags: - - API - - DOM - - Document - - Method - - Node - - Reference - - copy - - importNode -translation_of: Web/API/Document/importNode ---- -
{{APIRef("DOM")}}
- -

{{domxref("Document")}} オブジェクトの importNode() メソッドは、後で現在の文書に挿入するために、他の文書から {{domxref("Node")}} または {{domxref("DocumentFragment")}} の複製を作成します。

- -

インポートされたノードは、まだ文書ツリーには含まれません。これを含めるには、 {{domxref("Node.appendChild", "appendChild()")}} や {{domxref("Node.insertBefore", "insertBefore()")}} のような挿入メソッドを、現在の文書ツリーに存在するノードに対して呼び出す必要があります。

- -

{{domxref("document.adoptNode()")}} とは異なり、元の文書から元のノードは削除されません。インポートされたノードは元のノードの複製です。

- -

構文

- -
const importedNode = document.importNode(externalNode [, deep]);
-
- -

引数

- -
-
externalNode
-
現在の文書にインポートする、外部の {{domxref("Node")}} または {{domxref("DocumentFragment")}} です。
-
deep {{optional_inline}}
-
論理値で、 externalNode の DOM サブツリー全体をインポートするかどうかを制御します。 -
    -
  • deeptrue に設定された場合、 externalNode およびその子孫全てが複製されます。
  • -
  • deepfalse に設定された場合、 externalNode のみがインポートされます — 新しいノードには子ノードはない状態になります。
  • -
- -
-

中: DOM4 仕様書では、 deep 羽オプションの引数で、既定値は true でした。

- -

最新の仕様書ではこの既定値が変更されました。新しい既定値は false になりました。

- -

おすすめの方法: これは現在もオプションの引数ですが、常に deep 引数を渡すことが後方互換性および前方互換性には有用です。

- -
    -
  • Gecko 28.0 {{geckoRelease(28)}} では、コンソールでこの引数を省略しないよう開発者に警告しています。
  • -
  • Gecko 29.0 {{geckoRelease(29)}}) 以降、深いクローンではなく浅いクローンが既定値になっています。
  • -
-
-
-
- -

返値

- -

インポートする側の文書のスコープにコピーされた importedNode です。

- -
-

注: importedNode's {{domxref("Node.parentNode")}} は null になります。まだ文書ツリーに挿入されていないからです。

-
- -

- -
const iframe  = document.querySelector("iframe");
-const oldNode = iframe.contentWindow.document.getElementById("myNode");
-const newNode = document.importNode(oldNode, true);
-document.getElementById("container").appendChild(newNode);
-
- -

- -

{{page("/ja/docs/Web/API/Document/adoptNode", "Notes")}}

- -

仕様書

- - - - - - - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName("DOM WHATWG", "#dom-document-importnode", "document.importNode()")}}{{Spec2("DOM WHATWG")}}
{{SpecName("DOM2 Core", "core.html#Core-Document-importNode", "document.importNode()")}}{{Spec2("DOM2 Core")}}初回定義
- -

ブラウザーの互換性

- -

{{Compat("api.Document.importNode")}}

- -

関連情報

- - diff --git a/files/ja/web/api/document/importnode/index.md b/files/ja/web/api/document/importnode/index.md new file mode 100644 index 0000000000..5484b1b0a0 --- /dev/null +++ b/files/ja/web/api/document/importnode/index.md @@ -0,0 +1,109 @@ +--- +title: Document.importNode() +slug: Web/API/Document/importNode +tags: + - API + - DOM + - Document + - Method + - Node + - Reference + - copy + - importNode +translation_of: Web/API/Document/importNode +--- +
{{APIRef("DOM")}}
+ +

{{domxref("Document")}} オブジェクトの importNode() メソッドは、後で現在の文書に挿入するために、他の文書から {{domxref("Node")}} または {{domxref("DocumentFragment")}} の複製を作成します。

+ +

インポートされたノードは、まだ文書ツリーには含まれません。これを含めるには、 {{domxref("Node.appendChild", "appendChild()")}} や {{domxref("Node.insertBefore", "insertBefore()")}} のような挿入メソッドを、現在の文書ツリーに存在するノードに対して呼び出す必要があります。

+ +

{{domxref("document.adoptNode()")}} とは異なり、元の文書から元のノードは削除されません。インポートされたノードは元のノードの複製です。

+ +

構文

+ +
const importedNode = document.importNode(externalNode [, deep]);
+
+ +

引数

+ +
+
externalNode
+
現在の文書にインポートする、外部の {{domxref("Node")}} または {{domxref("DocumentFragment")}} です。
+
deep {{optional_inline}}
+
論理値で、 externalNode の DOM サブツリー全体をインポートするかどうかを制御します。 +
    +
  • deeptrue に設定された場合、 externalNode およびその子孫全てが複製されます。
  • +
  • deepfalse に設定された場合、 externalNode のみがインポートされます — 新しいノードには子ノードはない状態になります。
  • +
+ +
+

中: DOM4 仕様書では、 deep 羽オプションの引数で、既定値は true でした。

+ +

最新の仕様書ではこの既定値が変更されました。新しい既定値は false になりました。

+ +

おすすめの方法: これは現在もオプションの引数ですが、常に deep 引数を渡すことが後方互換性および前方互換性には有用です。

+ +
    +
  • Gecko 28.0 {{geckoRelease(28)}} では、コンソールでこの引数を省略しないよう開発者に警告しています。
  • +
  • Gecko 29.0 {{geckoRelease(29)}}) 以降、深いクローンではなく浅いクローンが既定値になっています。
  • +
+
+
+
+ +

返値

+ +

インポートする側の文書のスコープにコピーされた importedNode です。

+ +
+

注: importedNode's {{domxref("Node.parentNode")}} は null になります。まだ文書ツリーに挿入されていないからです。

+
+ +

+ +
const iframe  = document.querySelector("iframe");
+const oldNode = iframe.contentWindow.document.getElementById("myNode");
+const newNode = document.importNode(oldNode, true);
+document.getElementById("container").appendChild(newNode);
+
+ +

+ +

{{page("/ja/docs/Web/API/Document/adoptNode", "Notes")}}

+ +

仕様書

+ + + + + + + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName("DOM WHATWG", "#dom-document-importnode", "document.importNode()")}}{{Spec2("DOM WHATWG")}}
{{SpecName("DOM2 Core", "core.html#Core-Document-importNode", "document.importNode()")}}{{Spec2("DOM2 Core")}}初回定義
+ +

ブラウザーの互換性

+ +

{{Compat("api.Document.importNode")}}

+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf