[Pkg-javascript-commits] [node-acorn-jsx] 99/484: [walker] Fix broken handling of node predicates

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:10 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-acorn-jsx.

commit adcb3544989656d09e46559ed2df4186418497f2
Author: Marijn Haverbeke <marijnh at gmail.com>
Date:   Thu Feb 14 14:02:48 2013 +0100

    [walker] Fix broken handling of node predicates
---
 util/walk.js | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/util/walk.js b/util/walk.js
index f75aa1a..cfa7eb0 100644
--- a/util/walk.js
+++ b/util/walk.js
@@ -43,7 +43,7 @@
 
   function makeTest(test) {
     if (typeof test == "string")
-      return function(node) { node.type == test; };
+      return function(type) { return type == test; };
     else if (!test)
       return function() { return true; };
     else
@@ -64,7 +64,7 @@
         if ((start == null || node.start <= start) &&
             (end == null || node.end >= end))
           base[type](node, st, c);
-        if (test(node) &&
+        if (test(type, node) &&
             (start == null || node.start == start) &&
             (end == null || node.end == end))
           throw new Found(node, st);
@@ -84,11 +84,9 @@
       if (!base) base = exports.base;
       var c = function(node, st, override) {
         var type = override || node.type;
-        var inside = node.start <= pos && node.end >= pos;
-        if (inside)
-          base[type](node, st, c);
-        if (inside && test(node))
-          throw new Found(node, st);
+        if (node.start > pos || node.end < pos) return;
+        base[type](node, st, c);
+        if (test(type, node)) throw new Found(node, st);
       };
       c(node, state);
     } catch (e) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-acorn-jsx.git



More information about the Pkg-javascript-commits mailing list