diff options
Diffstat (limited to 'files/zh-cn/web')
-rw-r--r-- | files/zh-cn/web/api/domlocator/index.html | 51 | ||||
-rw-r--r-- | files/zh-cn/web/api/element/after/index.html | 176 | ||||
-rw-r--r-- | files/zh-cn/web/api/element/before/index.html | 188 | ||||
-rw-r--r-- | files/zh-cn/web/api/element/remove/index.html | 96 | ||||
-rw-r--r-- | files/zh-cn/web/api/element/replacewith/index.html | 112 | ||||
-rw-r--r-- | files/zh-cn/web/api/renderingcontext/index.html | 30 | ||||
-rw-r--r-- | files/zh-cn/web/events/mutation_events/index.html | 63 |
7 files changed, 0 insertions, 716 deletions
diff --git a/files/zh-cn/web/api/domlocator/index.html b/files/zh-cn/web/api/domlocator/index.html deleted file mode 100644 index 77ad2f17bb..0000000000 --- a/files/zh-cn/web/api/domlocator/index.html +++ /dev/null @@ -1,51 +0,0 @@ ---- -title: DOMLocator -slug: orphaned/Web/API/DOMLocator -translation_of: Web/API/DOMLocator -original_slug: Web/API/DOMLocator ---- -<p>{{APIRef("DOM")}}{{obsolete_header}}</p> - -<div class="warning"> -<p>NOTE: This is not implemented in Mozilla</p> -</div> - -<p>Indicates a location such as where an error occurred. Returned by DOMError.location.</p> - -<h2 id="Properties">Properties</h2> - -<dl> - <dt>{{domxref("DOMLocator.lineNumber")}} {{ReadOnlyInline}}</dt> - <dd>Returns a positiove integer or -1.</dd> - <dt>{{domxref("DOMLocator.columnNumber")}} {{ReadOnlyInline}}</dt> - <dd>Returns a positiove integer or -1.</dd> - <dt>{{domxref("DOMLocator.byteOffset")}} {{ReadOnlyInline}}</dt> - <dd>Returns a positiove integer or -1.</dd> - <dt>{{domxref("DOMLocator.utf16Offset")}} {{ReadOnlyInline}}</dt> - <dd>Returns a positiove integer or -1.</dd> - <dt>{{domxref("DOMLocator.relatedNode")}} {{ReadOnlyInline}}</dt> - <dd>Returns a positiove integer or -1.</dd> - <dt>{{domxref("DOMLocator.uri")}} {{ReadOnlyInline}}</dt> - <dd>Returns a positiove integer or -1.</dd> -</dl> - -<h2 id="Methods">Methods</h2> - -<p><em>This interface neither implements, nor inherits, any method.</em></p> - -<h2 id="Specifications">Specifications</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("DOM3 Core", "core.html#Interfaces-DOMLocator", "DOMLocator")}}</td> - <td>{{Spec2("DOM3 Core")}}</td> - <td>Initial definition</td> - </tr> - </tbody> -</table>
\ No newline at end of file diff --git a/files/zh-cn/web/api/element/after/index.html b/files/zh-cn/web/api/element/after/index.html deleted file mode 100644 index 76792e7638..0000000000 --- a/files/zh-cn/web/api/element/after/index.html +++ /dev/null @@ -1,176 +0,0 @@ ---- -title: ChildNode.after() -slug: orphaned/Web/API/ChildNode/after -translation_of: Web/API/ChildNode/after -original_slug: Web/API/ChildNode/after ---- -<div>{{APIRef("DOM")}}</div> - -<p><strong><code>ChildNode.after()</code> </strong>方法会在其父节点的子节点列表中插入一些<font face="Consolas, Liberation Mono, Courier, monospace"> </font>{{domxref("Node")}} 或<font face="Consolas, Liberation Mono, Courier, monospace"> </font>{{domxref("DOMString")}} 对象。插入位置为该节点之后。{{domxref("DOMString")}} 对象会被以<font face="Consolas, Liberation Mono, Courier, monospace"> </font>{{domxref("Text")}} 的形式插入。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox notranslate">[Throws, Unscopable] -void ChildNode.after((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 notranslate">var parent = document.createElement("div"); -var child = document.createElement("p"); -parent.appendChild(child); -var span = document.createElement("span"); - -child.after(span); - -console.log(parent.outerHTML); -// "<div><p></p><span></span></div>" -</pre> - -<h3 id="插入文本">插入文本</h3> - -<pre class="brush: js notranslate">var parent = document.createElement("div"); -var child = document.createElement("p"); -parent.appendChild(child); - -child.after("Text"); - -console.log(parent.outerHTML); -// "<div><p></p>Text</div>"</pre> - -<h3 id="同时插入元素和文本">同时插入元素和文本</h3> - -<pre class="brush: js notranslate">var parent = document.createElement("div"); -var child = document.createElement("p"); -parent.appendChild(child); -var span = document.createElement("span"); - -child.after(span, "Text"); - -console.log(parent.outerHTML); -// "<div><p></p><span></span>Text</div>"</pre> - -<h3 id="ChildNode.after_会被_with_环境排除"><code>ChildNode.after()</code> 会被 with 环境排除</h3> - -<p><code>after()</code> 方法不在 <code>with 环境的范围内,可以查看</code> {{jsxref("Symbol.unscopables")}} 来了解更多信息。</p> - -<pre class="brush: js notranslate">with(node) { - after("foo"); -} -// ReferenceError: after is not defined </pre> - -<h2 id="Polyfill">Polyfill</h2> - -<p>You can polyfill the <code>after()</code> method in Internet Explorer 9 and higher with the following code:</p> - -<pre class="brush: js notranslate">// from: https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/after()/after().md -(function (arr) { - arr.forEach(function (item) { - if (item.hasOwnProperty('after')) { - return; - } - Object.defineProperty(item, 'after', { - configurable: true, - enumerable: true, - writable: true, - value: function after() { - 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.nextSibling); - } - }); - }); -})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);</pre> - -<h3 id="Another_polyfill">Another polyfill</h3> - -<pre class="brush: js notranslate">// from: https://github.com/FabioVergani/js-Polyfill_Element.prototype.after/blob/master/after.js - -(function(x){ - var o=x.prototype,p='after'; - if(!o[p]){ - o[p]=function(){ - var e, m=arguments, l=m.length, i=0, t=this, p=t.parentNode, n=Node, s=String, d=document; - if(p!==null){ - while(i<l){ - e=m[i]; - if(e instanceof n){ - t=t.nextSibling; - if(t!==null){ - p.insertBefore(e,t); - }else{ - p.appendChild(e); - }; - }else{ - p.appendChild(d.createTextNode(s(e))); - }; - ++i; - }; - }; - }; - }; -})(Element); - - - -/* -minified: - -(function(x){ - var o=x.prototype; - o.after||(o.after=function(){var e,m=arguments,l=m.length,i=0,t=this,p=t.parentNode,n=Node,s=String,d=document;if(p!==null){while(i<l){((e=m[i]) instanceof n)?(((t=t.nextSibling )!==null)?p.insertBefore(e,t):p.appendChild(e)):p.appendChild(d.createTextNode(s(e)));++i;}}}); -}(Element)); -*/</pre> - -<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('DOM WHATWG', '#dom-childnode-after', 'ChildNode.after()')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<p>{{Compat("api.ChildNode.after")}}</p> - -<h2 id="相关链接">相关链接</h2> - -<ul> - <li>{{domxref("ChildNode")}} 和 {{domxref("ParentNode")}}</li> - <li>{{domxref("ChildNode.before()")}}</li> - <li>{{domxref("ParentNode.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 deleted file mode 100644 index add3dab015..0000000000 --- a/files/zh-cn/web/api/element/before/index.html +++ /dev/null @@ -1,188 +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</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 ChildNode.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); -// "<div><span></span><p></p></div>" -</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); -// "<div>Text<p></p></div>"</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); -// "<div><span></span>Text<p></p></div>"</pre> - -<h3 id="ChildNode.before()_is_unscopable不可使用区域"><code>ChildNode.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', 'ChildNode.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 deleted file mode 100644 index b60cab7a0c..0000000000 --- a/files/zh-cn/web/api/element/remove/index.html +++ /dev/null @@ -1,96 +0,0 @@ ---- -title: ChildNode.remove() -slug: orphaned/Web/API/ChildNode/remove -tags: - - API - - ChildNode - - DOM - - Method -translation_of: Web/API/ChildNode/remove -original_slug: Web/API/ChildNode/remove ---- -<p>{{APIRef("DOM")}}</p> - -<p><code><strong>ChildNode.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"><div id="div-01">Here is div-01</div> -<div id="div-02">Here is div-02</div> -<div id="div-03">Here is div-03</div> -</pre> - -<pre class="brush: js">var el = document.getElementById('div-02'); -el.remove(); -// id 为 'div-02' 的 div 被删掉了 -</pre> - -<p>{{EmbedLiveSample('使用_remove()')}}</p> - -<h3 id="ChildNode.remove()_是不可见的"><code>ChildNode.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', 'ChildNode.remove')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("api.ChildNode.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 deleted file mode 100644 index 9f3ef5bd88..0000000000 --- a/files/zh-cn/web/api/element/replacewith/index.html +++ /dev/null @@ -1,112 +0,0 @@ ---- -title: ChildNode.replaceWith() -slug: orphaned/Web/API/ChildNode/replaceWith -tags: - - DOM - - Node -translation_of: Web/API/ChildNode/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); -// "<div><span></span></div>" -</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 deleted file mode 100644 index 3a1477c435..0000000000 --- a/files/zh-cn/web/api/renderingcontext/index.html +++ /dev/null @@ -1,30 +0,0 @@ ---- -title: RenderingContext -slug: orphaned/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 diff --git a/files/zh-cn/web/events/mutation_events/index.html b/files/zh-cn/web/events/mutation_events/index.html deleted file mode 100644 index 732cb7614b..0000000000 --- a/files/zh-cn/web/events/mutation_events/index.html +++ /dev/null @@ -1,63 +0,0 @@ ---- -title: Mutation events -slug: orphaned/Web/Guide/Events/Mutation_events -translation_of: Web/Guide/Events/Mutation_events -original_slug: Web/Guide/Events/Mutation_events ---- -<p>{{deprecated_header()}}</p> - -<p><strong>Mutation 事件 </strong>为web页面提供一种机制或扩展,以便在DOM被改变时获得通知。<span style="background-color: #ffff00;">如果可能请用<a href="/en-US/docs/Web/API/MutationObserver" title="/en-US/docs/Web/API/MutationObserver">Mutation Observers</a>代替。</span></p> - -<h2 id="前言">前言</h2> - -<p id="Replacement.3A_mutation_observers">这个 mutation 事件在<a class="external" href="http://www.w3.org/TR/DOM-Level-3-Events/#events-mutationevents">DOM Events 标准</a> 中已被列为反对使用 , 因为在API的设计中有缺陷 (详情见发表于 <span id="to"><a class="external" href="http://lists.w3.org/Archives/Public/public-webapps/2011JulSep/0779.html">public-webapps</a> 的</span>"DOM Mutation Events Replacement: The Story So Far / Existing Points of Consensus" <span id="to">)</span>. </p> - -<p><a href="/en-US/docs/Web/API/MutationObserver">Mutation Observers</a> 在DOM4中被提议用来取代mutation事件. 预计它们被列入 in Firefox 14 and <a class="external" href="http://updates.html5rocks.com/2012/02/Detect-DOM-changes-with-Mutation-Observers" title="http://updates.html5rocks.com/2012/02/Detect-DOM-changes-with-Mutation-Observers">Chrome 18</a>中。</p> - -<p>避免用mutation事件的实际原因是<strong>性能问题</strong>和<strong>跨浏览器支持</strong>。</p> - -<h3 id="性能">性能</h3> - -<p>为DOM添加 mutation 监听器极度降低进一步修改DOM文档的性能(慢1.5 - 7倍),此外, 移除监听器不会逆转的损害。</p> - -<p>性能好坏 <a class="link-https" href="https://groups.google.com/forum/#!topic/mozilla.dev.platform/UH2VqFQRTDA" title="https://groups.google.com/forum/#!topic/mozilla.dev.platform/UH2VqFQRTDA">限制了文档拥有mutation事件监听</a>.</p> - -<h3 id="跨浏览器支持">跨浏览器支持</h3> - -<p>这些事件在不同的浏览器实现并不一致, 例如:</p> - -<ul> - <li>IE9之前的版本不支持mutation 事件而且在IE9版本中没有正确实现其中某些事件(<a class="external" href="http://help.dottoro.com/ljmcxjla.php" title="http://help.dottoro.com/ljmcxjla.php">例如, DOMNodeInserted</a>)</li> - <li>WebKit 不支持 DOMAttrModified (见 <a class="link-https" href="https://bugs.webkit.org/show_bug.cgi?id=8191" title="https://bugs.webkit.org/show_bug.cgi?id=8191">webkit bug 8191</a> 和 <a class="external" href="http://about.silkapp.com/page/Mutation%20Events:%20What%20Happen" title="http://about.silkapp.com/page/Mutation%20Events:%20What%20Happen">the workaround</a>)</li> - <li>"mutation name events", i.e. DOMElementNameChanged 和 DOMAttributeNameChanged 在Firefox中不被支持 (到 version 11), 可能其他浏览器也是这样.</li> - <li>...</li> -</ul> - -<p>Dottoro <a class="external" href="http://help.dottoro.com/ljfvvdnm.php#additionalEvents" title="http://help.dottoro.com/ljfvvdnm.php#additionalEvents">documents browser support for mutation events</a>.</p> - -<h2 id="Mutation_事件列表">Mutation 事件列表</h2> - -<p>下面是所有 mutation 事件列表, <a class="external" href="http://www.w3.org/TR/DOM-Level-3-Events/#events-mutationevents" title="http://www.w3.org/TR/DOM-Level-3-Events/#events-mutationevents">DOM Level 3 Events specification</a> 中定义的:</p> - -<ul> - <li><code>DOMAttrModified</code></li> - <li><code>DOMAttributeNameChanged</code></li> - <li><code>DOMCharacterDataModified</code></li> - <li><code>DOMElementNameChanged</code></li> - <li><code>DOMNodeInserted</code></li> - <li><code>DOMNodeInsertedIntoDocument</code></li> - <li><code>DOMNodeRemoved</code></li> - <li><code>DOMNodeRemovedFromDocument</code></li> - <li><code>DOMSubtreeModified</code></li> -</ul> - -<h2 id="使用">使用</h2> - -<p>你可以如下所示使用<a href="/en/DOM/element.addEventListener" title="en/DOM/element.addEventListener">element.addEventListener</a> 注册一个mutation 事件监听器:</p> - -<pre><code>element.addEventListener("DOMNodeInserted", function (ev) {</code> - // ... -<code>}, false);</code> -</pre> - -<p>事件对象在 {{ domxref("MutationEvent") }}传递给监听器 (见 <a class="external" href="http://www.w3.org/TR/DOM-Level-3-Events/#events-MutationEvent" title="http://www.w3.org/TR/DOM-Level-3-Events/#events-MutationEvent">its definition in the specification</a>) 对于大多数的事件, 和 {{ domxref("MutationNameEvent") }} 用于 <code>DOMAttributeNameChanged</code> and <code>DOMElementNameChanged</code>.</p> |