sass 3.5.0.pre.rc.1 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +1 -1
- data/README.md +1 -1
- data/Rakefile +40 -11
- data/VERSION +1 -1
- data/VERSION_DATE +1 -1
- data/extra/sass-spec-ref.sh +32 -0
- data/lib/sass.rb +3 -3
- data/lib/sass/css.rb +1 -1
- data/lib/sass/deprecation.rb +55 -0
- data/lib/sass/engine.rb +16 -12
- data/lib/sass/environment.rb +1 -1
- data/lib/sass/error.rb +3 -3
- data/lib/sass/exec/base.rb +1 -1
- data/lib/sass/plugin.rb +1 -1
- data/lib/sass/plugin/compiler.rb +1 -1
- data/lib/sass/plugin/configuration.rb +2 -2
- data/lib/sass/plugin/rack.rb +3 -3
- data/lib/sass/plugin/staleness_checker.rb +3 -3
- data/lib/sass/script.rb +3 -3
- data/lib/sass/script/functions.rb +23 -22
- data/lib/sass/script/lexer.rb +17 -8
- data/lib/sass/script/parser.rb +8 -7
- data/lib/sass/script/tree/node.rb +2 -2
- data/lib/sass/script/tree/operation.rb +43 -16
- data/lib/sass/script/value/base.rb +3 -3
- data/lib/sass/script/value/color.rb +15 -10
- data/lib/sass/script/value/helpers.rb +13 -2
- data/lib/sass/script/value/list.rb +2 -2
- data/lib/sass/script/value/number.rb +4 -4
- data/lib/sass/script/value/string.rb +5 -12
- data/lib/sass/scss/parser.rb +7 -4
- data/lib/sass/scss/rx.rb +1 -1
- data/lib/sass/scss/static_parser.rb +12 -24
- data/lib/sass/selector/abstract_sequence.rb +12 -11
- data/lib/sass/selector/comma_sequence.rb +18 -3
- data/lib/sass/selector/pseudo.rb +15 -2
- data/lib/sass/selector/sequence.rb +9 -7
- data/lib/sass/selector/simple.rb +5 -4
- data/lib/sass/selector/simple_sequence.rb +7 -3
- data/lib/sass/shared.rb +5 -3
- data/lib/sass/source/map.rb +2 -2
- data/lib/sass/source/position.rb +4 -4
- data/lib/sass/tree/comment_node.rb +1 -1
- data/lib/sass/tree/node.rb +3 -3
- data/lib/sass/tree/prop_node.rb +1 -1
- data/lib/sass/tree/rule_node.rb +15 -6
- data/lib/sass/tree/visitors/cssize.rb +3 -5
- data/lib/sass/tree/visitors/deep_copy.rb +1 -1
- data/lib/sass/tree/visitors/extend.rb +2 -8
- data/lib/sass/tree/visitors/perform.rb +3 -2
- data/lib/sass/tree/visitors/to_css.rb +3 -3
- data/lib/sass/util.rb +32 -5
- data/lib/sass/version.rb +2 -4
- data/test/sass/cache_test.rb +0 -1
- data/test/sass/callbacks_test.rb +0 -1
- data/test/sass/compiler_test.rb +0 -1
- data/test/sass/conversion_test.rb +3 -4
- data/test/sass/css2sass_test.rb +1 -2
- data/test/sass/css_variable_test.rb +0 -1
- data/test/sass/encoding_test.rb +0 -1
- data/test/sass/engine_test.rb +63 -60
- data/test/sass/exec_test.rb +0 -1
- data/test/sass/extend_test.rb +40 -81
- data/test/sass/functions_test.rb +8 -6
- data/test/sass/importer_test.rb +0 -1
- data/test/sass/logger_test.rb +0 -1
- data/test/sass/more_templates/more1.sass +10 -10
- data/test/sass/more_templates/more_import.sass +2 -2
- data/test/sass/plugin_test.rb +3 -4
- data/test/sass/results/script.css +1 -1
- data/test/sass/results/units.css +2 -2
- data/test/sass/script_conversion_test.rb +1 -2
- data/test/sass/script_test.rb +55 -47
- data/test/sass/scss/css_test.rb +2 -3
- data/test/sass/scss/rx_test.rb +0 -1
- data/test/sass/scss/scss_test.rb +26 -12
- data/test/sass/source_map_test.rb +13 -14
- data/test/sass/superselector_test.rb +0 -1
- data/test/sass/templates/_partial.sass +1 -1
- data/test/sass/templates/basic.sass +10 -10
- data/test/sass/templates/bork1.sass +1 -1
- data/test/sass/templates/bork5.sass +1 -1
- data/test/sass/templates/compact.sass +10 -10
- data/test/sass/templates/complex.sass +187 -187
- data/test/sass/templates/compressed.sass +10 -10
- data/test/sass/templates/expanded.sass +10 -10
- data/test/sass/templates/import.sass +2 -2
- data/test/sass/templates/importee.sass +3 -3
- data/test/sass/templates/mixins.sass +22 -22
- data/test/sass/templates/multiline.sass +4 -4
- data/test/sass/templates/nested.sass +13 -13
- data/test/sass/templates/parent_ref.sass +12 -12
- data/test/sass/templates/script.sass +70 -70
- data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +1 -1
- data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +2 -2
- data/test/sass/templates/subdir/subdir.sass +3 -3
- data/test/sass/templates/units.sass +10 -10
- data/test/sass/util/multibyte_string_scanner_test.rb +10 -3
- data/test/sass/util/normalized_map_test.rb +0 -1
- data/test/sass/util/subset_map_test.rb +0 -1
- data/test/sass/util_test.rb +4 -3
- data/test/sass/value_helpers_test.rb +0 -1
- metadata +15 -13
data/lib/sass/script.rb
CHANGED
@@ -16,12 +16,12 @@ module Sass
|
|
16
16
|
# Parses a string of SassScript
|
17
17
|
#
|
18
18
|
# @param value [String] The SassScript
|
19
|
-
# @param line [
|
19
|
+
# @param line [Integer] The number of the line on which the SassScript appeared.
|
20
20
|
# Used for error reporting
|
21
|
-
# @param offset [
|
21
|
+
# @param offset [Integer] The number of characters in on `line` that the SassScript started.
|
22
22
|
# Used for error reporting
|
23
23
|
# @param options [{Symbol => Object}] An options hash;
|
24
|
-
# see {file:SASS_REFERENCE.md#
|
24
|
+
# see {file:SASS_REFERENCE.md#Options the Sass options documentation}
|
25
25
|
# @return [Script::Tree::Node] The root node of the parse tree
|
26
26
|
def self.parse(value, line, offset, options = {})
|
27
27
|
Parser.parse(value, line, offset, options)
|
@@ -300,7 +300,7 @@ module Sass::Script
|
|
300
300
|
# \{#call call($function, $args...)}
|
301
301
|
# : Dynamically calls a Sass function reference returned by `get-function`.
|
302
302
|
#
|
303
|
-
# \{#get_function get-function($name)}
|
303
|
+
# \{#get_function get-function($name, $css: false)}
|
304
304
|
# : Looks up a function with the given name in the current lexical scope
|
305
305
|
# and returns a reference to it.
|
306
306
|
#
|
@@ -441,8 +441,8 @@ module Sass::Script
|
|
441
441
|
# If no signatures match, the first signature is returned for error messaging.
|
442
442
|
#
|
443
443
|
# @param method_name [Symbol] The name of the Ruby function to be called.
|
444
|
-
# @param arg_arity [
|
445
|
-
# @param kwarg_arity [
|
444
|
+
# @param arg_arity [Integer] The number of unnamed arguments the function was passed.
|
445
|
+
# @param kwarg_arity [Integer] The number of keyword arguments the function was passed.
|
446
446
|
#
|
447
447
|
# @return [{Symbol => Object}, nil]
|
448
448
|
# The signature options for the matching signature,
|
@@ -654,7 +654,7 @@ module Sass::Script
|
|
654
654
|
# @return [Sass::Script::Value::Color]
|
655
655
|
# @raise [ArgumentError] if any parameter is the wrong type or out of bounds
|
656
656
|
def rgb(red, green, blue)
|
657
|
-
if
|
657
|
+
if special_number?(red) || special_number?(green) || special_number?(blue)
|
658
658
|
return unquoted_string("rgb(#{red}, #{green}, #{blue})")
|
659
659
|
end
|
660
660
|
assert_type red, :Number, :red
|
@@ -715,7 +715,7 @@ module Sass::Script
|
|
715
715
|
color, alpha = args
|
716
716
|
|
717
717
|
assert_type color, :Color, :color
|
718
|
-
if
|
718
|
+
if special_number?(alpha)
|
719
719
|
unquoted_string("rgba(#{color.red}, #{color.green}, #{color.blue}, #{alpha})")
|
720
720
|
else
|
721
721
|
assert_type alpha, :Number, :alpha
|
@@ -724,7 +724,8 @@ module Sass::Script
|
|
724
724
|
end
|
725
725
|
when 4
|
726
726
|
red, green, blue, alpha = args
|
727
|
-
if
|
727
|
+
if special_number?(red) || special_number?(green) ||
|
728
|
+
special_number?(blue) || special_number?(alpha)
|
728
729
|
unquoted_string("rgba(#{red}, #{green}, #{blue}, #{alpha})")
|
729
730
|
else
|
730
731
|
rgba(rgb(red, green, blue), alpha)
|
@@ -753,7 +754,7 @@ module Sass::Script
|
|
753
754
|
# @raise [ArgumentError] if `$saturation` or `$lightness` are out of bounds
|
754
755
|
# or any parameter is the wrong type
|
755
756
|
def hsl(hue, saturation, lightness)
|
756
|
-
if
|
757
|
+
if special_number?(hue) || special_number?(saturation) || special_number?(lightness)
|
757
758
|
unquoted_string("hsl(#{hue}, #{saturation}, #{lightness})")
|
758
759
|
else
|
759
760
|
hsla(hue, saturation, lightness, number(1))
|
@@ -781,7 +782,8 @@ module Sass::Script
|
|
781
782
|
# @raise [ArgumentError] if `$saturation`, `$lightness`, or `$alpha` are out
|
782
783
|
# of bounds or any parameter is the wrong type
|
783
784
|
def hsla(hue, saturation, lightness, alpha)
|
784
|
-
if
|
785
|
+
if special_number?(hue) || special_number?(saturation) ||
|
786
|
+
special_number?(lightness) || special_number?(alpha)
|
785
787
|
return unquoted_string("hsla(#{hue}, #{saturation}, #{lightness}, #{alpha})")
|
786
788
|
end
|
787
789
|
assert_type hue, :Number, :hue
|
@@ -1324,7 +1326,7 @@ module Sass::Script
|
|
1324
1326
|
# @param $color1 [Sass::Script::Value::Color]
|
1325
1327
|
# @param $color2 [Sass::Script::Value::Color]
|
1326
1328
|
# @param $weight [Sass::Script::Value::Number] The relative weight of each
|
1327
|
-
# color. Closer to `
|
1329
|
+
# color. Closer to `100%` gives more weight to `$color1`, closer to `0%`
|
1328
1330
|
# gives more weight to `$color2`
|
1329
1331
|
# @return [Sass::Script::Value::Color]
|
1330
1332
|
# @raise [ArgumentError] if `$weight` is out of bounds or any parameter is
|
@@ -1573,7 +1575,7 @@ MESSAGE
|
|
1573
1575
|
# @param $start-at [Sass::Script::Value::Number] The index of the first
|
1574
1576
|
# character of the substring. If this is negative, it counts from the end
|
1575
1577
|
# of `$string`
|
1576
|
-
# @param $end-
|
1578
|
+
# @param $end-at [Sass::Script::Value::Number] The index of the last
|
1577
1579
|
# character of the substring. If this is negative, it counts from the end
|
1578
1580
|
# of `$string`. Defaults to -1
|
1579
1581
|
# @return [Sass::Script::Value::String] The substring. This will be quoted
|
@@ -1592,7 +1594,7 @@ MESSAGE
|
|
1592
1594
|
s = string.value.length + s if s < 0
|
1593
1595
|
s = 0 if s < 0
|
1594
1596
|
e = string.value.length + e if e < 0
|
1595
|
-
|
1597
|
+
return Sass::Script::Value::String.new("", string.type) if e < 0
|
1596
1598
|
extracted = string.value.slice(s..e)
|
1597
1599
|
Sass::Script::Value::String.new(extracted || "", string.type)
|
1598
1600
|
end
|
@@ -1610,7 +1612,7 @@ MESSAGE
|
|
1610
1612
|
# @raise [ArgumentError] if `$string` isn't a string
|
1611
1613
|
def to_upper_case(string)
|
1612
1614
|
assert_type string, :String, :string
|
1613
|
-
Sass::Script::Value::String.new(string.value
|
1615
|
+
Sass::Script::Value::String.new(Sass::Util.upcase(string.value), string.type)
|
1614
1616
|
end
|
1615
1617
|
declare :to_upper_case, [:string]
|
1616
1618
|
|
@@ -1625,7 +1627,7 @@ MESSAGE
|
|
1625
1627
|
# @raise [ArgumentError] if `$string` isn't a string
|
1626
1628
|
def to_lower_case(string)
|
1627
1629
|
assert_type string, :String, :string
|
1628
|
-
Sass::Script::Value::String.new(string.value
|
1630
|
+
Sass::Script::Value::String.new(Sass::Util.downcase(string.value), string.type)
|
1629
1631
|
end
|
1630
1632
|
declare :to_lower_case, [:string]
|
1631
1633
|
|
@@ -1690,13 +1692,11 @@ MESSAGE
|
|
1690
1692
|
end
|
1691
1693
|
declare :feature_exists, [:feature]
|
1692
1694
|
|
1693
|
-
# Returns a reference to a function for later invocation with the `call` function.
|
1695
|
+
# Returns a reference to a function for later invocation with the `call()` function.
|
1694
1696
|
#
|
1695
|
-
#
|
1696
|
-
# your stylesheet
|
1697
|
-
#
|
1698
|
-
# you can use `function-exists()` to check if the function reference
|
1699
|
-
# created points at a Sass function.
|
1697
|
+
# If `$css` is `false`, the function reference may refer to a function
|
1698
|
+
# defined in your stylesheet or built-in to the host environment. If it's
|
1699
|
+
# `true` it will refer to a plain-CSS function.
|
1700
1700
|
#
|
1701
1701
|
# @example
|
1702
1702
|
# get-function("rgb")
|
@@ -1704,8 +1704,9 @@ MESSAGE
|
|
1704
1704
|
# @function myfunc { @return "something"; }
|
1705
1705
|
# get-function("myfunc")
|
1706
1706
|
#
|
1707
|
-
# @overload get_function($name)
|
1707
|
+
# @overload get_function($name, $css: false)
|
1708
1708
|
# @param name [Sass::Script::Value::String] The name of the function being referenced.
|
1709
|
+
# @param css [Sass::Script::Value::Bool] Whether to get a plain CSS function.
|
1709
1710
|
#
|
1710
1711
|
# @return [Sass::Script::Value::Function] A function reference.
|
1711
1712
|
def get_function(name, kwargs = {})
|
@@ -2701,7 +2702,7 @@ WARNING
|
|
2701
2702
|
|
2702
2703
|
extends = Sass::Util::SubsetMap.new
|
2703
2704
|
begin
|
2704
|
-
extender.populate_extends(extends, extendee)
|
2705
|
+
extender.populate_extends(extends, extendee, nil, [], true)
|
2705
2706
|
selector.do_extend(extends).to_sass_script
|
2706
2707
|
rescue Sass::SyntaxError => e
|
2707
2708
|
raise ArgumentError.new(e.to_s)
|
@@ -2744,7 +2745,7 @@ WARNING
|
|
2744
2745
|
|
2745
2746
|
extends = Sass::Util::SubsetMap.new
|
2746
2747
|
begin
|
2747
|
-
replacement.populate_extends(extends, original)
|
2748
|
+
replacement.populate_extends(extends, original, nil, [], true)
|
2748
2749
|
selector.do_extend(extends, [], true).to_sass_script
|
2749
2750
|
rescue Sass::SyntaxError => e
|
2750
2751
|
raise ArgumentError.new(e.to_s)
|
data/lib/sass/script/lexer.rb
CHANGED
@@ -19,13 +19,13 @@ module Sass
|
|
19
19
|
# `source_range`: \[`Sass::Source::Range`\]
|
20
20
|
# : The range in the source file in which the token appeared.
|
21
21
|
#
|
22
|
-
# `pos`: \[`
|
22
|
+
# `pos`: \[`Integer`\]
|
23
23
|
# : The scanner position at which the SassScript token appeared.
|
24
24
|
Token = Struct.new(:type, :value, :source_range, :pos)
|
25
25
|
|
26
26
|
# The line number of the lexer's current position.
|
27
27
|
#
|
28
|
-
# @return [
|
28
|
+
# @return [Integer]
|
29
29
|
def line
|
30
30
|
return @line unless @tok
|
31
31
|
@tok.source_range.start_pos.line
|
@@ -34,7 +34,7 @@ module Sass
|
|
34
34
|
# The number of bytes into the current line
|
35
35
|
# of the lexer's current position (1-based).
|
36
36
|
#
|
37
|
-
# @return [
|
37
|
+
# @return [Integer]
|
38
38
|
def offset
|
39
39
|
return @offset unless @tok
|
40
40
|
@tok.source_range.start_pos.offset
|
@@ -144,12 +144,12 @@ module Sass
|
|
144
144
|
}
|
145
145
|
|
146
146
|
# @param str [String, StringScanner] The source text to lex
|
147
|
-
# @param line [
|
147
|
+
# @param line [Integer] The 1-based line on which the SassScript appears.
|
148
148
|
# Used for error reporting and sourcemap building
|
149
|
-
# @param offset [
|
149
|
+
# @param offset [Integer] The 1-based character (not byte) offset in the line in the source.
|
150
150
|
# Used for error reporting and sourcemap building
|
151
151
|
# @param options [{Symbol => Object}] An options hash;
|
152
|
-
# see {file:SASS_REFERENCE.md#
|
152
|
+
# see {file:SASS_REFERENCE.md#Options the Sass options documentation}
|
153
153
|
def initialize(str, line, offset, options)
|
154
154
|
@scanner = str.is_a?(StringScanner) ? str : Sass::Util::MultibyteStringScanner.new(str)
|
155
155
|
@line = line
|
@@ -368,8 +368,17 @@ MESSAGE
|
|
368
368
|
# IDs in properties are used in the Basic User Interface Module
|
369
369
|
# (http://www.w3.org/TR/css3-ui/).
|
370
370
|
return unless scan(REGULAR_EXPRESSIONS[:id])
|
371
|
-
if @scanner[0] =~ /^\#[0-9a-fA-F]+$/
|
372
|
-
|
371
|
+
if @scanner[0] =~ /^\#[0-9a-fA-F]+$/
|
372
|
+
if @scanner[0].length == 4 || @scanner[0].length == 7
|
373
|
+
return [:color, Script::Value::Color.from_hex(@scanner[0])]
|
374
|
+
elsif @scanner[0].length == 5 || @scanner[0].length == 9
|
375
|
+
filename = @options[:filename]
|
376
|
+
Sass::Util.sass_warn <<MESSAGE
|
377
|
+
DEPRECATION WARNING on line #{line}, column #{offset}#{" of #{filename}" if filename}:
|
378
|
+
The value "#{@scanner[0]}" is currently parsed as a string, but it will be parsed as a color in
|
379
|
+
future versions of Sass. Use "unquote('#{@scanner[0]}')" to continue parsing it as a string.
|
380
|
+
MESSAGE
|
381
|
+
end
|
373
382
|
end
|
374
383
|
[:ident, @scanner[0]]
|
375
384
|
end
|
data/lib/sass/script/parser.rb
CHANGED
@@ -7,25 +7,25 @@ module Sass
|
|
7
7
|
class Parser
|
8
8
|
# The line number of the parser's current position.
|
9
9
|
#
|
10
|
-
# @return [
|
10
|
+
# @return [Integer]
|
11
11
|
def line
|
12
12
|
@lexer.line
|
13
13
|
end
|
14
14
|
|
15
15
|
# The column number of the parser's current position.
|
16
16
|
#
|
17
|
-
# @return [
|
17
|
+
# @return [Integer]
|
18
18
|
def offset
|
19
19
|
@lexer.offset
|
20
20
|
end
|
21
21
|
|
22
22
|
# @param str [String, StringScanner] The source text to parse
|
23
|
-
# @param line [
|
23
|
+
# @param line [Integer] The line on which the SassScript appears.
|
24
24
|
# Used for error reporting and sourcemap building
|
25
|
-
# @param offset [
|
25
|
+
# @param offset [Integer] The character (not byte) offset where the script starts in the line.
|
26
26
|
# Used for error reporting and sourcemap building
|
27
27
|
# @param options [{Symbol => Object}] An options hash; see
|
28
|
-
# {file:SASS_REFERENCE.md#
|
28
|
+
# {file:SASS_REFERENCE.md#Options the Sass options documentation}.
|
29
29
|
# This supports an additional `:allow_extra_text` option that controls
|
30
30
|
# whether the parser throws an error when extra text is encountered
|
31
31
|
# after the parsed construct.
|
@@ -820,8 +820,9 @@ RUBY
|
|
820
820
|
location = "on line #{interpolation.line}"
|
821
821
|
location << " of #{interpolation.filename}" if interpolation.filename
|
822
822
|
Sass::Util.sass_warn <<WARNING
|
823
|
-
DEPRECATION WARNING #{location}:
|
824
|
-
in a future version of Sass.
|
823
|
+
DEPRECATION WARNING #{location}:
|
824
|
+
\#{} interpolation near operators will be simplified in a future version of Sass.
|
825
|
+
To preserve the current behavior, use quotes:
|
825
826
|
|
826
827
|
#{interpolation.to_quoted_equivalent.to_sass}
|
827
828
|
|
@@ -10,7 +10,7 @@ module Sass::Script::Tree
|
|
10
10
|
|
11
11
|
# The line of the document on which this node appeared.
|
12
12
|
#
|
13
|
-
# @return [
|
13
|
+
# @return [Integer]
|
14
14
|
attr_accessor :line
|
15
15
|
|
16
16
|
# The source range in the document on which this node appeared.
|
@@ -25,7 +25,7 @@ module Sass::Script::Tree
|
|
25
25
|
|
26
26
|
# Sets the options hash for this node,
|
27
27
|
# as well as for all child nodes.
|
28
|
-
# See {file:SASS_REFERENCE.md#
|
28
|
+
# See {file:SASS_REFERENCE.md#Options the Sass options documentation}.
|
29
29
|
#
|
30
30
|
# @param options [{Symbol => Object}] The options
|
31
31
|
def options=(options)
|
@@ -2,6 +2,9 @@ module Sass::Script::Tree
|
|
2
2
|
# A SassScript parse node representing a binary operation,
|
3
3
|
# such as `$a + $b` or `"foo" + 1`.
|
4
4
|
class Operation < Node
|
5
|
+
@@color_arithmetic_deprecation = Sass::Deprecation.new
|
6
|
+
@@unitless_equals_deprecation = Sass::Deprecation.new
|
7
|
+
|
5
8
|
attr_reader :operand1
|
6
9
|
attr_reader :operand2
|
7
10
|
attr_reader :operator
|
@@ -85,28 +88,52 @@ module Sass::Script::Tree
|
|
85
88
|
raise Sass::SyntaxError.new("Undefined operation: \"#{value1} #{@operator} #{value2}\".")
|
86
89
|
end
|
87
90
|
|
88
|
-
|
89
|
-
|
90
|
-
result == (if @operator == :eq
|
91
|
-
Sass::Script::Value::Bool::TRUE
|
92
|
-
else
|
93
|
-
Sass::Script::Value::Bool::FALSE
|
94
|
-
end)
|
95
|
-
|
96
|
-
operation = "#{value1.to_sass} #{@operator == :eq ? '==' : '!='} #{value2.to_sass}"
|
97
|
-
future_value = @operator == :neq
|
98
|
-
Sass::Util.sass_warn <<WARNING
|
99
|
-
DEPRECATION WARNING on line #{line}#{" of #{filename}" if filename}:
|
100
|
-
The result of `#{operation}` will be `#{future_value}` in future releases of Sass.
|
101
|
-
Unitless numbers will no longer be equal to the same numbers with units.
|
102
|
-
WARNING
|
103
|
-
end
|
91
|
+
warn_for_color_arithmetic(value1, value2)
|
92
|
+
warn_for_unitless_equals(value1, value2, result)
|
104
93
|
|
105
94
|
result
|
106
95
|
end
|
107
96
|
|
108
97
|
private
|
109
98
|
|
99
|
+
def warn_for_color_arithmetic(value1, value2)
|
100
|
+
return unless @operator == :plus || @operator == :times || @operator == :minus ||
|
101
|
+
@operator == :div || @operator == :mod
|
102
|
+
|
103
|
+
if value1.is_a?(Sass::Script::Value::Number)
|
104
|
+
return unless value2.is_a?(Sass::Script::Value::Color)
|
105
|
+
elsif value1.is_a?(Sass::Script::Value::Color)
|
106
|
+
return unless value2.is_a?(Sass::Script::Value::Color) || value2.is_a?(Sass::Script::Value::Number)
|
107
|
+
else
|
108
|
+
return
|
109
|
+
end
|
110
|
+
|
111
|
+
@@color_arithmetic_deprecation.warn(filename, line, <<WARNING)
|
112
|
+
The operation `#{value1} #{@operator} #{value2}` is deprecated and will be an error in future versions.
|
113
|
+
Consider using Sass's color functions instead.
|
114
|
+
http://sass-lang.com/documentation/Sass/Script/Functions.html#other_color_functions
|
115
|
+
WARNING
|
116
|
+
end
|
117
|
+
|
118
|
+
def warn_for_unitless_equals(value1, value2, result)
|
119
|
+
return unless @operator == :eq || @operator == :neq
|
120
|
+
return unless value1.is_a?(Sass::Script::Value::Number)
|
121
|
+
return unless value2.is_a?(Sass::Script::Value::Number)
|
122
|
+
return unless value1.unitless? != value2.unitless?
|
123
|
+
return unless result == (if @operator == :eq
|
124
|
+
Sass::Script::Value::Bool::TRUE
|
125
|
+
else
|
126
|
+
Sass::Script::Value::Bool::FALSE
|
127
|
+
end)
|
128
|
+
|
129
|
+
operation = "#{value1.to_sass} #{@operator == :eq ? '==' : '!='} #{value2.to_sass}"
|
130
|
+
future_value = @operator == :neq
|
131
|
+
@@unitless_equals_deprecation.warn(filename, line, <<WARNING)
|
132
|
+
The result of `#{operation}` will be `#{future_value}` in future releases of Sass.
|
133
|
+
Unitless numbers will no longer be equal to the same numbers with units.
|
134
|
+
WARNING
|
135
|
+
end
|
136
|
+
|
110
137
|
def operand_to_sass(op, side, opts)
|
111
138
|
return "(#{op.to_sass(opts)})" if op.is_a?(Sass::Script::Tree::ListLiteral)
|
112
139
|
return op.to_sass(opts) unless op.is_a?(Operation)
|
@@ -27,7 +27,7 @@ module Sass::Script::Value
|
|
27
27
|
|
28
28
|
# Sets the options hash for this node,
|
29
29
|
# as well as for all child nodes.
|
30
|
-
# See {file:SASS_REFERENCE.md#
|
30
|
+
# See {file:SASS_REFERENCE.md#Options the Sass options documentation}.
|
31
31
|
#
|
32
32
|
# @param options [{Symbol => Object}] The options
|
33
33
|
attr_writer :options
|
@@ -149,7 +149,7 @@ MSG
|
|
149
149
|
# Returns the hash code of this value. Two objects' hash codes should be
|
150
150
|
# equal if the objects are equal.
|
151
151
|
#
|
152
|
-
# @return [Fixnum] The hash code.
|
152
|
+
# @return [Integer for Ruby 2.4.0+, Fixnum for earlier Ruby versions] The hash code.
|
153
153
|
def hash
|
154
154
|
value.hash
|
155
155
|
end
|
@@ -176,7 +176,7 @@ MSG
|
|
176
176
|
eq(other).to_bool
|
177
177
|
end
|
178
178
|
|
179
|
-
# @return [
|
179
|
+
# @return [Integer] The integer value of this value
|
180
180
|
# @raise [Sass::SyntaxError] if this value isn't an integer
|
181
181
|
def to_i
|
182
182
|
raise Sass::SyntaxError.new("#{inspect} is not an integer.")
|
@@ -17,8 +17,8 @@ module Sass::Script::Value
|
|
17
17
|
# @private
|
18
18
|
#
|
19
19
|
# Convert a ruby integer to a rgba components
|
20
|
-
# @param color [
|
21
|
-
# @return [Array<
|
20
|
+
# @param color [Integer]
|
21
|
+
# @return [Array<Integer>] Array of 4 numbers representing r,g,b and alpha
|
22
22
|
def self.int_to_rgba(color)
|
23
23
|
rgba = (0..3).map {|n| color >> (n << 3) & 0xff}.reverse
|
24
24
|
rgba[-1] = rgba[-1] / 255.0
|
@@ -293,7 +293,7 @@ module Sass::Script::Value
|
|
293
293
|
|
294
294
|
# The red component of the color.
|
295
295
|
#
|
296
|
-
# @return [
|
296
|
+
# @return [Integer]
|
297
297
|
def red
|
298
298
|
hsl_to_rgb!
|
299
299
|
@attrs[:red]
|
@@ -301,7 +301,7 @@ module Sass::Script::Value
|
|
301
301
|
|
302
302
|
# The green component of the color.
|
303
303
|
#
|
304
|
-
# @return [
|
304
|
+
# @return [Integer]
|
305
305
|
def green
|
306
306
|
hsl_to_rgb!
|
307
307
|
@attrs[:green]
|
@@ -309,7 +309,7 @@ module Sass::Script::Value
|
|
309
309
|
|
310
310
|
# The blue component of the color.
|
311
311
|
#
|
312
|
-
# @return [
|
312
|
+
# @return [Integer]
|
313
313
|
def blue
|
314
314
|
hsl_to_rgb!
|
315
315
|
@attrs[:blue]
|
@@ -342,7 +342,7 @@ module Sass::Script::Value
|
|
342
342
|
# The alpha channel (opacity) of the color.
|
343
343
|
# This is 1 unless otherwise defined.
|
344
344
|
#
|
345
|
-
# @return [
|
345
|
+
# @return [Integer]
|
346
346
|
def alpha
|
347
347
|
@attrs[:alpha].to_f
|
348
348
|
end
|
@@ -357,7 +357,7 @@ module Sass::Script::Value
|
|
357
357
|
|
358
358
|
# Returns the red, green, and blue components of the color.
|
359
359
|
#
|
360
|
-
# @return [Array<
|
360
|
+
# @return [Array<Integer>] A frozen three-element array of the red, green, and blue
|
361
361
|
# values (respectively) of the color
|
362
362
|
def rgb
|
363
363
|
[red, green, blue].freeze
|
@@ -365,7 +365,7 @@ module Sass::Script::Value
|
|
365
365
|
|
366
366
|
# Returns the red, green, blue, and alpha components of the color.
|
367
367
|
#
|
368
|
-
# @return [Array<
|
368
|
+
# @return [Array<Integer>] A frozen four-element array of the red, green,
|
369
369
|
# blue, and alpha values (respectively) of the color
|
370
370
|
def rgba
|
371
371
|
[red, green, blue, alpha].freeze
|
@@ -373,7 +373,7 @@ module Sass::Script::Value
|
|
373
373
|
|
374
374
|
# Returns the hue, saturation, and lightness components of the color.
|
375
375
|
#
|
376
|
-
# @return [Array<
|
376
|
+
# @return [Array<Integer>] A frozen three-element array of the
|
377
377
|
# hue, saturation, and lightness values (respectively) of the color
|
378
378
|
def hsl
|
379
379
|
[hue, saturation, lightness].freeze
|
@@ -381,7 +381,7 @@ module Sass::Script::Value
|
|
381
381
|
|
382
382
|
# Returns the hue, saturation, lightness, and alpha components of the color.
|
383
383
|
#
|
384
|
-
# @return [Array<
|
384
|
+
# @return [Array<Integer>] A frozen four-element array of the hue,
|
385
385
|
# saturation, lightness, and alpha values (respectively) of the color
|
386
386
|
def hsla
|
387
387
|
[hue, saturation, lightness, alpha].freeze
|
@@ -563,6 +563,11 @@ module Sass::Script::Value
|
|
563
563
|
def to_s(opts = {})
|
564
564
|
return smallest if options[:style] == :compressed
|
565
565
|
return representation if representation
|
566
|
+
|
567
|
+
# IE10 doesn't properly support the color name "transparent", so we emit
|
568
|
+
# generated transparent colors as rgba(0, 0, 0, 0) in favor of that. See
|
569
|
+
# #1782.
|
570
|
+
return rgba_str if Number.basically_equal?(alpha, 0)
|
566
571
|
return name if name
|
567
572
|
alpha? ? rgba_str : hex_str
|
568
573
|
end
|