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..b3d3ba4cb54d21be325da581830b3e1af277c5da 100644 |
| --- a/ui/webui/resources/js/util.js |
| +++ b/ui/webui/resources/js/util.js |
| @@ -216,26 +216,43 @@ document.addEventListener('click', function(e) { |
| 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; |
| + } |
| + } |
| + } |
|
Dan Beam
2016/08/08 19:29:48
could this work?
/**
* @param {!Node} node
* @r
Dan Beam
2016/08/08 21:28:00
actually, Array#find might also suck wrt compat UG
|
| + |
| 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 = 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; |
| + |
|
Dan Beam
2016/08/08 19:29:47
nit: anchor = /** @type {!HTMLAnchorElement} */(an
calamity
2016/08/09 08:39:07
Done.
|
| + 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(); |
| } |
| }); |