Giter Site home page Giter Site logo

Comments (9)

necolas avatar necolas commented on July 30, 2024

Please include the stack trace

from css.

smykes avatar smykes commented on July 30, 2024

Stack Trace is essentially
StringifyCSS -> Identity.compile -> Identity.stylesheet -> Base.mapVisit
does that help at all?

from css.

conradz avatar conradz commented on July 30, 2024

The example the you gave parses and stringifies successfully, and looking at the methods you mentioned does not turn up anything obvious. Could you post the entire stack trace including line numbers?

from css.

smykes avatar smykes commented on July 30, 2024

I just had an epiphany that I will check tomorrow morning. If I find it to be wrong I will post more information.

from css.

smykes avatar smykes commented on July 30, 2024

So it turns out it's not you it's me. The parsing is happening without a problem, but I am altering selectors between the parse and the stringify to add a prefix (foo) before each selector so #bar would turn into #foo #foobar, I have everything working but @font-face rules are tripping it up. Obviously this isn't your problem and you can close the issue, but any help would be appreciated. Code is below.

ast.stylesheet.rules.forEach(function each(rule) {
            if (rule.type === "font-face") {
                return;
            }
            if (false) {
                errors.push({
                    line: rule.declarations.line,
                    message: rule.declarations.message
                });
            } else {
                if (!rule.selectors) { //if the selectors are not on the first layer
                    if (!rule.rules) { //
                        return;
                    } else {
                        for (var i = 0; i < rule.rules.length; i++) {
                            rule.rules[i].selectors = rule.rules[i].selectors.map(function(selector) {
                                return nameSpaceCSS(selector);
                            });
                        }
                    }
                } else { //the selector is on the first layer.
                    rule.selectors = rule.selectors.map(function(selector) {
                        return nameSpaceCSS(selector);
                    });
                }
            }
        });

from css.

smykes avatar smykes commented on July 30, 2024

This is what I'm trying to stringify:

{
  "type": "stylesheet",
  "stylesheet": {
    "rules": [
      {
        "type": "font-face",
        "declarations": [
          {
            "type": "declaration",
            "property": "font-family",
            "value": "'MyFontFamily'",
            "position": {
              "start": {
                "line": 2,
                "column": 5
              },
              "end": {
                "line": 2,
                "column": 32
              }
            }
          },
          {
            "type": "declaration",
            "property": "src",
            "value": "url('myfont-webfont.eot?#iefix') format('embedded-opentype'), \n         url('myfont-webfont.woff') format('woff'), \n         url('myfont-webfont.ttf')  format('truetype'),\n         url('myfont-webfont.svg#svgFontName') format('svg')",
            "position": {
              "start": {
                "line": 3,
                "column": 5
              },
              "end": {
                "line": 6,
                "column": 61
              }
            }
          }
        ],
        "position": {
          "start": {
            "line": 1,
            "column": 1
          },
          "end": {
            "line": 7,
            "column": 6
          }
        }
      }
    ]
  }
}

from css.

conradz avatar conradz commented on July 30, 2024

@smykes not sure, the code that you have seems to work ok when I try it (although it is missing the nameSpaceCSS function; I tried an identity function). Also the JSON AST that you provided stringifies correctly. Could you make a full example (including JS and CSS) that crashes when run in node, possibly on gist.github.com?

from css.

smykes avatar smykes commented on July 30, 2024

@conradz this got taken out of r1 for me and has been pushed to r2. I have put in a workaround for my code for now, after hardening or r1 I am going to revisit it and I will get back to you.

from css.

conradz avatar conradz commented on July 30, 2024

OK, closing for now as it seems to not be a problem in css, but feel free to still provide more feedback or reopen if it does seem to be a bug in this module.

from css.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.