diff options
Diffstat (limited to 'files/pt-br/web/api/document/importnode/index.html')
-rw-r--r-- | files/pt-br/web/api/document/importnode/index.html | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/files/pt-br/web/api/document/importnode/index.html b/files/pt-br/web/api/document/importnode/index.html new file mode 100644 index 0000000000..831879f58f --- /dev/null +++ b/files/pt-br/web/api/document/importnode/index.html @@ -0,0 +1,84 @@ +--- +title: Document.importNode() +slug: Web/API/Document/importNode +translation_of: Web/API/Document/importNode +--- +<p id="Summary">{{APIRef("DOM")}}</p> + +<p>Cria uma cópia de um nó a partir de um documento externo para ser inserido no document atual.</p> + +<h2 id="Syntax" name="Syntax">Sintaxe</h2> + +<pre class="syntaxbox">var <em>node</em> = <em>document</em>.importNode(<em>externalNode</em>, <em>deep</em>); +</pre> + +<dl> + <dt><code>node</code></dt> + <dd><code>O novo nó que será importado no documento. A propriedade <a href="/en-US/docs/DOM/Node.parentNode" title="DOM/Node.parentNode">parentNode</a> do novo nó é null, desde que ele não foi inserido na árvores do documento.</code></dd> + <dt><code>externalNode</code></dt> + <dd><code>O nó de outro documento para ser importado.</code></dd> + <dt><code>deep</code></dt> + <dd><code>Um boolean, indicando se os nós filhos, do nó a ser importado, devem ser importados também.</code></dd> +</dl> + +<div class="note"> +<p><strong>Note:</strong> In the DOM4 specification (as implemented in Gecko 13.0 {{geckoRelease(13)}}), <code>deep</code> is an optional argument. If omitted, the method acts as if the value of <code>deep</code> was <strong><code>true</code></strong>, defaulting to using deep cloning as the default behavior. To create a shallow clone, <code>deep</code> must be set to <code>false</code>.</p> + +<p>This behavior has been changed in the latest spec, and if omitted, the method will act as if the value of <code>deep</code> was <strong><code>false</code></strong>. Though It's still optional, you should always provide the <code>deep</code> argument both for backward and forward compatibility. With Gecko 28.0 {{geckoRelease(28)}}, the console warned developers not to omit the argument. Starting with Gecko 29.0 {{geckoRelease(29)}}), a shallow clone is defaulted instead of a deep clone.</p> +</div> + +<h2 id="Example" name="Example">Exemplo</h2> + +<pre class="brush: js">var iframe = document.getElementsByTagName("iframe")[0]; +var oldNode = iframe.contentWindow.document.getElementById("myNode"); +var newNode = document.importNode(oldNode, true); +document.getElementById("container").appendChild(newNode); +</pre> + +<h2 id="Notes" name="Notes">Notas</h2> + +<p>O nó original não é removido do documento de origem. O nó importado é um clone do original.</p> + +<p> </p> + +<p>Nodes from external documents should be cloned using <a href="/pt-BR/docs/Web/API/Document/importNode" title="Cria uma cópia de um nó a partir de um documento externo para ser inserido no document atual."><code>document.importNode()</code></a> (or adopted using <a class="new" href="/pt-BR/docs/Web/API/Document/adoptNode" rel="nofollow" title="A documentação sobre isto ainda não foi escrita; por favor considere contribuir!"><code>document.adoptNode()</code></a>) before they can be inserted into the current document. For more on the <a class="new" href="/pt-BR/docs/Web/API/Node/ownerDocument" rel="nofollow" title="A documentação sobre isto ainda não foi escrita; por favor considere contribuir!"><code>Node.ownerDocument</code></a> issues, see the <a class="external" href="http://www.w3.org/DOM/faq.html#ownerdoc" rel="noopener">W3C DOM FAQ</a>.</p> + +<p>Firefox doesn't currently enforce this rule (it did for a while during the development of Firefox 3, but too many sites break when this rule is enforced). We encourage Web developers to fix their code to follow this rule for improved future compatibility.</p> + +<p> </p> + +<h2 id="Especificação">Especificação</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", "#dom-document-importnode", "document.importNode()")}}</td> + <td>{{Spec2("DOM WHATWG")}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName("DOM2 Core", "core.html#Core-Document-importNode", "document.importNode()")}}</td> + <td>{{Spec2("DOM2 Core")}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_Compatibility" name="Browser_Compatibility">Compatibilidade nos Browsers</h2> + +<div> + + +<p>{{Compat("api.Document.importNode")}}</p> +</div> + +<h2 id="Veja_também">Veja também</h2> + +<ul> + <li>{{domxref("document.adoptNode()")}}</li> +</ul> |