blob: 83026ac378d1383799e1dc19e6d6c15df4631b8f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
---
title: Node.normalize
slug: Web/API/Node/normalize
tags:
- DOM
- Gecko
- Node
translation_of: Web/API/Node/normalize
---
<div>{{ApiRef}}</div>
<h2 id="Summary" name="Summary">概要</h2>
<p>指定ノードの空のノードを削除し、隣接するテキストノードをひとつに纏め、文書を「正規化 (normalize)」します。</p>
<h2 id="Syntax" name="Syntax">構文</h2>
<pre class="syntaxbox"><em>element</em>.normalize();
</pre>
<h2 id="Example" name="Example">例</h2>
<pre class="brush:js;highlight:10;">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"
</pre>
<h2 id="Specification" name="Specification">仕様書</h2>
<ul>
<li><a href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-normalize">DOM Level 2 Core: Node.normalize</a></li>
</ul>
<h2 id="See_also" name="See_also">関連情報</h2>
<ul>
<li><a href="/ja/docs/Web/API/Text.splitText"><code>Text.splitText</code></a></li>
</ul>
|