ljharb/js-traverse

Does not work with builtin objects with internal slots (URL, Map, Set, etc)

Open

#10 opened on May 29, 2024

View on GitHub
 (2 comments) (0 reactions) (0 assignees)JavaScript (10 forks)github user discovery
bughelp wanted

Repository metrics

Stars
 (61 stars)
PR merge metrics
 (PR metrics pending)

Description

For instance:

    traverse({ url: new URL("https://example.com") }).map(function () {
      if (this.node instanceof URL) {
        this.update(this.node.toString());
      }
    });
TypeError: Receiver must be an instance of class URL
 ❯ Object.<anonymous> src/log-sanitizer.spec.ts:57:31
     55|     traverse({ url: new URL("https://example.com") }).map(function () {
     56|       if (this.node instanceof URL) {
     57|         this.update(this.node.toString());
       |                               ^
     58|       }
     59|     });
 ❯ walker node_modules/traverse/index.js:169:16
 ❯ node_modules/traverse/index.js:190:17
 ❯ forEach node_modules/traverse/index.js:19:30
 ❯ walker node_modules/traverse/index.js:185:4
 ❯ walk node_modules/traverse/index.js:208:3
 ❯ Traverse.map node_modules/traverse/index.js:251:9

Contributor guide