MDL-63977 Behat: Fix bug in 'near' calculation
authorsam marshall <s.marshall@open.ac.uk>
Tue, 15 Jan 2019 14:31:44 +0000 (14:31 +0000)
committersam marshall <s.marshall@open.ac.uk>
Mon, 11 Feb 2019 16:20:42 +0000 (16:20 +0000)
lib/tests/behat/app_behat_runtime.js

index 354786e..b07b53e 100644 (file)
             var calculateNearDepth = function(node) {
                 var depth = 0;
                 while (node) {
-                    if (nearAncestors.indexOf(node) !== -1) {
-                        return depth;
+                    var ancestorDepth = nearAncestors.indexOf(node);
+                    if (ancestorDepth !== -1) {
+                        return depth + ancestorDepth;
                     }
                     node = node.parentNode;
                     depth++;