aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/api/treewalker/index.html
blob: 1f2a520efd12a3a44bf62b36cc7382b78e2de4c6 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
---
title: TreeWalker
slug: Web/API/TreeWalker
tags:
  - API
  - DOM
  - Reference
translation_of: Web/API/TreeWalker
---
<div>
<p>{{ APIRef("DOM") }}</p>
</div>

<p><strong><code>TreeWalker</code></strong> 오브젝트는 도큐먼트 서브트리의 노드들과 그 안에서의 위치를 나타낸다.</p>

<p><code>TreeWalker</code> 는 {{domxref("Document.createTreeWalker()")}} 메소드로 생성할 수 있다.</p>

<h2 id="Properties" name="Properties">속성</h2>

<p><em>이 인터페이스는 어떤 프라퍼티도 상속하지 않는다.</em></p>

<dl>
 <dt>{{domxref("TreeWalker.root")}} {{readonlyInline}}</dt>
 <dd><code>TreeWalker</code> 를 생성할 때 지정한 루트 노드를 나타대는 {{domxref("Node")}}를 반환한다.</dd>
 <dt>{{domxref("TreeWalker.whatToShow")}} {{readonlyInline}}</dt>
 <dd>제공해야할 {{domxref("Node")}} 유형을 기술하는 <code>unsigned long</code> 비트마스크를 반환한다. 일치하지 않는 노드들은 건너뛰지만 관련된 경우 그 자식들을 포함할 수 있다. 가능한 값들은:
 <table class="standard-table">
  <tbody>
   <tr>
    <td class="header">상수</td>
    <td class="header">숫자 값</td>
    <td class="header">설명</td>
   </tr>
   <tr>
    <td><code>NodeFilter.SHOW_ALL</code></td>
    <td><code>-1</code><code>unsigned long의 최대 값</code>)</td>
    <td>모든 노드를 보여준다.</td>
   </tr>
   <tr>
    <td><code>NodeFilter.SHOW_ATTRIBUTE</code> {{deprecated_inline}}</td>
    <td><code>2</code></td>
    <td>속성 {{ domxref("Attr") }} 노드들을 보여준다. {{ domxref("Attr") }}노드가 루트인 {{ domxref("TreeWalker") }}를 생성할 때에만 의미가 있다. 이 경우, 그 속성 노드가 그 반복 또는 순회에 첫 위치로 나타남을 의미한다. 속성은 결코 다른 노드의 자식이 아니기 때문에 도큐먼트 트리를 순회할 때는 나타나지 않는다.</td>
   </tr>
   <tr>
    <td><code>NodeFilter.SHOW_CDATA_SECTION</code> {{deprecated_inline}}</td>
    <td><code>8</code></td>
    <td>{{ domxref("CDATASection") }} 노드들을 보여준다.</td>
   </tr>
   <tr>
    <td><code>NodeFilter.SHOW_COMMENT</code></td>
    <td><code>128</code></td>
    <td>{{ domxref("Comment") }} 노드들을 보여준다.</td>
   </tr>
   <tr>
    <td><code>NodeFilter.SHOW_DOCUMENT</code></td>
    <td><code>256</code></td>
    <td>{{ domxref("Document") }} 노드들을 보여준다.</td>
   </tr>
   <tr>
    <td><code>NodeFilter.SHOW_DOCUMENT_FRAGMENT</code></td>
    <td><code>1024</code></td>
    <td>{{ domxref("DocumentFragment") }} 노드들을 보여준다.</td>
   </tr>
   <tr>
    <td><code>NodeFilter.SHOW_DOCUMENT_TYPE</code></td>
    <td><code>512</code></td>
    <td>{{ domxref("DocumentType") }} 노드들을 보여준다.</td>
   </tr>
   <tr>
    <td><code>NodeFilter.SHOW_ELEMENT</code></td>
    <td><code>1</code></td>
    <td>{{ domxref("Element") }} 노드들을 보여준다.</td>
   </tr>
   <tr>
    <td><code>NodeFilter.SHOW_ENTITY</code> {{deprecated_inline}}</td>
    <td><code>32</code></td>
    <td>{{ domxref("Entity") }} 노드들을 보여준다. {{ domxref("Entity") }} 노드를 루트로 하여 {{ domxref("TreeWalker") }}를 생성할 때만 의미가 있다; 이 경우, 그 {{ domxref("Entity") }} 노드가 그 순회의 첫 위치에 나타남을 의미한다. 엔티티들은 도큐먼트 트리의 일부가 아니기 때문에 도큐먼트 트리를 순회할 때 나타나지 않는다.</td>
   </tr>
   <tr>
    <td><code>NodeFilter.SHOW_ENTITY_REFERENCE</code> {{deprecated_inline}}</td>
    <td><code>16</code></td>
    <td>{{ domxref("EntityReference") }} 노드들을 보여준다.</td>
   </tr>
   <tr>
    <td><code>NodeFilter.SHOW_NOTATION</code> {{deprecated_inline}}</td>
    <td><code>2048</code></td>
    <td>{{ domxref("Notation") }} 노드들을 보여준다. {{ domxref("Notation") }} 노드를 루트로 하여 {{ domxref("TreeWalker") }}를 생성할 때만 의미가 있다; 이 경우, 그 {{ domxref("Notation") }} 노드가 순회의 첫 위치에 나타남을 의미한다, 그들은 도큐먼트 트리를 순회할 때 나타나지 않는다.</td>
   </tr>
   <tr>
    <td><code>NodeFilter.SHOW_PROCESSING_INSTRUCTION</code></td>
    <td><code>64</code></td>
    <td>{{ domxref("ProcessingInstruction") }} 노드들을 보여준다.</td>
   </tr>
   <tr>
    <td><code>NodeFilter.SHOW_TEXT</code></td>
    <td><code>4</code></td>
    <td>{{ domxref("Text") }} 노드들을 보여준다.</td>
   </tr>
  </tbody>
 </table>
 </dd>
 <dt>{{domxref("TreeWalker.filter")}} {{readonlyInline}}</dt>
 <dd>의미있는 노드들을 선택하기 위해 사용하는 {{domxref("NodeFilter")}}를 반환한다.</dd>
 <dt>{{domxref("TreeWalker.expandEntityReferences")}} {{readonlyInline}}{{obsolete_inline}}</dt>
 <dd>{{domxref("EntityReference")}}를 버릴 때 그 것의 전체 서브트리도 같이 버려야함을 표시하는 {{domxref("Boolean")}}이다.</dd>
 <dt>{{domxref("TreeWalker.currentNode")}}</dt>
 <dd><code>TreeWalker</code>가 현재 가리키고 있는 {{domxref("Node")}}이다.</dd>
