[Pkg-mozext-commits] [wot] 48/226: Use DOM Mutation Observers instead of Mutation events. Fixes #16
David Prévot
taffit at moszumanska.debian.org
Fri May 1 00:35:33 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository wot.
commit 75c6f36d3bfac606d2a601d873fdd31a9be47f12
Author: Sami Tolvanen <sami at mywot.com>
Date: Thu Sep 20 13:55:02 2012 +0300
Use DOM Mutation Observers instead of Mutation events. Fixes #16
---
content/search.js | 36 ++++++++++++++----------------------
1 file changed, 14 insertions(+), 22 deletions(-)
diff --git a/content/search.js b/content/search.js
index 6ae5d4d..54e2d3a 100644
--- a/content/search.js
+++ b/content/search.js
@@ -443,26 +443,6 @@ var wot_search =
}
},
- onchange: function(event)
- {
- try {
- var content = event.currentTarget;
-
- if (!content) {
- return;
- }
-
- content.removeEventListener("DOMNodeInserted", wot_search.onchange,
- false);
-
- window.setTimeout(function() {
- wot_search.watch(content);
- }, 1000);
- } catch (e) {
- dump("wot_search.onchange: failed with " + e + "\n");
- }
- },
-
watch: function(content)
{
try {
@@ -476,8 +456,20 @@ var wot_search =
return;
}
- content.addEventListener("DOMNodeInserted", wot_search.onchange,
- false);
+ wot_search.observer = new MutationObserver(function(mutation) {
+ if (wot_search.observer) {
+ wot_search.observer.disconnect();
+ wot_search.observer = null;
+ }
+
+ window.setTimeout(function() {
+ wot_search.watch(content);
+ }, 500);
+ });
+
+ wot_search.observer.observe(content, {
+ attributes: true, childList: true, subtree: true
+ });
} catch (e) {
dump("wot_search.watch: failed with " + e + "\n");
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/wot.git
More information about the Pkg-mozext-commits
mailing list