From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/api/node/normalize/index.html | 48 ++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 files/ja/web/api/node/normalize/index.html (limited to 'files/ja/web/api/node/normalize/index.html') diff --git a/files/ja/web/api/node/normalize/index.html b/files/ja/web/api/node/normalize/index.html new file mode 100644 index 0000000000..83026ac378 --- /dev/null +++ b/files/ja/web/api/node/normalize/index.html @@ -0,0 +1,48 @@ +--- +title: Node.normalize +slug: Web/API/Node/normalize +tags: + - DOM + - Gecko + - Node +translation_of: Web/API/Node/normalize +--- +
{{ApiRef}}
+ +

概要

+ +

指定ノードの空のノードを削除し、隣接するテキストノードをひとつに纏め、文書を「正規化 (normalize)」します。

+ +

構文

+ +
element.normalize();
+
+ +

+ +
var wrapper = document.createElement("div");
+
+wrapper.appendChild( document.createTextNode("Part 1 ") );
+wrapper.appendChild( document.createTextNode("Part 2 ") );
+
+// wrapper.childNodes[0].textContent === "Part 1 "
+// wrapper.childNodes[1].textContent === "Part 2 "
+// この時点で、wrapper の 子ノード数は 2 です。 wrapper.childNodes.length === 2
+
+wrapper.normalize(); // 正規化
+
+// 正規化後の wrapper の子ノード数は 1 となっています。 wrapper.childNodes.length === 1
+// 挿入処理の為に冗長化したノードはひとつに纏められています。 wrapper.childNodes[0].textContent === "Part 1 Part 2"
+
+ +

仕様書

+ + + +

関連情報

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