Comments (9)
Please include the stack trace
from css.
Stack Trace is essentially
StringifyCSS -> Identity.compile -> Identity.stylesheet -> Base.mapVisit
does that help at all?
from css.
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.
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.
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.
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.
@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.
@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.
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)
- Hi is there any type definitions for this library ?
- " and &apos are not recognized
- undefined:2:1230: property missing ':' when using background with Data URI HOT 5
- Parsing of URL fields
- Trying to get in touch regarding a security issue HOT 4
- Declaration parsing fails with this mess of quotes, brackets & braces HOT 1
- Duplicate packages detected in the css project on Tag: v3.0.0
- Comments in a string are lost
- Mycss HOT 2
- [email protected] dependency is deprecated HOT 12
- Typescript support, performance optimization and browser friendly version (no source-map) HOT 6
- @layer is not supported with css v3 HOT 1
- Fork to continue work: https://github.com/node-projects/css-parser HOT 1
- @container support
- property missing ':' when styles have url with quotes
- Security Vulnerability report HOT 1
- Css
- Declaration matcher by regular expression is finishing too early.
- CSS
- CSS
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from css.