From aae82b5111b7e3d5a911611d1daf9c1d39c3ee0c Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Thu, 17 Sep 2009 20:15:40 -0400 Subject: [PATCH] Whitespace --- .../location_strategy_javascript/webratlink.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/webrat/selenium/location_strategy_javascript/webratlink.js b/lib/webrat/selenium/location_strategy_javascript/webratlink.js index 2a36308..b02576a 100644 --- a/lib/webrat/selenium/location_strategy_javascript/webratlink.js +++ b/lib/webrat/selenium/location_strategy_javascript/webratlink.js @@ -1,12 +1,20 @@ var links = inDocument.getElementsByTagName('a'); + var candidateLinks = $A(links).select(function(candidateLink) { - var textMatched = PatternMatcher.matches(locator, getText(candidateLink)); - var idMatched = PatternMatcher.matches(locator, candidateLink.id); - var titleMatched = PatternMatcher.matches(locator, candidateLink.title); + var textMatched = PatternMatcher.matches(locator, getText(candidateLink)); + var idMatched = PatternMatcher.matches(locator, candidateLink.id); + var titleMatched = PatternMatcher.matches(locator, candidateLink.title); + return textMatched || idMatched || titleMatched; }); + if (candidateLinks.length == 0) { return null; } -candidateLinks = candidateLinks.sortBy(function(s) { return s.length * -1; }); //reverse length sort + +//reverse length sort +candidateLinks = candidateLinks.sortBy(function(s) { + return s.length * -1; +}); + return candidateLinks.first();