Index: chrome/browser/resources/md_downloads/crisper.js |
diff --git a/chrome/browser/resources/md_downloads/crisper.js b/chrome/browser/resources/md_downloads/crisper.js |
index 9d05ffdd5ae91cee082c934bf619d13186c33f6b..64e60e7097bb737561dddfd9cda4fc037a6732e3 100644 |
--- a/chrome/browser/resources/md_downloads/crisper.js |
+++ b/chrome/browser/resources/md_downloads/crisper.js |
@@ -1365,26 +1365,44 @@ function queryRequiredElement(selectors, opt_context) { |
if (e.defaultPrevented) |
return; |
+ var eventPath = e.path; |
+ var anchor = null; |
+ if (eventPath) { |
+ for (var i = 0; i < eventPath.length; i++) { |
+ var element = eventPath[i]; |
+ if (element.tagName === 'A' && element.href) { |
+ anchor = element; |
+ break; |
+ } |
+ } |
+ } |
+ |
+ // Fallback if Event.path is not available. |
var el = e.target; |
- if (el.nodeType == Node.ELEMENT_NODE && |
+ if (!anchor && el.nodeType == Node.ELEMENT_NODE && |
el.webkitMatchesSelector('A, A *')) { |
while (el.tagName != 'A') { |
el = el.parentElement; |
} |
+ anchor = el; |
+ } |
- if ((el.protocol == 'file:' || el.protocol == 'about:') && |
- (e.button == 0 || e.button == 1)) { |
- chrome.send('navigateToUrl', [ |
- el.href, |
- el.target, |
- e.button, |
- e.altKey, |
- e.ctrlKey, |
- e.metaKey, |
- e.shiftKey |
- ]); |
- e.preventDefault(); |
- } |
+ if (!anchor) |
+ return; |
+ |
+ anchor = /** @type {!HTMLAnchorElement} */(anchor); |
+ if ((anchor.protocol == 'file:' || anchor.protocol == 'about:') && |
+ (e.button == 0 || e.button == 1)) { |
+ chrome.send('navigateToUrl', [ |
+ anchor.href, |
+ anchor.target, |
+ e.button, |
+ e.altKey, |
+ e.ctrlKey, |
+ e.metaKey, |
+ e.shiftKey |
+ ]); |
+ e.preventDefault(); |
} |
}); |
}); |
@@ -11919,4 +11937,4 @@ cr.define('downloads', function() { |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-window.addEventListener('load', downloads.Manager.onLoad); |
+window.addEventListener('load', downloads.Manager.onLoad); |