红联Linux门户
Linux帮助

Sass 3.3.0发布,CSS预处理器

发布时间:2014-03-09 09:17:13来源:红联作者:empast
Sass 3.3.0 发布,于此同时还发布了 Sass 3.2.15 版本:当父选择器换行符后面跟着逗号时,支持 &.foo 。

Sass 3.3.0 变得更加灵活,值得注意的更新内容如下:

SassScript Maps

Source Maps

关键字变量参数

弃用:Variable Scope 和 !global

其他小改进:

The parent selector, &, can be used with an identifier suffix. For example, &-suffix and &_suffix are now legal. The suffix will be added to the end of the parent selector, and will throw an error if this isn’t possible. & must still appear at the beginning of a compound selector - that is, .foo-& is still illegal.

listen is no longer bundled with Sass, nor is it a standard RubyGems dependency. Instead, it’s automatically installed along with Sass in order to ensure that the user ends up with a version of Listen that works with their local Ruby version.

Sass now has numerous functions for working with strings: str-length will return the length of a string; str-insert will insert one string into another; str-index will return the index of a substring within another string; str-slice will slice a substring from a string; to-upper-case will transform a string to upper case characters; and to-lower-case will transform a string to lower case characters.

A list-separator function has been added to determine what separator a list uses. Thanks to Sam Richard.

Custom Ruby functions can now access the global environment, which allows them the same power as Sass-based functions with respect to reading and setting variables defined elsewhere in the stylesheet.

The set-nth($list, $n, $value) function lets you construct a new list based on $list, with the nth element changed to the value specified.

In order to make it easier for mixins to process maps, they may now recursively call themselves and one another. It is no longer an error to have a mixin @include loop.

Add “grey” and “transparent” as recognized SassScript colors. Thanks to Rob Wierzbowski.

Add a function unique-id() that will return a CSS identifier that is unique within the scope of a single CSS file.

Allow negative indices into lists when using nth().

You can now detect the presence of a Sass feature using the new function feature-exists($feature-name). There are no detectable features in this release, this is provided so that subsequent releases can begin to use it. Additionally, plugins can now expose their functionality through feature-exists by calling Sass.add_feature(feature_name). Features exposed by plugins must begin with a dash to distinguish them from official features.

It is now possible to determine the existence of different Sass constructs using these new functions:

variable-exists($name) checks if a variable resolves in the current scope.

global-variable-exists($name) checks if a global variable of the given name exists.

function-exists($name) checks if a function exists.

mixin-exists($name) checks if a mixin exists.

You can call a function by name by passing the function name to the call function. For example, call(nth, a b c, 2) returns b.

Comments following selectors in the indented syntax will be correctly converted using sass-convert.

@each now supports “multiple assignment”, which makes it easier to iterate over lists of lists. If you write @each $var1, $var2, $var3 in a b c, d e f, g h i, the elements of the sub-lists will be assigned individually to the variables. $var1, $var2, and $var3 will be a, b and c; then d, e, and f; and then g, h, and i. For more information, see the @each reference.

@for loops can now go downward as well as upward. For example, @for $var from 5 through 1 will set $var to 5, 4, 3, 2, and 1. Thanks to Robin Roestenburg.

There is a new convenience API for creating Sass values from within ruby extensions.

The if() function now only evaluates the argument corresponding to the value of the first argument.

Comma-separated lists may now have trailing commas (e.g. 1, 2, 3,). This also allows you to use a trailing comma to distinguish a list with a single element from that element itself - for example, (1,) is explicitly a list containing the value 1.

All directives that are nested in CSS rules or properties and that contain more CSS rules or properties are now bubbled up through their parent rules.

A new random() function returns a random number.

A new function inspect($value) is provided for debugging the current sass representation of a value.

The @debug directive now automatically inspects sass objects that are not strings.

Numbers will no longer be emitted in scientific notation.

sass-convert will now correctly handle silent (//-style) comments contained within loud (/* */-style) comments.

Allow modulo arithmetic for numbers with compatible units. Thanks to Isaac Devine.

Keyword arguments to mixins and functions that contain hyphens will have the hyphens preserved when using sass-convert.

先后不兼容----必读
Sass will now throw an error when @extend is used to extend a selector outside the @media context of the extending selector. This means the following will be an error:

@media screen {
.foo { @extend .bar; }
}
.bar { color: blue; }Sass will now throw an error when an @extend that has no effect is used. The !optional flag may be used to avoid this behavior for a single @extend.

Sass will now throw an error when it encounters a single @import statement that tries to import more than one file. For example, if you have @import "screen" and both screen.scss and _screen.scss exist, a warning will be printed.

grey and transparent are no longer interpreted as strings; they’re now interpreted as colors, as per the CSS spec.

The automatic placement of the current working directory onto the Sass load path is now deprecated as this causes unpredictable build processes. If you need the current working directory to be available, set SASS_PATH=. in your shell’s environment.

Sass::Compiler.on_updating_stylesheet has been removed.

Sass::Plugin.options= has been removed.

Sass::Script::Number::PRECISION has been removed.

The methods in the Sass::Util module can no longer be used by including it. They must be invoked on the module itself for performance reasons.

Sass values have always been immutable. The ruby object that backs each sass value is now “frozen” to prevent accidental modification and for performance.

Many classes in the Sass::Script have been rearranged. All the value classes have been moved into Sass::Script::Value (e.g. Sass::Script::Value::Color, Sass::Script::Value::String, etc). Their base class is now Sass::Script::Value::Base instead of Sass::Script::Literal. All the parse tree classes have been moved into Sass::Script::Tree (e.g. Sass::Script::Tree::Node, Sass::Script::Tree::Operation, etc).
The old names will continue to work for the next couple releases, but they will be removed eventually. Any code using them should upgrade to the new names.

As part of a migration to cleaner variable semantics, assigning to global variables in a local context by default is deprecated. If there’s a global variable named $color and you write $color: blue within a CSS rule, Sass will now print a warning; in the future, it will create a new local variable named $color. You may now explicitly assign to global variables using the !global flag; for example, $color: blue !global will always assign to the global $color variable.

Two numbers separated by a hyphen with no whitespace will now be parsed as a subtraction operation rather than two numbers in a list. That is, 2px-1px will parse the same as 2px - 1px rather than 2px -1px.

index()’s false return value when a value isn’t found is deprecated. In future Sass releases it will be null instead, so it should be used in ways that are compatible with both false and null.

mix()’s arguments are now $color1 and $color2 rather than $color-1 and $color-2, in keeping with other functions.

comparable()’s arguments are now $number1 and $number2 rather than $number-1 and $number-2, in keeping with other functions.

percentage(), round(), ceil(), floor(), and abs() now take arguments named ‘$number’ instead of ‘$value’.

Sass 扩展了 CSS3,增加了规则、变量、混入、选择器、继承等等特性。Sass 生成良好格式化的 CSS 代码,易于组织和维护。

项目主页:http://sass-lang.com/documentation/file.SASS_CHANGELOG.html

下载地址:https://github.com/nex3/sass

来自:oschina开源中国社区
文章评论

共有 0 条评论