gradient-parser icon indicating copy to clipboard operation
gradient-parser copied to clipboard

Stringify visit access a variable that does not exist

Open jcharry opened this issue 8 years ago • 4 comments

    '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.

jcharry avatar Sep 15 '17 18:09 jcharry

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

oceangravity avatar Feb 16 '20 02:02 oceangravity

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

strarsis avatar Mar 14 '21 17:03 strarsis

@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

strarsis avatar Mar 14 '21 17:03 strarsis

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

rafaelcaricio avatar Mar 15 '21 13:03 rafaelcaricio