</dl>

<h2 id="Methods" name="Methods">메서드</h2>

<p><em>이 인터페이스는 아무 메서드도 상속하지 않는다.</em></p>

<div class="note">
<p><em>TreeWalker는 보이는 DOM 노드만 고려한다는 것에주의하라.</em></p>
</div>

<dl>
 <dt>{{domxref("TreeWalker.parentNode()")}}</dt>
 <dd>현재 {{domxref("Node")}}를 도큐먼트 순서의 첫번째 보이는 조상으로 이동하고 찾은 노드를 반환한다. 그런 노드가 없거나 오브젝트 생성시에 정의한 <em>루트 노드</em>보다 앞이면 <code>null</code>을 반환하고 현재 노드는 바뀌지 않는다.</dd>
 <dt>{{domxref("TreeWalker.firstChild()")}}</dt>
 <dd>현재 {{domxref("Node")}}를 현재 노드의 첫번째 보이는 자식으로 이동하고 찾은 자식을 반환한다. 그런 자식이 없으면 <code>null</code>을 반환하고 현재 노드는 바뀌지 않는다.</dd>
 <dt>{{domxref("TreeWalker.lastChild()")}}</dt>
 <dd>현재 {{domxref("Node")}}를 현재 노드의 마지막 보이는 자식으로 이동하고 찾은 자식을 반환한다. 그런 자식이 없으면 <code>null</code>을 반환하고 현재 노드는 바뀌지 않는다.</dd>
 <dt>{{domxref("TreeWalker.previousSibling()")}}</dt>
 <dd>현재 {{domxref("Node")}}를 이전 형제로 이동하고 찾은 형제를 반환한다. 그런 노드가 없으면 <code>null</code>을 반환하고 현재 노드는 바뀌지 않는다.</dd>
 <dt>{{domxref("TreeWalker.nextSibling()")}}</dt>
 <dd>현재 {{domxref("Node")}}를 다음 형제로 이동하고 찾은 형제를 반환한다. 그런 노드가 없으면 <code>null</code>을 반환하고 현재 노드는 바뀌지 않는다.</dd>
 <dt>{{domxref("TreeWalker.previousNode()")}}</dt>
 <dd>현재 {{domxref("Node")}}를 도큐먼트 순서의 이전 보이는 노드로 이동하고 찾은 노드를 반환한다. 그런 노드가 없거나 오브젝트 생성시에 정의한 <em>루트 노드</em>보다 앞이면 <code>null</code>을 반환하고 현재 노드는 바뀌지 않는다.</dd>
 <dt>{{domxref("TreeWalker.nextNode()")}}</dt>
 <dd>현재 {{domxref("Node")}}를 도큐먼트 순서의 다음 보이는 노드로 이동하고 찾은 노드를 반환한다. 그런 노드가 없거나 오브젝트 생성시에 정의한 <em>루트 노드</em>보다 앞이면 <code>null</code>을 반환하고 현재 노드는 바뀌지 않는다.</dd>
</dl>

<h2 id="Specification" name="Specification">명세</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('DOM WHATWG', '#interface-treewalker', 'TreeWalker')}}</td>
   <td>{{Spec2('DOM WHATWG')}}</td>
   <td>Removed the <code>expandEntityReferences</code> property.</td>
  </tr>
  <tr>
   <td>{{SpecName('DOM2 Traversal_Range', 'traversal.html#Traversal-TreeWalker', 'TreeWalker')}}</td>
   <td>{{Spec2('DOM2 Traversal_Range')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="브라우저_호환성">브라우저 호환성</h2>



<p>{{Compat("api.TreeWalker")}}</p>

<h2 id="같이_보기">같이 보기</h2>

<ul>
 <li>생성 메소드: {{domxref("Document.createTreeWalker()")}}.</li>
 <li>관련된 인터페이스: {{domxref("NodeFilter")}}, {{domxref("NodeIterator")}}.</li>
</ul>