From b9afb23d12dcae1e09f8d04c72143c5ddaa34aea Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Fri, 16 Jul 2021 16:27:00 -0400 Subject: delete conflicting/orphaned docs (zh-CN) (#1412) * delete conflicting docs (zh-CN) * and redirects * do orphaned as well * fix * remove more orphans * revert orphaned docs that can identify origin * move orphaned docs to current loc * adjust slug path * fix redirect change from rebase Co-authored-by: Irvin --- files/zh-cn/web/events/mutation_events/index.html | 63 +++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 files/zh-cn/web/events/mutation_events/index.html (limited to 'files/zh-cn/web/events/mutation_events/index.html') diff --git a/files/zh-cn/web/events/mutation_events/index.html b/files/zh-cn/web/events/mutation_events/index.html new file mode 100644 index 0000000000..732cb7614b --- /dev/null +++ b/files/zh-cn/web/events/mutation_events/index.html @@ -0,0 +1,63 @@ +--- +title: Mutation events +slug: orphaned/Web/Guide/Events/Mutation_events +translation_of: Web/Guide/Events/Mutation_events +original_slug: Web/Guide/Events/Mutation_events +--- +

{{deprecated_header()}}

+ +

Mutation 事件 为web页面提供一种机制或扩展,以便在DOM被改变时获得通知。如果可能请用Mutation Observers代替。

+ +

前言

+ +

这个 mutation 事件在DOM Events 标准 中已被列为反对使用 , 因为在API的设计中有缺陷 (详情见发表于 public-webapps 的"DOM Mutation Events Replacement: The Story So Far / Existing Points of Consensus" )

+ +

Mutation Observers 在DOM4中被提议用来取代mutation事件. 预计它们被列入 in Firefox 14 and Chrome 18中。

+ +

避免用mutation事件的实际原因是性能问题跨浏览器支持

+ +

性能

+ +

为DOM添加 mutation 监听器极度降低进一步修改DOM文档的性能(慢1.5 - 7倍),此外, 移除监听器不会逆转的损害。

+ +

性能好坏 限制了文档拥有mutation事件监听.

+ +

跨浏览器支持

+ +

这些事件在不同的浏览器实现并不一致, 例如:

+ + + +

Dottoro documents browser support for mutation events.

+ +

Mutation 事件列表

+ +

下面是所有 mutation 事件列表, DOM Level 3 Events specification 中定义的:

+ + + +

使用

+ +

你可以如下所示使用element.addEventListener 注册一个mutation 事件监听器:

+ +
element.addEventListener("DOMNodeInserted", function (ev) {
+  // ...
+}, false);
+
+ +

事件对象在 {{ domxref("MutationEvent") }}传递给监听器 (见 its definition in the specification) 对于大多数的事件, 和 {{ domxref("MutationNameEvent") }} 用于 DOMAttributeNameChanged and DOMElementNameChanged.

-- cgit v1.2.3-54-g00ecf