Stringify visit access a variable that does not exist #9

Open
opened 2017-09-15 18:35:51 +00:00 by jcharry · 4 comments
jcharry commented 2017-09-15 18:35:51 +00:00 (Migrated from github.com)
    'visit': function(element) {
      if (!element) {
        return '';
      }

      if (element instanceof Array) {
        return visitor.visit_array(element, result);
      } else if (element.type) {
        var nodeVisitor = visitor['visit_' + element.type];
        if (nodeVisitor) {
          return nodeVisitor(element);
        } else {
          throw Error('Missing visitor visit_' + element.type);
        }
      } else {
        throw Error('Invalid node.');
      }
    }

in the call to visitor.visit_array, result is not defined, throwing an error.

``` 'visit': function(element) { if (!element) { return ''; } if (element instanceof Array) { return visitor.visit_array(element, result); } else if (element.type) { var nodeVisitor = visitor['visit_' + element.type]; if (nodeVisitor) { return nodeVisitor(element); } else { throw Error('Missing visitor visit_' + element.type); } } else { throw Error('Invalid node.'); } } ``` in the call to `visitor.visit_array`, `result` is not defined, throwing an error.
oceangravity commented 2020-02-16 02:23:59 +00:00 (Migrated from github.com)

Hi @jcharry I just published a npm package to parse CSS gradients https://npmjs.com/package/webskit-gradient-parser please let me know if is helpful for you, thank you!
#javascript #css #gradients #npm #webskit

Hi @jcharry I just published a npm package to parse CSS gradients https://npmjs.com/package/webskit-gradient-parser please let me know if is helpful for you, thank you! #javascript #css #gradients #npm #webskit
strarsis commented 2021-03-14 17:49:25 +00:00 (Migrated from github.com)

@oceangravity: Nice! But the stringify feature is missing, which is very important for manipulating a gradient via its AST.

@oceangravity: Nice! But the stringify feature is missing, which is very important for manipulating a gradient via its AST.
strarsis commented 2021-03-14 17:50:00 +00:00 (Migrated from github.com)

@rafaelcaricio: Any chances this could be addressed in the near future? Currently stringifying is not possible.
There is a fork with a fix for the issue: https://github.com/pixelspark/gradient-parser

@rafaelcaricio: Any chances this could be addressed in the near future? Currently stringifying is not possible. There is a fork with a fix for the issue: https://github.com/pixelspark/gradient-parser
rafaelcaricio commented 2021-03-15 13:56:35 +00:00 (Migrated from github.com)

@strarsis this should be fixed now in version 1.0.2. Could you check if that works now?

@strarsis this should be fixed now in version `1.0.2`. Could you check if that works now?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: rafaelcaricio/gradient-parser#9
No description provided.