You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Empty "before" value when input file is UTF-8 encoded. #32
If raw and trimmed values are same (like in color: black) _value will contain only one value.
If raw and trimmed values are different (like in border-width: 1px /**/ 1px, decl.value == '1px 1px', but decl._value.raw == '1px /**/ 1px') _value will contain has with two values.
In PostCSS 0.3 I add Comment node specially for this case :).
But I plan to write postcss-control-comment library to works with this processing instructions in comments. Can you show me example of your processing instructions, because I think what API should postcss-control-comment supports.
I updated to 0.3 and changed the code to perform a check on decl._value.raw != null, but I noticed rule.before does not return the same value as in 0.2 !
If we store comment in before, then on decl.clone() we copy this comment. In most of cases it will be unexpected behavior.
In PostCSS 0.3, when we add new decl or rule node without before, PostCSS will find first same type node and copy before and other code style props from it. If we store comemnt in before it will be copy to new node.
If we store comment in before it will be very difficult to find source map annotation comment or processing instructions comment, because before can contain several comments and we will need to parse it.
I already figured that out, it just makes more sense to have comments as properties of rules, not rules of type comment!
Also you don't need all of that, each rule will contain the list of comments preceding it. and the root contains the list of comments after the last rule.
But comments can be before declarations, so we need decl.beforeComments and between last declatation and rules’s } can be comments too, so we need rule.afterComments ;).
Activity
ai commentedon Feb 26, 2014
Seems like you use outdated PostCSS. PostCSS 0.3 may fix this issue.
Please update and if issue will be on latest version, be free to reopen issue.
MohammadYounes commentedon Feb 26, 2014
Thanks for the quick response, Yes I'm using PostCSS 0.2.0
Where did
decl._value.rawgo? The change log says nothing about it being removed ? what is the alterantive ?ai commentedon Feb 26, 2014
_valueis totally internal method ;). Use only.value,.selectorand same public getters.ai commentedon Feb 26, 2014
Docs about this magic properties: https://github.com/ai/postcss#raw-properties
ai commentedon Feb 26, 2014
If raw and trimmed values are same (like in
color: black)_valuewill contain only one value.If raw and trimmed values are different (like in
border-width: 1px /**/ 1px,decl.value == '1px 1px', butdecl._value.raw == '1px /**/ 1px')_valuewill contain has with two values.MohammadYounes commentedon Feb 27, 2014
For post processing, I think raw value should be always available, even if it's equal to the trimmed value.
I'll stick to 0.2 for the time being ;)
Thanks.
ai commentedon Feb 27, 2014
Raw values is avaiable, it is just combined with trimmed :D.
Now
rawproperty is like a private method with bad API, but I can add some good API to get raw value. Why do you need raw value?MohammadYounes commentedon Feb 27, 2014
I use comments to provide processing instructions, most of them placed after the decl. value
ai commentedon Feb 27, 2014
In PostCSS 0.3 I add
Commentnode specially for this case :).But I plan to write
postcss-control-commentlibrary to works with this processing instructions in comments. Can you show me example of your processing instructions, because I think what API shouldpostcss-control-commentsupports.MohammadYounes commentedon Feb 27, 2014
I'm using something like
replace,append,prepend, for example:ai commentedon Feb 27, 2014
Hm. I think about structure instruction like:
ai commentedon Feb 27, 2014
What about this API:
MohammadYounes commentedon Feb 27, 2014
Why not keep it exposed as a property
I updated to 0.3 and changed the code to perform a check on
decl._value.raw != null, but I noticedrule.beforedoes not return the same value as in 0.2 !in your example:
What will get the value
/* autoprefixer: off */?ai commentedon Feb 27, 2014
Node can contain several raw values ;).
Yeap,
beforelogic was changed. But it was very necessary changes to allow code style copy to new nodes and to supportCommentnodes.In this example every comment will be
Commentnode. But if comment is inside value or selector, it will be in raw.7 remaining items
ai commentedon Feb 27, 2014
I open it as notice to add
rawAPI.ai commentedon Feb 27, 2014
Maybe
decl.rawValue?MohammadYounes commentedon Feb 27, 2014
Oh sorry about that ...
decl.rawValueseems great 👍In my opinion, a comment is not a rule. and I liked it better when comments were handled by
before,betweenandafterproperties.ai commentedon Feb 27, 2014
If we store comment in
before, then ondecl.clone()we copy this comment. In most of cases it will be unexpected behavior.In PostCSS 0.3, when we add new decl or rule node without
before, PostCSS will find first same type node and copybeforeand other code style props from it. If we store comemnt inbeforeit will be copy to new node.If we store comment in
beforeit will be very difficult to find source map annotation comment or processing instructions comment, becausebeforecan contain several comments and we will need to parse it.MohammadYounes commentedon Feb 27, 2014
How about moving the comments nodes inside the rule
rule.comments, and provide a flag for cloneclone(bool:include comments)?ai commentedon Feb 27, 2014
We will need
rule.beforeComments,rule.afterComments,decl.beforeComments. Traveling code will be much diffiult.Why you need comments in decl node? You can get previous comment very easy:
MohammadYounes commentedon Feb 27, 2014
I already figured that out, it just makes more sense to have comments as properties of rules, not rules of type comment!
Also you don't need all of that, each rule will contain the list of comments preceding it. and the root contains the list of comments after the last rule.
ai commentedon Feb 27, 2014
But comments can be before declarations, so we need
decl.beforeCommentsand between last declatation and rules’s}can be comments too, so we needrule.afterComments;).MohammadYounes commentedon Feb 27, 2014
For declarations use
beforeandafterai commentedon Feb 27, 2014
But what will be if rule will not have any declaration inside, only comments? ;)
MohammadYounes commentedon Feb 27, 2014
Empty declaration 😄
MohammadYounes commentedon Feb 27, 2014
Or may be provide
rule.rawValuetoo, let me know your decision, so I plan my upgrade accordingly ... either way its a pretty awesome framework 👍