Bug 853456 - Walk up DOM tree to find target of links. r=mfinkle
authorWes Johnston <wjohnston@mozilla.com>
Tue, 23 Apr 2013 10:10:44 -0700
changeset 140599 3c0e77a706f47a2b2a337a1de0e67e497d462190
parent 140598 8a4e38fbd3f7f2b63ff7fa252137bdacde7e6d71
child 140600 57af1961439a359356a05b391cf8d29a8783e34a
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs853456
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 853456 - Walk up DOM tree to find target of links. r=mfinkle
mobile/android/chrome/content/WebAppRT.js
--- a/mobile/android/chrome/content/WebAppRT.js
+++ b/mobile/android/chrome/content/WebAppRT.js
@@ -128,18 +128,22 @@ let WebAppRT = {
         Services.prefs.setIntPref(aPref.name, aPref.value);
         break;
     }
   },
 
   handleEvent: function(event) {
     let target = event.target;
   
-    if (!(target instanceof HTMLAnchorElement) ||
-        target.getAttribute("target") != "_blank") {
+    // walk up the tree to find the nearest link tag
+    while(target && !(target instanceof HTMLAnchorElement)) {
+      target = target.parentNode;
+    }
+
+    if (!target || target.getAttribute("target") != "_blank") {
       return;
     }
   
     let uri = Services.io.newURI(target.href,
                                  target.ownerDocument.characterSet,
                                  null);
   
     // Direct the URL to the browser.