From 6664910170e1623a97b2d0b961788eab404dfdae Mon Sep 17 00:00:00 2001 From: "mtomasz@chromium.org" Date: Mon, 15 Apr 2013 04:53:36 +0000 Subject: Fix TagWatcher when a text node is added. The previous implementation was causing Javascript errors, when a text node got inserted to the document. This patch fixes this issue by checking if the inserted node is an Element node. TEST=(1) Add a node in inspector, (2) add
node, (3) add text node in inspector. BUG=222663 Review URL: https://chromiumcodereview.appspot.com/14222005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194138 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/renderer/resources/extensions/tag_watcher.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chrome/renderer/resources/extensions/tag_watcher.js b/chrome/renderer/resources/extensions/tag_watcher.js index 815eb60..1f5aaa7 100644 --- a/chrome/renderer/resources/extensions/tag_watcher.js +++ b/chrome/renderer/resources/extensions/tag_watcher.js @@ -21,10 +21,11 @@ function watchForTag(tagName, cb) { var documentObserver = new WebKitMutationObserver(function(mutations) { forEach(mutations, function(i, mutation) { forEach(mutation.addedNodes, function(i, addedNode) { - if (addedNode.tagName == tagName) { - cb(addedNode); + if (addedNode.nodeType == Node.ELEMENT_NODE) { + if (addedNode.tagName == tagName) + cb(addedNode); + findChildTags(addedNode); } - findChildTags(addedNode); }); }); }); @@ -32,4 +33,3 @@ function watchForTag(tagName, cb) { } exports.watchForTag = watchForTag; - -- cgit v1.1