Skip to content

Commit 496a145

Browse files
committed
[문서] 1.5 주요 노드 프로퍼티 병합충돌 해결
1 parent 69faffd commit 496a145

1 file changed

Lines changed: 0 additions & 65 deletions

File tree

  • 2-ui/1-document/05-basic-dom-node-properties

2-ui/1-document/05-basic-dom-node-properties/article.md

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,14 @@ DOM 노드는 종류에 따라 각각 다른 프로퍼티를 지원합니다.
1010

1111
DOM 노드는 종류에 따라 대응하는 내장 클래스가 다릅니다.
1212

13-
<<<<<<< HEAD
1413
계층 구조 꼭대기엔 [EventTarget](https://dom.spec.whatwg.org/#eventtarget)이 있는데, [Node](http://dom.spec.whatwg.org/#interface-node)는 EventTarget을, 다른 DOM 노드들은 Node 클래스를 상속받습니다.
15-
=======
16-
The root of the hierarchy is [EventTarget](https://dom.spec.whatwg.org/#eventtarget), that is inherited by [Node](https://dom.spec.whatwg.org/#interface-node), and other DOM nodes inherit from it.
17-
>>>>>>> upstream/master
1814

1915
이런 관계를 그림으로 나타내면 다음과 같습니다.
2016

2117
![](dom-class-hierarchy.svg)
2218

2319
각 클래스는 다음과 같은 특징을 지닙니다.
2420

25-
<<<<<<< HEAD
2621
- [EventTarget](https://dom.spec.whatwg.org/#eventtarget) -- 루트에 있는 '추상(abstract)' 클래스로, 이 클래스에 대응하는 객체는 실제로 만들어지지 않습니다. EventTarget가 모든 DOM 노드의 베이스에 있기때문에 DOM 노드에서 '이벤트'를 사용할 수 있습니다. 자세한 내용은 곧 다룰 예정입니다.
2722
- [Node](http://dom.spec.whatwg.org/#interface-node) -- 역시 '추상' 클래스로, DOM 노드의 베이스 역할을 합니다. getter 역할을 하는 `parentNode`, `nextSibling`, `childNodes` 등의 주요 트리 탐색 기능을 제공합니다. `Node` 클래스의 객체는 절대 생성되지 않습니다. 하지만 이 클래스를 상속받는 클래스는 여럿 있습니다. 텍스트 노드를 위한 `Text` 클래스와 요소 노드를 위한 `Element` 클래스, 주석 노드를 위한 `Comment`클래스는 `Node`클래스를 상속받습니다.
2823
- [Element](http://dom.spec.whatwg.org/#interface-element) -- DOM 요소를 위한 베이스 클래스입니다. `nextElementSibling`, `children` 이나 `getElementsByTagName`, `querySelector` 같이 요소 전용 탐색을 도와주는 프로퍼티나 메서드가 이를 기반으로 합니다. 브라우저는 HTML뿐만 아니라 XML, SVG도 지원하는데 `Element` 클래스는 이와 관련된 `SVGElement`, `XMLElement`, `HTMLElement` 클래스의 베이스 역할을 합니다.
@@ -33,41 +28,6 @@ The root of the hierarchy is [EventTarget](https://dom.spec.whatwg.org/#eventtar
3328
- 이외에도 다른 클래스가 많은데, 각 태그에 해당하는 클래스는 고유한 프로퍼티와 메서드를 지원합니다.
3429

3530
이렇게 특정 노드에서 사용할 수 있는 프로퍼티와 메서드는 상속을 기반으로 결정됩니다.
36-
=======
37-
- [EventTarget](https://dom.spec.whatwg.org/#eventtarget) -- is the root "abstract" class for everything.
38-
39-
Objects of that class are never created. It serves as a base, so that all DOM nodes support so-called "events", we'll study them later.
40-
41-
- [Node](https://dom.spec.whatwg.org/#interface-node) -- is also an "abstract" class, serving as a base for DOM nodes.
42-
43-
It provides the core tree functionality: `parentNode`, `nextSibling`, `childNodes` and so on (they are getters). Objects of `Node` class are never created. But there are other classes that inherit from it (and so inherit the `Node` functionality).
44-
45-
- [Document](https://dom.spec.whatwg.org/#interface-document), for historical reasons often inherited by `HTMLDocument` (though the latest spec doesn't dictate it) -- is a document as a whole.
46-
47-
The `document` global object belongs exactly to this class. It serves as an entry point to the DOM.
48-
49-
- [CharacterData](https://dom.spec.whatwg.org/#interface-characterdata) -- an "abstract" class, inherited by:
50-
- [Text](https://dom.spec.whatwg.org/#interface-text) -- the class corresponding to a text inside elements, e.g. `Hello` in `<p>Hello</p>`.
51-
- [Comment](https://dom.spec.whatwg.org/#interface-comment) -- the class for comments. They are not shown, but each comment becomes a member of DOM.
52-
53-
- [Element](https://dom.spec.whatwg.org/#interface-element) -- is the base class for DOM elements.
54-
55-
It provides element-level navigation like `nextElementSibling`, `children` and searching methods like `getElementsByTagName`, `querySelector`.
56-
57-
A browser supports not only HTML, but also XML and SVG. So the `Element` class serves as a base for more specific classes: `SVGElement`, `XMLElement` (we don't need them here) and `HTMLElement`.
58-
59-
- Finally, [HTMLElement](https://html.spec.whatwg.org/multipage/dom.html#htmlelement) is the basic class for all HTML elements. We'll work with it most of the time.
60-
61-
It is inherited by concrete HTML elements:
62-
- [HTMLInputElement](https://html.spec.whatwg.org/multipage/forms.html#htmlinputelement) -- the class for `<input>` elements,
63-
- [HTMLBodyElement](https://html.spec.whatwg.org/multipage/semantics.html#htmlbodyelement) -- the class for `<body>` elements,
64-
- [HTMLAnchorElement](https://html.spec.whatwg.org/multipage/semantics.html#htmlanchorelement) -- the class for `<a>` elements,
65-
- ...and so on.
66-
67-
There are many other tags with their own classes that may have specific properties and methods, while some elements, such as `<span>`, `<section>`, `<article>` do not have any specific properties, so they are instances of `HTMLElement` class.
68-
69-
So, the full set of properties and methods of a given node comes as the result of the chain of inheritance.
70-
>>>>>>> upstream/master
7131

7232
`<input>` 요소에 대응하는 DOM 객체를 예로 들어봅시다. 이 객체는 [HTMLInputElement](https://html.spec.whatwg.org/multipage/forms.html#htmlinputelement) 클래스를 기반으로 만들어집니다.
7333

@@ -171,19 +131,11 @@ interface HTMLInputElement: HTMLElement {
171131
<script>
172132
let elem = document.body;
173133
174-
<<<<<<< HEAD
175134
// 타입을 알아봅시다.
176135
alert(elem.nodeType); // 1 => 요소 노드
177136
178137
// 첫 번째 자식 노드
179138
alert(elem.firstChild.nodeType); // 3 => 텍스트 노드
180-
=======
181-
// let's examine: what type of node is in elem?
182-
alert(elem.nodeType); // 1 => element
183-
184-
// and its first child is...
185-
alert(elem.firstChild.nodeType); // 3 => text
186-
>>>>>>> upstream/master
187139
188140
// 문서 객체의 타입 확인
189141
alert( document.nodeType ); // 9 => 문서 객체
@@ -246,11 +198,7 @@ XML 모드에선 케이스가 '그대로' 유지됩니다. XML 모드는 요즘
246198
247199
## innerHTML로 내용 조작하기
248200
249-
<<<<<<< HEAD
250201
[innerHTML](https://w3c.github.io/DOM-Parsing/#widl-Element-innerHTML) 프로퍼티를 사용하면 요소 안의 HTML을 문자열 형태로 받아올 수 있습니다.
251-
=======
252-
The [innerHTML](https://w3c.github.io/DOM-Parsing/#the-innerhtml-mixin) property allows to get the HTML inside the element as a string.
253-
>>>>>>> upstream/master
254202
255203
요소 안 HTML을 수정하는 것도 가능합니다. innerHTML은 페이지를 수정하는 데 쓰이는 강력한 방법의 하나입니다.
256204
@@ -449,36 +397,23 @@ elem.innerHTML = elem.innerHTML + "..."
449397
<div id="elem2"></div>
450398
451399
<script>
452-
<<<<<<< HEAD
453400
let name = prompt("이름을 알려주세요.", "<b>이보라</b>");
454-
=======
455-
let name = prompt("What's your name?", "<b>Winnie-the-Pooh!</b>");
456-
>>>>>>> upstream/master
457401
458402
elem1.innerHTML = name;
459403
elem2.textContent = name;
460404
</script>
461405
```
462406
463-
<<<<<<< HEAD
464407
1. 첫 번째 `<div>`엔 이름이 'HTML 형태'로 저장됩니다. 입력한 태그는 태그로 해석되어 굵은 글씨가 출력되네요.
465408
2. 두 번째 `<div>`엔 이름이 '텍스트 형태'로 저장됩니다. 따라서 입력한 값 그대로 `<b>이보라</b>`가 출력되는 것을 확인할 수 있습니다.
466-
=======
467-
1. The first `<div>` gets the name "as HTML": all tags become tags, so we see the bold name.
468-
2. The second `<div>` gets the name "as text", so we literally see `<b>Winnie-the-Pooh!</b>`.
469-
>>>>>>> upstream/master
470409
471410
개발을 하다보면 사용자의 입력값을 받아 처리해야 하는 경우가 많습니다. 이때 사용자가 입력한 값은 텍스트로 처리되어야 합니다. 예상치 못한 HTML이 사이트에 침투하는 것을 막으려면 `textContent`를 사용합시다.
472411
473412
## hidden 프로퍼티
474413
475414
hidden 속성과 hidden 프로퍼티는 요소를 보여줄지 말지 지정할 때 사용할 수 있습니다.
476415
477-
<<<<<<< HEAD
478416
`hidden`은 HTML 안에서 쓸 수도 있고 자바스크립트에서도 쓸 수 있습니다.
479-
=======
480-
We can use it in HTML or assign it using JavaScript, like this:
481-
>>>>>>> upstream/master
482417
483418
```html run height="80"
484419
<div>아래 두 div를 숨겨봅시다.</div>

0 commit comments

Comments
 (0)