diff options
| author | Jez Ng | 2012-01-18 09:16:43 +0800 |
|---|---|---|
| committer | Jez Ng | 2012-01-18 09:29:59 +0800 |
| commit | 7e981d61eb70817924bcecd64745f1cdd3615955 (patch) | |
| tree | f4d4b4207b344c354685fcc3ed061634eea30224 /linkHints.js | |
| parent | 91ded7b7960da5b2e18ce087c15a6223635564e1 (diff) | |
| download | vimium-7e981d61eb70817924bcecd64745f1cdd3615955.tar.bz2 | |
Prevent link hinting from throwing an exception.
This was causing hinting to fail entirely on some pages.
Diffstat (limited to 'linkHints.js')
| -rw-r--r-- | linkHints.js | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/linkHints.js b/linkHints.js index 2c0f6504..f603add8 100644 --- a/linkHints.js +++ b/linkHints.js @@ -128,15 +128,18 @@ var linkHints = { if (element.localName === "area") { var map = element.parentElement; + if (!map) continue; var img = document.querySelector("img[usemap='#" + map.getAttribute("name") + "']"); - var clientRect = img.getClientRects()[0]; + if (!img) continue; + var imgClientRects = img.getClientRects(); + if (!imgClientRects) continue; var c = element.coords.split(/,/); var coords = [parseInt(c[0], 10), parseInt(c[1], 10), parseInt(c[2], 10), parseInt(c[3], 10)]; var rect = { - top: clientRect.top + coords[1], - left: clientRect.left + coords[0], - right: clientRect.left + coords[2], - bottom: clientRect.top + coords[3], + top: imgClientRects[0].top + coords[1], + left: imgClientRects[0].left + coords[0], + right: imgClientRects[0].left + coords[2], + bottom: imgClientRects[0].top + coords[3], width: coords[2] - coords[0], height: coords[3] - coords[1] }; |
