From 83cd31cf36b469a0cee29ed13d90279a5b76f0a5 Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Tue, 10 Jan 2012 01:38:54 +0800 Subject: Fix regression -- issue #286 is reactivated by 34bc211. --- linkHints.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/linkHints.js b/linkHints.js index 170dacb8..9ee56781 100644 --- a/linkHints.js +++ b/linkHints.js @@ -151,8 +151,9 @@ var linkHints = { getVisibleClientRect: function(element) { // Note: this call will be expensive if we modify the DOM in between calls. var clientRects = element.getClientRects(); + var clientRectsLength = clientRects.length; - for (var i = 0, len = clientRects.length; i < len; i++) { + for (var i = 0; i < clientRectsLength; i++) { // Exclude links which have just a few pixels on screen, because the link hints won't show for them // anyway. if (clientRects[i].top < 0 || clientRects[i].top >= window.innerHeight - 4 || @@ -168,6 +169,10 @@ var linkHints = { computedStyle.getPropertyValue('display') == 'none') continue; + return clientRects[i]; + } + + for (var i = 0; i < clientRectsLength; i++) { // If the link has zero dimensions, it may be wrapping visible // but floated elements. Check for this. if (clientRects[i].width == 0 || clientRects[i].height == 0) { @@ -182,8 +187,6 @@ var linkHints = { return childClientRect; } } - - return clientRects[i]; }; return null; }, -- cgit v1.2.3