aboutsummaryrefslogtreecommitdiff
path: root/files
diff options
context:
space:
mode:
authorIrvin <irvinfly@gmail.com>2021-08-17 02:46:21 +0800
committerGitHub <noreply@github.com>2021-08-17 02:46:21 +0800
commit2478646b4648d9c3b98482f186e542fc8ca0cc19 (patch)
treeed2cf4a397e5e6bd4bce72edae928494bb6dbac6 /files
parent13655caf6054c012946aa786a0675c8556c49805 (diff)
downloadtranslated-content-2478646b4648d9c3b98482f186e542fc8ca0cc19.tar.gz
translated-content-2478646b4648d9c3b98482f186e542fc8ca0cc19.tar.bz2
translated-content-2478646b4648d9c3b98482f186e542fc8ca0cc19.zip
bring some orphaned docs and relocate according to it's counterpart eng doc (partial revert #1616) (#1618)
* Revert "Remove previously orphaned file (#1616)" This reverts commit 49c5601989809c347a5a595e3c5edc08731e5305. * fix broken slugs * rm orphaned docs that eng origin is not available * Web/API/Element/after: sync origin english content
Diffstat (limited to 'files')
-rw-r--r--files/zh-cn/web/api/element/after/index.html91
-rw-r--r--files/zh-cn/web/api/element/before/index.html193
-rw-r--r--files/zh-cn/web/api/element/remove/index.html98
-rw-r--r--files/zh-cn/web/api/element/replacewith/index.html116
-rw-r--r--files/zh-cn/web/api/renderingcontext/index.html30
5 files changed, 528 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/element/after/index.html b/files/zh-cn/web/api/element/after/index.html
new file mode 100644
index 0000000000..ea111ec412
--- /dev/null
+++ b/files/zh-cn/web/api/element/after/index.html
@@ -0,0 +1,91 @@
+---
+title: Element.after()
+slug: Web/API/Element/after
+translation_of: Web/API/Element/after
+original_slug: Web/API/ChildNode/after
+tags:
+ - API
+ - DOM
+ - Method
+ - Node
+ - Reference
+browser-compat: api.Element.after
+---
+<div>{{APIRef("DOM")}}</div>
+
+<p><strong><code>Element.after()</code> </strong>方法会在其父节点的子节点列表中插入一些 {{domxref("Node")}} 或 {{domxref("DOMString")}} 对象。插入位置为该节点之后。{{domxref("DOMString")}} 对象会被以 {{domxref("Text")}} 的形式插入。</p>
+
+<h2 id="Syntax">语法</h2>
+
+<pre class="brush: js">
+after(... nodes)
+</pre>
+
+<h3 id="Parameters">参数</h3>
+
+<dl>
+ <dt><code>nodes</code></dt>
+ <dd>一组准备插入的 {{domxref("Node")}} 或 {{domxref("DOMString")}} 。</dd>
+</dl>
+
+<h3 id="Exceptions">错误</h3>
+
+<ul>
+ <li>{{domxref("HierarchyRequestError")}}: 在某些不正确的层级结构进行了插入操作。</li>
+</ul>
+
+<h2 id="Examples">示例</h2>
+
+<h3 id="Inserting_an_element">插入元素</h3>
+
+<pre class="brush: js">let container = document.createElement("div");
+let p = document.createElement("p");
+container.appendChild(p);
+let span = document.createElement("span");
+
+p.after(span);
+
+console.log(container.outerHTML);
+// "&lt;div&gt;&lt;p&gt;&lt;/p&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;"
+</pre>
+
+<h3 id="Inserting_text">插入文本</h3>
+
+<pre class="brush: js">let container = document.createElement("div");
+let p = document.createElement("p");
+container.appendChild(p);
+
+p.after("Text");
+
+console.log(container.outerHTML);
+// "&lt;div&gt;&lt;p&gt;&lt;/p&gt;Text&lt;/div&gt;"</pre>
+
+<h3 id="Inserting_an_element_and_text">同时插入元素和文本</h3>
+
+<pre class="brush: js">let container = document.createElement("div");
+let p = document.createElement("p");
+container.appendChild(p);
+let span = document.createElement("span");
+
+p.after(span, "Text");
+
+console.log(container.outerHTML);
+// "&lt;div&gt;&lt;p&gt;&lt;/p&gt;&lt;span&gt;&lt;/span&gt;Text&lt;/div&gt;"</pre>
+
+<h2 id="Specifications">规范</h2>
+
+{{Specifications}}
+
+<h2 id="Browser_compatibility">浏览器兼容性</h2>
+
+<p>{{Compat}}</p>
+
+<h2 id="See_also">相关链接</h2>
+
+<ul>
+ <li>{{domxref("Element.before()")}}</li>
+ <li>{{domxref("Element.append()")}}</li>
+ <li>{{domxref("Node.appendChild()")}}</li>
+ <li>{{domxref("Element.insertAdjacentElement()")}}</li>
+ <li>{{domxref("NodeList")}}</li>
+</ul>
diff --git a/files/zh-cn/web/api/element/before/index.html b/files/zh-cn/web/api/element/before/index.html
new file mode 100644
index 0000000000..11553a0194
--- /dev/null
+++ b/files/zh-cn/web/api/element/before/index.html
@@ -0,0 +1,193 @@
+---
+title: Element.before()
+slug: Web/API/Element/before
+tags:
+ - API
+ - DOM
+ - Method
+ - Node
+ - Reference
+translation_of: Web/API/Element/before
+original_slug: Web/API/ChildNode/before
+browser-compat: api.Element.before
+---
+<div>{{APIRef("DOM")}} {{SeeCompatTable}}</div>
+
+<p> <code><strong>ChildNode</strong></code><strong><code>.before</code></strong> 方法可以在<code>ChildNode这个节点的父节点中插入一些列的</code> {{domxref("Node")}} 或者 {{domxref("DOMString")}} 对象,位置就是在<code>ChildNode节点的前面,</code>{{domxref("DOMString")}} 对象其实和 {{domxref("Text")}}节点一样的方式来完成插入的。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">[Throws, Unscopable]
+void Element.before((Node or DOMString)... nodes);
+</pre>
+
+<h3 id="Parameters参数">Parameters参数</h3>
+
+<dl>
+ <dt><code>nodes</code></dt>
+ <dd>一系列的 {{domxref("Node")}} 或者 {{domxref("DOMString")}} </dd>
+</dl>
+
+<h3 id="Exceptions">Exceptions</h3>
+
+<ul>
+ <li>{{domxref("HierarchyRequestError")}}: 当节点插入了错误的层级就会出现报错,需要遵循html标签的层级关系,</li>
+</ul>
+
+<h2 id="Examples事例">Examples事例</h2>
+
+<h3 id="Inserting_an_element插入元素节点">Inserting an element插入元素节点</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);
+// "&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;"
+</pre>
+
+<h3 id="Inserting_text插入文本节点">Inserting text插入文本节点</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);
+// "&lt;div&gt;Text&lt;p&gt;&lt;/p&gt;&lt;/div&gt;"</pre>
+
+<h3 id="Inserting_an_element_and_text同时插入文本和元素">Inserting an element and text同时插入文本和元素</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);
+// "&lt;div&gt;&lt;span&gt;&lt;/span&gt;Text&lt;p&gt;&lt;/p&gt;&lt;/div&gt;"</pre>
+
+<h3 id="Element.before()_is_unscopable不可使用区域"><code>Element.before()</code> is unscopable不可使用区域</h3>
+
+<p>The <code>before()</code> 不能配合with声明使用,See {{jsxref("Symbol.unscopables")}} for more information.</p>
+
+<pre class="brush: js">with(node) {
+ before("foo");
+}
+// ReferenceError: before is not defined </pre>
+
+<h2 id="Polyfill">Polyfill</h2>
+
+<p>兼容ie9或者更高版本的方法,You can polyfill the <code>before() method</code> in Internet Explorer 9 and higher with the following 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="Specification">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', '#dom-childnode-before', 'Element.before()')}}</td>
+ <td>{{Spec2('DOM WHATWG')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p>{{CompatibilityTable}}</p>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatChrome(54.0)}}</td>
+ <td>{{CompatGeckoDesktop(49)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatOpera(39)}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Android</th>
+ <th>Android Webview</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ <th>Chrome for Android</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatChrome(54.0)}}</td>
+ <td>{{CompatGeckoMobile(49)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatOpera(39)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatChrome(54.0)}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>{{domxref("ChildNode")}} and {{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>
diff --git a/files/zh-cn/web/api/element/remove/index.html b/files/zh-cn/web/api/element/remove/index.html
new file mode 100644
index 0000000000..b244385222
--- /dev/null
+++ b/files/zh-cn/web/api/element/remove/index.html
@@ -0,0 +1,98 @@
+---
+
+title: Element.remove()
+slug: Web/API/Element/remove
+tags:
+ - API
+ - Element
+ - DOM
+ - Method
+translation_of: Web/API/Element/remove
+original_slug: Web/API/ChildNode/remove
+browser-compat: api.Element.remove
+---
+<p>{{APIRef("DOM")}}</p>
+
+<p><code><strong>Element.remove()</strong></code> 方法,把对象从它所属的 DOM 树中删除。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox"><var>node</var>.remove();</pre>
+
+<h2 id="示例">示例</h2>
+
+<h3 id="使用_remove()">使用 <code>remove()</code></h3>
+
+<pre class="brush: html">&lt;div id="div-01"&gt;Here is div-01&lt;/div&gt;
+&lt;div id="div-02"&gt;Here is div-02&lt;/div&gt;
+&lt;div id="div-03"&gt;Here is div-03&lt;/div&gt;
+</pre>
+
+<pre class="brush: js">var el = document.getElementById('div-02');
+el.remove();
+// id 为 'div-02' 的 div 被删掉了
+</pre>
+
+<p>{{EmbedLiveSample('使用_remove()')}}</p>
+
+<h3 id="Element.remove()_是不可见的"><code>Element.remove()</code> 是不可见的</h3>
+
+<p>在 <code>with</code> 语句中,<code>remove()</code> 方法是不可见的。参阅 {{jsxref("Symbol.unscopables")}} 了解更多信息。</p>
+
+<pre class="brush: js">with(node) {
+ remove();
+}
+// ReferenceError: remove is not defined</pre>
+
+<h2 id="Polyfill">Polyfill</h2>
+
+<p>You can polyfill the <code>remove()</code> method in Internet Explorer 9 and higher with the following code:</p>
+
+<pre class="brush: js">//https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md
+(function (arr) {
+ arr.forEach(function (item) {
+ if (item.hasOwnProperty('remove')) {
+ return;
+ }
+ Object.defineProperty(item, 'remove', {
+ configurable: true,
+ enumerable: true,
+ writable: true,
+ value: function remove() {
+ this.parentNode.removeChild(this);
+ }
+ });
+ });
+})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);</pre>
+
+<h2 id="Specification" name="Specification">规范</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-remove', 'Element.remove')}}</td>
+ <td>{{Spec2('DOM WHATWG')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("api.Element.remove")}}</p>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li>{{domxref("ChildNode")}} 纯接口。</li>
+ <li>
+ <div class="syntaxbox">实现此纯接口的对象类型: {{domxref("CharacterData")}}、{{domxref("Element")}} , 和 {{domxref("DocumentType")}}.</div>
+ </li>
+</ul>
diff --git a/files/zh-cn/web/api/element/replacewith/index.html b/files/zh-cn/web/api/element/replacewith/index.html
new file mode 100644
index 0000000000..13fe96c23b
--- /dev/null
+++ b/files/zh-cn/web/api/element/replacewith/index.html
@@ -0,0 +1,116 @@
+---
+title: Element.replaceWith()
+slug: Web/API/Element/replaceWith
+tags:
+ - API
+ - DOM
+ - Method
+ - Element
+ - Reference
+browser-compat: api.Element.replaceWith
+translation_of: Web/API/Element/replaceWith
+original_slug: Web/API/ChildNode/replaceWith
+---
+<div>{{APIRef("DOM")}} {{SeeCompatTable}}</div>
+
+<p><code><strong>ChildNode</strong></code><strong><code>.replaceWith()</code></strong> 的方法用一套 {{domxref("Node")}} 对象或者 {{domxref("DOMString")}} 对象,替换了该节点父节点下的子节点 。{{domxref("DOMString")}} 对象被当做等效的{{domxref("Text")}} 节点插入。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">[Throws, Unscopable]
+void ChildNode.replaceWith((Node or DOMString)... nodes);
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>节点</code></dt>
+ <dd>一系列用来替换的{{domxref("Node")}} 对象或者 {{domxref("DOMString")}} 对象。</dd>
+</dl>
+
+<h3 id="例外">例外</h3>
+
+<ul>
+ <li>{{domxref("HierarchyRequestError")}}: 无法在层次结构中的指定点插入节点。</li>
+</ul>
+
+<h2 id="案例">案例</h2>
+
+<h3 id="Using_replaceWith">Using <code>replaceWith()</code></h3>
+
+<pre class="brush: js">var parent = document.createElement("div");
+var child = document.createElement("p");
+parent.appendChild(child);
+var span = document.createElement("span");
+
+child.replaceWith(span);
+
+console.log(parent.outerHTML);
+// "&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;"
+</pre>
+
+<h3 id="ChildNode.replaceWith_is_unscopable"><code>ChildNode.replaceWith()</code> is unscopable</h3>
+
+<p><code>replaceWith()</code>的方法并没有作用于with语句. 参考 {{jsxref("Symbol.unscopables")}} 获取更多信息.</p>
+
+<pre class="brush: js">with(node) {
+ replaceWith("foo");
+}
+// ReferenceError: replaceWith is not defined </pre>
+
+<h2 id="Polyfill">Polyfill</h2>
+
+<p>你可以在IE9及更高级的浏览器中使用下面的代码向上兼容<code>replaceWith()</code>的方法:</p>
+
+<pre class="brush: js">(function (arr) {
+ arr.forEach(function (item) {
+ if (item.hasOwnProperty('replaceWith')) {
+ return;
+ }
+ Object.defineProperty(item, 'replaceWith', {
+ configurable: true,
+ enumerable: true,
+ writable: true,
+ value: function replaceWith() {
+ 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.replaceChild(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-replacewith', 'ChildNode.replacewith()')}}</td>
+ <td>{{Spec2('DOM WHATWG')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{Compat("api.ChildNode.replaceWith")}}</p>
+
+<h2 id="参阅">参阅</h2>
+
+<ul>
+ <li>{{domxref("ChildNode")}} 和 {{domxref("ParentNode")}}</li>
+ <li>{{domxref("Node.replaceChild()")}}</li>
+ <li>{{domxref("NodeList")}}</li>
+</ul>
diff --git a/files/zh-cn/web/api/renderingcontext/index.html b/files/zh-cn/web/api/renderingcontext/index.html
new file mode 100644
index 0000000000..4cf1dfc0b7
--- /dev/null
+++ b/files/zh-cn/web/api/renderingcontext/index.html
@@ -0,0 +1,30 @@
+---
+title: RenderingContext
+slug: Web/API/RenderingContext
+translation_of: Web/API/RenderingContext
+original_slug: Web/API/RenderingContext
+---
+<p>{{APIRef("Canvas API")}}</p>
+
+<p><code><strong>RenderingContext</strong></code> 是一个辅助类型,描述下面任何一个渲染上下文:  {{domxref("CanvasRenderingContext2D")}}, {{domxref("WebGLRenderingContext")}} 或者 {{domxref("WebGL2RenderingContext")}} (继承自 <code>WebGLRenderingContext</code>)。</p>
+
+<p>这是简化规范的辅助类型,它不是一个接口,也没有对象实现它。</p>
+
+<h2 id="规范描述">规范描述</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('HTML WHATWG', "scripting.html#renderingcontext", "RenderingContext")}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<p> </p> \ No newline at end of file