Why is Sass striping semicolons?

北战南征 提交于 2020-01-07 04:51:32

问题


I'm using Compass to compile a Sass Zen theme. I got this warning:

 Compass has changed how browser support is configured. The following configuration         variables are no longer supported: $legacy-support-for-ie6, $legacy-support-for-ie7, $legacy-support-for-ie8

I installed older versions of

compass (0.12.7)
sass (3.2.19)
breakpoint (1.3)

I'm no longer getting the warning, however, I'm losing semicolons in the compiled code. Example:

/* Address paddings set differently in IE 6/7. */
menu,
ol,
ul {
padding: 0 0 0 $indent-amount; /* LTR */
}

@if $legacy-support-for-ie7 {
/* Correct list images handled incorrectly in IE 7. */
nav ul,
nav ol {
list-style: none;
list-style-image: none;
} 

Compiles to

menu,
ol,
ul {
padding: 0 0 0 30px 
/* LTR */
}

Notice the missing semicolon. It seems like everywhere there's an @if $legacy-support-for-ie compass then strips the preceding semicolon. There are 51 declarations of @if $legacy-support-for-ie in my files, I'd rather just leave them if possible.


回答1:


I've had issues with using the latest version of compass when a site was setup to use the pre 1.0 release of compass. Try using Compass 0.12.7 and then rebuilding your dependencies from there. https://rubygems.org/gems/compass/versions/0.12.7




回答2:


The $legacy-support-for-ie has nothing to do with the very last semicolon being dropped. That's a particular of Compass.

Sass does not care how your code is formatted as long as it is valid. When the CSS is generated, it follows the style rules dictated by the chosen output style for things like whitespace, indentation, punctuation, etc. You can only specify a different output style, not change the particulars of any given style.

Note that omitting the final semicolon is completely valid according to CSS.



来源:https://stackoverflow.com/questions/27273988/why-is-sass-striping-semicolons

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!