sass 3.4.24 → 3.4.25
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/Rakefile +39 -10
- data/VERSION +1 -1
- data/VERSION_DATE +1 -1
- 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 +13 -5
- data/lib/sass/environment.rb +1 -1
- data/lib/sass/plugin.rb +1 -1
- data/lib/sass/plugin/compiler.rb +1 -1
- data/lib/sass/plugin/configuration.rb +1 -1
- data/lib/sass/plugin/rack.rb +2 -2
- data/lib/sass/plugin/staleness_checker.rb +1 -1
- data/lib/sass/script.rb +1 -1
- data/lib/sass/script/functions.rb +2 -2
- data/lib/sass/script/lexer.rb +1 -1
- data/lib/sass/script/parser.rb +4 -3
- data/lib/sass/script/tree/node.rb +1 -1
- data/lib/sass/script/tree/operation.rb +43 -16
- data/lib/sass/script/value/base.rb +1 -1
- data/lib/sass/script/value/string.rb +5 -12
- data/lib/sass/scss/static_parser.rb +7 -0
- data/lib/sass/selector/comma_sequence.rb +13 -1
- data/lib/sass/selector/simple.rb +1 -0
- data/lib/sass/tree/node.rb +2 -2
- data/lib/sass/tree/rule_node.rb +13 -4
- data/lib/sass/tree/visitors/deep_copy.rb +1 -1
- data/lib/sass/tree/visitors/perform.rb +3 -2
- data/test/sass/conversion_test.rb +3 -3
- data/test/sass/css2sass_test.rb +1 -1
- data/test/sass/engine_test.rb +56 -50
- data/test/sass/extend_test.rb +14 -8
- data/test/sass/functions_test.rb +5 -2
- 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 -3
- data/test/sass/script_test.rb +38 -29
- data/test/sass/scss/css_test.rb +2 -2
- data/test/sass/scss/scss_test.rb +25 -10
- data/test/sass/source_map_test.rb +13 -13
- 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 -2
- metadata +25 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8b2d6c079c8e8aec59e0dd45294419919f88239
|
4
|
+
data.tar.gz: 5e31ebbe100aa0b066d414ee32e3f29d792907f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1782f895c1aaeef19491dfb41434ca10a60d28395f53a3ec19f8a65ec21c97625db3325732007fbc3155821c53adf9bcd00ced70e9fe3c1c935295b34f3dfdaf
|
7
|
+
data.tar.gz: 39578a844dd4d6e381cb10ced82d5c6782ddd042c79cc5c4c9cc6a69163badbf1ce368526987447b955d44a3d20470ea5e4eae481ea9359d63eea09cab94ca70
|
data/Rakefile
CHANGED
@@ -12,8 +12,42 @@ task :default => :test
|
|
12
12
|
|
13
13
|
require 'rake/testtask'
|
14
14
|
|
15
|
+
LINE_SIZE = 80
|
16
|
+
DECORATION_CHAR = '#'
|
17
|
+
|
18
|
+
def print_header(string)
|
19
|
+
length = string.length
|
20
|
+
puts DECORATION_CHAR * LINE_SIZE
|
21
|
+
puts string.center(length + 2, ' ').center(LINE_SIZE, DECORATION_CHAR)
|
22
|
+
puts DECORATION_CHAR * LINE_SIZE
|
23
|
+
end
|
24
|
+
|
15
25
|
desc "Run all tests"
|
16
|
-
task :test
|
26
|
+
task :test do
|
27
|
+
test_cases = [
|
28
|
+
{
|
29
|
+
'env' => {'MATHN' => 'true'},
|
30
|
+
'tasks' => ['test:ruby', 'test:spec', :rubocop]
|
31
|
+
},
|
32
|
+
{
|
33
|
+
'env' => {'MATHN' => 'false'},
|
34
|
+
'tasks' => ['test:ruby']
|
35
|
+
}
|
36
|
+
]
|
37
|
+
|
38
|
+
test_cases.each do |test_case|
|
39
|
+
env = test_case['env']
|
40
|
+
tasks = test_case['tasks']
|
41
|
+
|
42
|
+
env.each do |key, value|
|
43
|
+
ENV[key] = value
|
44
|
+
end
|
45
|
+
tasks.each do |task|
|
46
|
+
print_header("Running task: #{task}, env: #{env}")
|
47
|
+
Rake::Task[task].execute
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
17
51
|
|
18
52
|
namespace :test do
|
19
53
|
desc "Run the ruby tests (without sass-spec)"
|
@@ -76,25 +110,20 @@ def ruby_version_at_least?(version_string)
|
|
76
110
|
ruby_version >= version
|
77
111
|
end
|
78
112
|
|
79
|
-
|
80
|
-
(ENV.has_key?("RUBOCOP") && ENV["RUBOCOP"] == "true" ||
|
81
|
-
!(ENV.has_key?("RUBOCOP") || ENV.has_key?("TEST")))
|
113
|
+
begin
|
82
114
|
require 'rubocop/rake_task'
|
83
115
|
RuboCop = Rubocop unless defined?(RuboCop)
|
84
116
|
RuboCop::RakeTask.new do |t|
|
85
117
|
t.patterns = FileList["lib/**/*"]
|
86
118
|
end
|
87
|
-
|
119
|
+
rescue LoadError
|
88
120
|
task :rubocop do
|
89
|
-
puts "
|
90
|
-
next if ENV.has_key?("RUBOCOP") && ENV["RUBOCOP"] != "true"
|
121
|
+
puts "Rubocop is disabled."
|
91
122
|
puts "Passing this check is required in order for your patch to be accepted."
|
92
|
-
puts "
|
123
|
+
puts "Install Rubocop and then run the style check with: rake rubocop."
|
93
124
|
end
|
94
125
|
end
|
95
126
|
|
96
|
-
task :test => :rubocop
|
97
|
-
|
98
127
|
# ----- Packaging -----
|
99
128
|
|
100
129
|
# Don't use Rake::GemPackageTast because we want prerequisites to run
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.4.
|
1
|
+
3.4.25
|
data/VERSION_DATE
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
07 July 2017 22:00:34 UTC
|
data/lib/sass.rb
CHANGED
@@ -47,7 +47,7 @@ module Sass
|
|
47
47
|
#
|
48
48
|
# @param contents [String] The contents of the Sass file.
|
49
49
|
# @param options [{Symbol => Object}] An options hash;
|
50
|
-
# see {file:SASS_REFERENCE.md#
|
50
|
+
# see {file:SASS_REFERENCE.md#Options the Sass options documentation}
|
51
51
|
# @raise [Sass::SyntaxError] if there's an error in the document
|
52
52
|
# @raise [Encoding::UndefinedConversionError] if the source encoding
|
53
53
|
# cannot be converted to UTF-8
|
@@ -69,7 +69,7 @@ module Sass
|
|
69
69
|
#
|
70
70
|
# @param filename [String] The path to the Sass, SCSS, or CSS file on disk.
|
71
71
|
# @param options [{Symbol => Object}] An options hash;
|
72
|
-
# see {file:SASS_REFERENCE.md#
|
72
|
+
# see {file:SASS_REFERENCE.md#Options the Sass options documentation}
|
73
73
|
# @return [String] The compiled CSS.
|
74
74
|
#
|
75
75
|
# @overload compile_file(filename, css_filename, options = {})
|
@@ -77,7 +77,7 @@ module Sass
|
|
77
77
|
#
|
78
78
|
# @param filename [String] The path to the Sass, SCSS, or CSS file on disk.
|
79
79
|
# @param options [{Symbol => Object}] An options hash;
|
80
|
-
# see {file:SASS_REFERENCE.md#
|
80
|
+
# see {file:SASS_REFERENCE.md#Options the Sass options documentation}
|
81
81
|
# @param css_filename [String] The location to which to write the compiled CSS.
|
82
82
|
def self.compile_file(filename, *args)
|
83
83
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
data/lib/sass/css.rb
CHANGED
@@ -18,7 +18,7 @@ module Sass
|
|
18
18
|
# that can be converted to Unicode.
|
19
19
|
# If the stylesheet contains an `@charset` declaration,
|
20
20
|
# that overrides the Ruby encoding
|
21
|
-
# (see {file:SASS_REFERENCE.md#
|
21
|
+
# (see {file:SASS_REFERENCE.md#Encodings the encoding documentation})
|
22
22
|
# @option options :old [Boolean] (false)
|
23
23
|
# Whether or not to output old property syntax
|
24
24
|
# (`:color blue` as opposed to `color: blue`).
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Sass
|
2
|
+
# A deprecation warning that should only be printed once for a given line in a
|
3
|
+
# given file.
|
4
|
+
#
|
5
|
+
# A global Deprecation instance should be created for each type of deprecation
|
6
|
+
# warning, and `warn` should be called each time a warning is needed.
|
7
|
+
class Deprecation
|
8
|
+
@@allow_double_warnings = false
|
9
|
+
|
10
|
+
# Runs a block in which double deprecation warnings for the same location
|
11
|
+
# are allowed.
|
12
|
+
def self.allow_double_warnings
|
13
|
+
old_allow_double_warnings = @@allow_double_warnings
|
14
|
+
@@allow_double_warnings = true
|
15
|
+
yield
|
16
|
+
ensure
|
17
|
+
@@allow_double_warnings = old_allow_double_warnings
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
# A set of filename, line pairs for which warnings have been emitted.
|
22
|
+
@seen = Set.new
|
23
|
+
end
|
24
|
+
|
25
|
+
# Prints `message` as a deprecation warning associated with `filename`,
|
26
|
+
# `line`, and optionally `column`.
|
27
|
+
#
|
28
|
+
# This ensures that only one message will be printed for each line of a
|
29
|
+
# given file.
|
30
|
+
#
|
31
|
+
# @overload warn(filename, line, message)
|
32
|
+
# @param filename [String, nil]
|
33
|
+
# @param line [Number]
|
34
|
+
# @param message [String]
|
35
|
+
# @overload warn(filename, line, column, message)
|
36
|
+
# @param filename [String, nil]
|
37
|
+
# @param line [Number]
|
38
|
+
# @param column [Number]
|
39
|
+
# @param message [String]
|
40
|
+
def warn(filename, line, column_or_message, message = nil)
|
41
|
+
return if !@@allow_double_warnings && @seen.add?([filename, line]).nil?
|
42
|
+
if message
|
43
|
+
column = column_or_message
|
44
|
+
else
|
45
|
+
message = column_or_message
|
46
|
+
end
|
47
|
+
|
48
|
+
location = "line #{line}"
|
49
|
+
location << ", column #{column}" if column
|
50
|
+
location << " of #{filename}" if filename
|
51
|
+
|
52
|
+
Sass::Util.sass_warn("DEPRECATION WARNING on #{location}:\n#{message}")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/sass/engine.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'set'
|
2
2
|
require 'digest/sha1'
|
3
3
|
require 'sass/cache_stores'
|
4
|
+
require 'sass/deprecation'
|
4
5
|
require 'sass/source/position'
|
5
6
|
require 'sass/source/range'
|
6
7
|
require 'sass/source/map'
|
@@ -89,6 +90,8 @@ module Sass
|
|
89
90
|
# output = sass_engine.render
|
90
91
|
# puts output
|
91
92
|
class Engine
|
93
|
+
@@old_property_deprecation = Deprecation.new
|
94
|
+
|
92
95
|
# A line of Sass code.
|
93
96
|
#
|
94
97
|
# `text`: `String`
|
@@ -168,7 +171,7 @@ module Sass
|
|
168
171
|
# default values and resolving aliases.
|
169
172
|
#
|
170
173
|
# @param options [{Symbol => Object}] The options hash;
|
171
|
-
# see {file:SASS_REFERENCE.md#
|
174
|
+
# see {file:SASS_REFERENCE.md#Options the Sass options documentation}
|
172
175
|
# @return [{Symbol => Object}] The normalized options hash.
|
173
176
|
# @private
|
174
177
|
def self.normalize_options(options)
|
@@ -222,7 +225,7 @@ module Sass
|
|
222
225
|
#
|
223
226
|
# @param filename [String] The path to the Sass or SCSS file
|
224
227
|
# @param options [{Symbol => Object}] The options hash;
|
225
|
-
# See {file:SASS_REFERENCE.md#
|
228
|
+
# See {file:SASS_REFERENCE.md#Options the Sass options documentation}.
|
226
229
|
# @return [Sass::Engine] The Engine for the given Sass or SCSS file.
|
227
230
|
# @raise [Sass::SyntaxError] if there's an error in the document.
|
228
231
|
def self.for_file(filename, options)
|
@@ -240,7 +243,7 @@ module Sass
|
|
240
243
|
end
|
241
244
|
|
242
245
|
# The options for the Sass engine.
|
243
|
-
# See {file:SASS_REFERENCE.md#
|
246
|
+
# See {file:SASS_REFERENCE.md#Options the Sass options documentation}.
|
244
247
|
#
|
245
248
|
# @return [{Symbol => Object}]
|
246
249
|
attr_reader :options
|
@@ -257,9 +260,9 @@ module Sass
|
|
257
260
|
# that can be converted to Unicode.
|
258
261
|
# If the template contains an `@charset` declaration,
|
259
262
|
# that overrides the Ruby encoding
|
260
|
-
# (see {file:SASS_REFERENCE.md#
|
263
|
+
# (see {file:SASS_REFERENCE.md#Encodings the encoding documentation})
|
261
264
|
# @param options [{Symbol => Object}] An options hash.
|
262
|
-
# See {file:SASS_REFERENCE.md#
|
265
|
+
# See {file:SASS_REFERENCE.md#Options the Sass options documentation}.
|
263
266
|
# @see {Sass::Engine.for_file}
|
264
267
|
# @see {Sass::Plugin}
|
265
268
|
def initialize(template, options = {})
|
@@ -625,6 +628,11 @@ WARNING
|
|
625
628
|
raise SyntaxError.new("Invalid property: \"#{line.text}\".",
|
626
629
|
:line => @line) if name.nil? || value.nil?
|
627
630
|
|
631
|
+
@@old_property_deprecation.warn(@options[:filename], @line, <<WARNING)
|
632
|
+
Old-style properties like "#{line.text}" are deprecated and will be an error in future versions of Sass.
|
633
|
+
Use "#{name}: #{value}" instead.
|
634
|
+
WARNING
|
635
|
+
|
628
636
|
value_start_offset = name_end_offset = name_start_offset + name.length
|
629
637
|
unless value.empty?
|
630
638
|
# +1 and -1 both compensate for the leading ':', which is part of line.text
|
data/lib/sass/environment.rb
CHANGED
@@ -81,7 +81,7 @@ module Sass
|
|
81
81
|
inherited_hash_reader :function
|
82
82
|
|
83
83
|
# @param options [{Symbol => Object}] The options hash. See
|
84
|
-
# {file:SASS_REFERENCE.md#
|
84
|
+
# {file:SASS_REFERENCE.md#Options the Sass options documentation}.
|
85
85
|
# @param parent [Environment] See \{#parent}
|
86
86
|
def initialize(parent = nil, options = nil)
|
87
87
|
@parent = parent
|
data/lib/sass/plugin.rb
CHANGED
@@ -12,7 +12,7 @@ module Sass
|
|
12
12
|
# when it's used as a plugin for various frameworks.
|
13
13
|
# All Rack-enabled frameworks are supported out of the box.
|
14
14
|
# The plugin is
|
15
|
-
# {file:SASS_REFERENCE.md#
|
15
|
+
# {file:SASS_REFERENCE.md#Rack_Rails_Merb_Plugin automatically activated for Rails and Merb}.
|
16
16
|
# Other frameworks must enable it explicitly; see {Sass::Plugin::Rack}.
|
17
17
|
#
|
18
18
|
# This module has a large set of callbacks available
|
data/lib/sass/plugin/compiler.rb
CHANGED
@@ -31,7 +31,7 @@ module Sass::Plugin
|
|
31
31
|
# Creates a new compiler.
|
32
32
|
#
|
33
33
|
# @param opts [{Symbol => Object}]
|
34
|
-
# See {file:SASS_REFERENCE.md#
|
34
|
+
# See {file:SASS_REFERENCE.md#Options the Sass options documentation}.
|
35
35
|
def initialize(opts = {})
|
36
36
|
@watched_files = Set.new
|
37
37
|
options.merge!(opts)
|
data/lib/sass/plugin/rack.rb
CHANGED
@@ -14,14 +14,14 @@ module Sass
|
|
14
14
|
# :never_update => environment != :production,
|
15
15
|
# :full_exception => environment != :production)
|
16
16
|
#
|
17
|
-
# {file:SASS_REFERENCE.md#
|
17
|
+
# {file:SASS_REFERENCE.md#Options See the Reference for more options}.
|
18
18
|
#
|
19
19
|
# ## Use
|
20
20
|
#
|
21
21
|
# Put your Sass files in `public/stylesheets/sass`.
|
22
22
|
# Your CSS will be generated in `public/stylesheets`,
|
23
23
|
# and regenerated every request if necessary.
|
24
|
-
# The locations and frequency {file:SASS_REFERENCE.md#
|
24
|
+
# The locations and frequency {file:SASS_REFERENCE.md#Options can be customized}.
|
25
25
|
# That's all there is to it!
|
26
26
|
class Rack
|
27
27
|
# The delay, in seconds, between update checks.
|
@@ -39,7 +39,7 @@ module Sass
|
|
39
39
|
# for checking the staleness of several stylesheets at once.
|
40
40
|
#
|
41
41
|
# @param options [{Symbol => Object}]
|
42
|
-
# See {file:SASS_REFERENCE.md#
|
42
|
+
# See {file:SASS_REFERENCE.md#Options the Sass options documentation}.
|
43
43
|
def initialize(options)
|
44
44
|
# URIs that are being actively checked for staleness. Protects against
|
45
45
|
# import loops.
|
data/lib/sass/script.rb
CHANGED
@@ -21,7 +21,7 @@ module Sass
|
|
21
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)
|
@@ -2510,7 +2510,7 @@ MESSAGE
|
|
2510
2510
|
|
2511
2511
|
extends = Sass::Util::SubsetMap.new
|
2512
2512
|
begin
|
2513
|
-
extender.populate_extends(extends, extendee)
|
2513
|
+
extender.populate_extends(extends, extendee, nil, [], true)
|
2514
2514
|
selector.do_extend(extends).to_sass_script
|
2515
2515
|
rescue Sass::SyntaxError => e
|
2516
2516
|
raise ArgumentError.new(e.to_s)
|
@@ -2553,7 +2553,7 @@ MESSAGE
|
|
2553
2553
|
|
2554
2554
|
extends = Sass::Util::SubsetMap.new
|
2555
2555
|
begin
|
2556
|
-
replacement.populate_extends(extends, original)
|
2556
|
+
replacement.populate_extends(extends, original, nil, [], true)
|
2557
2557
|
selector.do_extend(extends, [], true).to_sass_script
|
2558
2558
|
rescue Sass::SyntaxError => e
|
2559
2559
|
raise ArgumentError.new(e.to_s)
|
data/lib/sass/script/lexer.rb
CHANGED
@@ -147,7 +147,7 @@ module Sass
|
|
147
147
|
# @param offset [Integer] The 1-based character (not byte) offset in the line in the source.
|
148
148
|
# Used for error reporting and sourcemap building
|
149
149
|
# @param options [{Symbol => Object}] An options hash;
|
150
|
-
# see {file:SASS_REFERENCE.md#
|
150
|
+
# see {file:SASS_REFERENCE.md#Options the Sass options documentation}
|
151
151
|
def initialize(str, line, offset, options)
|
152
152
|
@scanner = str.is_a?(StringScanner) ? str : Sass::Util::MultibyteStringScanner.new(str)
|
153
153
|
@line = line
|
data/lib/sass/script/parser.rb
CHANGED
@@ -26,7 +26,7 @@ module Sass
|
|
26
26
|
# @param offset [Integer] The character (not byte) offset where the script starts in the line.
|
27
27
|
# Used for error reporting and sourcemap building
|
28
28
|
# @param options [{Symbol => Object}] An options hash; see
|
29
|
-
# {file:SASS_REFERENCE.md#
|
29
|
+
# {file:SASS_REFERENCE.md#Options the Sass options documentation}.
|
30
30
|
# This supports an additional `:allow_extra_text` option that controls
|
31
31
|
# whether the parser throws an error when extra text is encountered
|
32
32
|
# after the parsed construct.
|
@@ -818,8 +818,9 @@ RUBY
|
|
818
818
|
location = "on line #{interpolation.line}"
|
819
819
|
location << " of #{interpolation.filename}" if interpolation.filename
|
820
820
|
Sass::Util.sass_warn <<WARNING
|
821
|
-
DEPRECATION WARNING #{location}:
|
822
|
-
in a future version of Sass.
|
821
|
+
DEPRECATION WARNING #{location}:
|
822
|
+
\#{} interpolation near operators will be simplified in a future version of Sass.
|
823
|
+
To preserve the current behavior, use quotes:
|
823
824
|
|
824
825
|
#{interpolation.to_quoted_equivalent.to_sass}
|
825
826
|
|
@@ -33,7 +33,7 @@ module Sass::Script::Tree
|
|
33
33
|
|
34
34
|
# Sets the options hash for this node,
|
35
35
|
# as well as for all child nodes.
|
36
|
-
# See {file:SASS_REFERENCE.md#
|
36
|
+
# See {file:SASS_REFERENCE.md#Options the Sass options documentation}.
|
37
37
|
#
|
38
38
|
# @param options [{Symbol => Object}] The options
|
39
39
|
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
|
@@ -92,28 +95,52 @@ module Sass::Script::Tree
|
|
92
95
|
raise Sass::SyntaxError.new("Undefined operation: \"#{value1} #{@operator} #{value2}\".")
|
93
96
|
end
|
94
97
|
|
95
|
-
|
96
|
-
|
97
|
-
result == (if @operator == :eq
|
98
|
-
Sass::Script::Value::Bool::TRUE
|
99
|
-
else
|
100
|
-
Sass::Script::Value::Bool::FALSE
|
101
|
-
end)
|
102
|
-
|
103
|
-
operation = "#{value1.to_sass} #{@operator == :eq ? '==' : '!='} #{value2.to_sass}"
|
104
|
-
future_value = @operator == :neq
|
105
|
-
Sass::Util.sass_warn <<WARNING
|
106
|
-
DEPRECATION WARNING on line #{line}#{" of #{filename}" if filename}:
|
107
|
-
The result of `#{operation}` will be `#{future_value}` in future releases of Sass.
|
108
|
-
Unitless numbers will no longer be equal to the same numbers with units.
|
109
|
-
WARNING
|
110
|
-
end
|
98
|
+
warn_for_color_arithmetic(value1, value2)
|
99
|
+
warn_for_unitless_equals(value1, value2, result)
|
111
100
|
|
112
101
|
result
|
113
102
|
end
|
114
103
|
|
115
104
|
private
|
116
105
|
|
106
|
+
def warn_for_color_arithmetic(value1, value2)
|
107
|
+
return unless @operator == :plus || @operator == :times || @operator == :minus ||
|
108
|
+
@operator == :div || @operator == :mod
|
109
|
+
|
110
|
+
if value1.is_a?(Sass::Script::Value::Number)
|
111
|
+
return unless value2.is_a?(Sass::Script::Value::Color)
|
112
|
+
elsif value1.is_a?(Sass::Script::Value::Color)
|
113
|
+
return unless value2.is_a?(Sass::Script::Value::Color) || value2.is_a?(Sass::Script::Value::Number)
|
114
|
+
else
|
115
|
+
return
|
116
|
+
end
|
117
|
+
|
118
|
+
@@color_arithmetic_deprecation.warn(filename, line, <<WARNING)
|
119
|
+
The operation `#{value1} #{@operator} #{value2}` is deprecated and will be an error in future versions.
|
120
|
+
Consider using Sass's color functions instead.
|
121
|
+
http://sass-lang.com/documentation/Sass/Script/Functions.html#other_color_functions
|
122
|
+
WARNING
|
123
|
+
end
|
124
|
+
|
125
|
+
def warn_for_unitless_equals(value1, value2, result)
|
126
|
+
return unless @operator == :eq || @operator == :neq
|
127
|
+
return unless value1.is_a?(Sass::Script::Value::Number)
|
128
|
+
return unless value2.is_a?(Sass::Script::Value::Number)
|
129
|
+
return unless value1.unitless? != value2.unitless?
|
130
|
+
return unless result == (if @operator == :eq
|
131
|
+
Sass::Script::Value::Bool::TRUE
|
132
|
+
else
|
133
|
+
Sass::Script::Value::Bool::FALSE
|
134
|
+
end)
|
135
|
+
|
136
|
+
operation = "#{value1.to_sass} #{@operator == :eq ? '==' : '!='} #{value2.to_sass}"
|
137
|
+
future_value = @operator == :neq
|
138
|
+
@@unitless_equals_deprecation.warn(filename, line, <<WARNING)
|
139
|
+
The result of `#{operation}` will be `#{future_value}` in future releases of Sass.
|
140
|
+
Unitless numbers will no longer be equal to the same numbers with units.
|
141
|
+
WARNING
|
142
|
+
end
|
143
|
+
|
117
144
|
def operand_to_sass(op, side, opts)
|
118
145
|
return "(#{op.to_sass(opts)})" if op.is_a?(Sass::Script::Tree::ListLiteral)
|
119
146
|
return op.to_sass(opts) unless op.is_a?(Operation)
|