diff options
Diffstat (limited to 'files/ko/orphaned/web/api/childnode/before/index.html')
-rw-r--r-- | files/ko/orphaned/web/api/childnode/before/index.html | 145 |
1 files changed, 0 insertions, 145 deletions
diff --git a/files/ko/orphaned/web/api/childnode/before/index.html b/files/ko/orphaned/web/api/childnode/before/index.html deleted file mode 100644 index e0c01c2a02..0000000000 --- a/files/ko/orphaned/web/api/childnode/before/index.html +++ /dev/null @@ -1,145 +0,0 @@ ---- -title: ChildNode.before() -slug: orphaned/Web/API/ChildNode/before -tags: - - API - - DOM - - 노드 - - 레퍼런스 - - 메소드 - - 실험중 -translation_of: Web/API/ChildNode/before -original_slug: Web/API/ChildNode/before ---- -<div>{{APIRef("DOM")}} {{SeeCompatTable}}</div> - -<p><code><strong>ChildNode.before</strong></code> 메소드는 <code>ChildNode</code> 의 부모가 가진 자식의 <code>ChildNode</code> 바로 이전에 {{domxref("Node")}} 또는 {{domxref("DOMString")}} 객체의 집합을 삽입합니다.{{domxref("DOMString")}} 객체는 {{domxref("Text")}} 노드와 동일하게 삽입됩니다.</p> - -<h2 id="문법">문법</h2> - -<pre class="syntaxbox">[Throws, Unscopable] -void ChildNode.before((Node or DOMString)... nodes); -</pre> - -<h3 id="파라미터">파라미터</h3> - -<dl> - <dt><code>nodes</code></dt> - <dd>삽입할 {{domxref("Node")}} 또는 {{domxref("DOMString")}} 객체의 집합입니다.</dd> -</dl> - -<h3 id="예외">예외</h3> - -<ul> - <li>{{domxref("HierarchyRequestError")}}: 노드는 계층 구조의 특정 지점에 삽입될 수 없습니다.</li> -</ul> - -<h2 id="예제">예제</h2> - -<h3 id="엘리먼트_삽입하기">엘리먼트 삽입하기</h3> - -<pre class="brush: js">var parent = document.createElement("div"); -var child = document.createElement("p"); -parent.appendChild(child); -var span = document.createElement("span"); - -child.before(span); - -console.log(parent.outerHTML); -// "<div><span></span><p></p></div>" -</pre> - -<h3 id="텍스트_삽입하기">텍스트 삽입하기</h3> - -<pre class="brush: js">var parent = document.createElement("div"); -var child = document.createElement("p"); -parent.appendChild(child); - -child.before("Text"); - -console.log(parent.outerHTML); -// "<div>Text<p></p></div>"</pre> - -<h3 id="엘리먼트와_텍스트_삽입하기">엘리먼트와 텍스트 삽입하기</h3> - -<pre class="brush: js">var parent = document.createElement("div"); -var child = document.createElement("p"); -parent.appendChild(child); -var span = document.createElement("span"); - -child.before(span, "Text"); - -console.log(parent.outerHTML); -// "<div><span></span>Text<p></p></div>"</pre> - -<h3 id="ChildNode.before()_는_범위를_지정할_수_없습니다"><code>ChildNode.before()</code> 는 범위를 지정할 수 없습니다</h3> - -<p><code>before()</code> 메소드는 <code>with</code> 구문으로 범위를 지정할 수 없습니다. 자세한 내용은 {{jsxref("Symbol.unscopables")}} 문서를 확인하세요.</p> - -<pre class="brush: js">with(node) { - before("foo"); -} -// ReferenceError: before is not defined </pre> - -<h2 id="폴리필">폴리필</h2> - -<p>다음 코드를 사용해 인터넷 익스플로러 9 이상에서 <code>before() 메소드</code> 를 폴리필링할 수 있습니다.</p> - -<pre class="brush: js">// from: https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/before()/before().md -(function (arr) { - arr.forEach(function (item) { - if (item.hasOwnProperty('before')) { - return; - } - Object.defineProperty(item, 'before', { - configurable: true, - enumerable: true, - writable: true, - value: function before() { - var argArr = Array.prototype.slice.call(arguments), - docFrag = document.createDocumentFragment(); - - argArr.forEach(function (argItem) { - var isNode = argItem instanceof Node; - docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem))); - }); - - this.parentNode.insertBefore(docFrag, this); - } - }); - }); -})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);</pre> - -<h2 id="명세">명세</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">명세</th> - <th scope="col">상태</th> - <th scope="col">코멘트</th> - </tr> - <tr> - <td>{{SpecName('DOM WHATWG', '#dom-childnode-before', 'ChildNode.before()')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>초기 정의.</td> - </tr> - </tbody> -</table> - -<h2 id="브라우저_호환성">브라우저 호환성</h2> - - - -<p>{{Compat("api.ChildNode.before")}}</p> - -<h2 id="함께_보기">함께 보기</h2> - -<ul> - <li>{{domxref("ChildNode")}} 와 {{domxref("ParentNode")}}</li> - <li>{{domxref("ChildNode.after()")}}</li> - <li>{{domxref("ParentNode.append()")}}</li> - <li>{{domxref("Node.appendChild()")}}</li> - <li>{{domxref("Node.insertBefore()")}}</li> - <li>{{domxref("NodeList")}}</li> -</ul> |