Chromium Code Reviews| Index: ui/webui/resources/js/util.js |
| diff --git a/ui/webui/resources/js/util.js b/ui/webui/resources/js/util.js |
| index 293205804389a21425c26bc0c26756533d9e42ea..d4207ad87e1b8897bb900f538af0abe08ea9629d 100644 |
| --- a/ui/webui/resources/js/util.js |
| +++ b/ui/webui/resources/js/util.js |
| @@ -216,26 +216,31 @@ document.addEventListener('click', function(e) { |
| if (e.defaultPrevented) |
|
Dan Beam
2016/08/02 06:02:44
nit: in my ideal world
if (e.defaultPrevented ||
calamity
2016/08/08 05:06:43
Acknowledged.
|
| return; |
| - var el = e.target; |
| - if (el.nodeType == Node.ELEMENT_NODE && |
| - el.webkitMatchesSelector('A, A *')) { |
| - while (el.tagName != 'A') { |
| - el = el.parentElement; |
| + var eventPath = e.path; |
|
Dan Beam
2016/08/02 06:02:43
this code runs on safari, which may have dodgy sup
calamity
2016/08/08 05:06:43
Done.
|
| + var anchor = null; |
| + for (var i = 0; i < eventPath.length; i++) { |
| + var element = eventPath[i]; |
| + if (element.tagName === 'A' && element.href) { |
| + anchor = element; |
| + break; |
| } |
| + } |
| - 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; |
| + |
| + 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(); |
| } |
| }); |