summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormtomasz@chromium.org <mtomasz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-15 04:53:36 +0000
committermtomasz@chromium.org <mtomasz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-15 04:53:36 +0000
commit6664910170e1623a97b2d0b961788eab404dfdae (patch)
tree5f96f412413bbb04adb77c9ea9d6863e39cca626
parentec8499787764a5137bbb1b5565a68dc3d5201302 (diff)
downloadchromium_src-6664910170e1623a97b2d0b961788eab404dfdae.zip
chromium_src-6664910170e1623a97b2d0b961788eab404dfdae.tar.gz
chromium_src-6664910170e1623a97b2d0b961788eab404dfdae.tar.bz2
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 <webview...></webview> node in inspector, (2) add <div><webview...></webview></div> 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
-rw-r--r--chrome/renderer/resources/extensions/tag_watcher.js8
1 files 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;
-