[Pkg-mozext-commits] [itsalltext] 412/459: Removed old-style Mutation detection

David Prévot taffit at moszumanska.debian.org
Tue Feb 24 23:26:43 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository itsalltext.

commit e8262d0d2a0381885f52f46952a0ed22720d008b
Author: Christian Höltje <docwhat at gerf.org>
Date:   Mon May 13 23:23:32 2013 -0400

    Removed old-style Mutation detection
    
    ...replaced with a MutationObserver.
---
 src/chrome/content/monitor.js | 42 +++++++++++++++++++++++-------------------
 1 file changed, 23 insertions(+), 19 deletions(-)

diff --git a/src/chrome/content/monitor.js b/src/chrome/content/monitor.js
index 2832d18..b2b7af0 100644
--- a/src/chrome/content/monitor.js
+++ b/src/chrome/content/monitor.js
@@ -168,28 +168,31 @@ Monitor.prototype.hitched_isLocked = function () {
     return this._lock_count > 0;
 };
 
-Monitor.prototype.hitched_handleSubtreeModified = function (event) {
-    var has_textareas;
-    if (this.isLocked()) {
-        return;
-    }
-    has_textareas = event.originalTarget.getElementsByTagName('textarea').length > 0;
-    if (has_textareas) {
-        //disabled-debug -- itsalltext.debug('handleSubtreeModified: %o', event.target);
-        try {
-            // Ignore events while adding the gumdrops.
-            this.incrementLock();
-            this.watcher(0, true);
-        } catch (e) {
-            this.decrementLock();
+Monitor.prototype.hitched_handleMutation = function (mutations, observer) {
+    var that = this;
+
+    mutations.forEach(function (mutation) {
+        if (that.isLocked()) {
+            return;
         }
-        this.decrementLock();
-    }
+
+        var has_textareas = mutation.target.getElementsByTagName('textarea').length > 0;
+        if (has_textareas) {
+            //disabled-debug -- itsalltext.debug('handleMutation: %o', event.target);
+            try {
+                // Ignore events while adding the gumdrops.
+                that.incrementLock();
+                that.watcher(0, true);
+            } catch (e) {
+                that.decrementLock();
+            }
+            that.decrementLock();
+        }
+    });
 };
 
 Monitor.prototype.hitched_startPage = function (event, force) {
-    var doc = event.originalTarget,
-    unsafeWin;
+    var doc = event.originalTarget, unsafeWin, observer;
     //disabled-debug -- itsalltext.debug('startPage', doc && doc.location, force);
     if (!(force || this.isHTML(doc))) {
         this.stopPage(event);
@@ -202,7 +205,8 @@ Monitor.prototype.hitched_startPage = function (event, force) {
     }
 
     // Listen for the subtree being modified.
-    itsalltext.listen(unsafeWin, 'DOMSubtreeModified', this.handleSubtreeModified);
+    observer  = new MutationObserver(this.handleMutation);
+    observer.observe(unsafeWin.document, { childList: true, subtree: true });
 
     // Kick off a watcher now...
     this.incrementLock();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/itsalltext.git



More information about the Pkg-mozext-commits mailing list