sass 3.7.4 → 4.0.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.yardopts +1 -1
- data/CODE_OF_CONDUCT.md +1 -1
- data/CONTRIBUTING.md +1 -146
- data/MIT-LICENSE +1 -1
- data/README.md +25 -39
- data/Rakefile +274 -0
- data/VERSION +1 -1
- data/VERSION_DATE +1 -1
- data/lib/sass.rb +3 -3
- data/lib/sass/cache_stores/filesystem.rb +2 -2
- data/lib/sass/cache_stores/memory.rb +5 -4
- data/lib/sass/callbacks.rb +2 -2
- data/lib/sass/css.rb +12 -12
- data/lib/sass/engine.rb +44 -62
- data/lib/sass/environment.rb +7 -35
- data/lib/sass/error.rb +14 -14
- data/lib/sass/exec/base.rb +14 -3
- data/lib/sass/exec/sass_convert.rb +6 -20
- data/lib/sass/exec/sass_scss.rb +29 -5
- data/lib/sass/features.rb +2 -3
- data/lib/sass/importers/filesystem.rb +6 -11
- data/lib/sass/logger.rb +3 -8
- data/lib/sass/logger/base.rb +2 -19
- data/lib/sass/plugin.rb +2 -3
- data/lib/sass/plugin/compiler.rb +67 -48
- data/lib/sass/plugin/configuration.rb +3 -3
- data/lib/sass/plugin/merb.rb +1 -1
- data/lib/sass/plugin/rack.rb +3 -3
- data/lib/sass/plugin/staleness_checker.rb +3 -3
- data/lib/sass/railtie.rb +1 -1
- data/lib/sass/script.rb +3 -3
- data/lib/sass/script/css_parser.rb +15 -5
- data/lib/sass/script/functions.rb +121 -337
- data/lib/sass/script/lexer.rb +36 -102
- data/lib/sass/script/parser.rb +153 -529
- data/lib/sass/script/tree/funcall.rb +34 -42
- data/lib/sass/script/tree/interpolation.rb +26 -171
- data/lib/sass/script/tree/list_literal.rb +8 -23
- data/lib/sass/script/tree/map_literal.rb +2 -2
- data/lib/sass/script/tree/node.rb +3 -3
- data/lib/sass/script/tree/operation.rb +16 -43
- data/lib/sass/script/tree/string_interpolation.rb +43 -64
- data/lib/sass/script/tree/variable.rb +1 -1
- data/lib/sass/script/value.rb +0 -2
- data/lib/sass/script/value/arg_list.rb +1 -1
- data/lib/sass/script/value/base.rb +9 -27
- data/lib/sass/script/value/color.rb +18 -26
- data/lib/sass/script/value/helpers.rb +18 -44
- data/lib/sass/script/value/list.rb +14 -35
- data/lib/sass/script/value/map.rb +2 -2
- data/lib/sass/script/value/number.rb +16 -26
- data/lib/sass/script/value/string.rb +1 -30
- data/lib/sass/scss.rb +2 -0
- data/lib/sass/scss/css_parser.rb +3 -7
- data/lib/sass/scss/parser.rb +78 -196
- data/lib/sass/scss/rx.rb +14 -7
- data/lib/sass/scss/script_lexer.rb +15 -0
- data/lib/sass/scss/script_parser.rb +25 -0
- data/lib/sass/scss/static_parser.rb +55 -38
- data/lib/sass/selector.rb +10 -7
- data/lib/sass/selector/abstract_sequence.rb +12 -15
- data/lib/sass/selector/comma_sequence.rb +6 -24
- data/lib/sass/selector/pseudo.rb +6 -19
- data/lib/sass/selector/sequence.rb +16 -14
- data/lib/sass/selector/simple.rb +7 -9
- data/lib/sass/selector/simple_sequence.rb +12 -16
- data/lib/sass/shared.rb +1 -1
- data/lib/sass/source/map.rb +9 -7
- data/lib/sass/source/position.rb +4 -4
- data/lib/sass/stack.rb +3 -23
- data/lib/sass/tree/charset_node.rb +1 -1
- data/lib/sass/tree/comment_node.rb +1 -1
- data/lib/sass/tree/function_node.rb +3 -2
- data/lib/sass/tree/node.rb +3 -5
- data/lib/sass/tree/prop_node.rb +58 -49
- data/lib/sass/tree/rule_node.rb +8 -15
- data/lib/sass/tree/visitors/check_nesting.rb +23 -19
- data/lib/sass/tree/visitors/convert.rb +13 -15
- data/lib/sass/tree/visitors/cssize.rb +15 -4
- data/lib/sass/tree/visitors/deep_copy.rb +2 -2
- data/lib/sass/tree/visitors/extend.rb +14 -10
- data/lib/sass/tree/visitors/perform.rb +18 -29
- data/lib/sass/tree/visitors/set_options.rb +2 -2
- data/lib/sass/tree/visitors/to_css.rb +47 -77
- data/lib/sass/util.rb +311 -98
- data/lib/sass/util/cross_platform_random.rb +19 -0
- data/lib/sass/util/multibyte_string_scanner.rb +133 -127
- data/lib/sass/util/normalized_map.rb +8 -1
- data/lib/sass/util/ordered_hash.rb +192 -0
- data/lib/sass/version.rb +6 -2
- data/test/sass/cache_test.rb +131 -0
- data/test/sass/callbacks_test.rb +61 -0
- data/test/sass/compiler_test.rb +236 -0
- data/test/sass/conversion_test.rb +2171 -0
- data/test/sass/css2sass_test.rb +526 -0
- data/test/sass/data/hsl-rgb.txt +319 -0
- data/test/sass/encoding_test.rb +219 -0
- data/test/sass/engine_test.rb +3400 -0
- data/test/sass/exec_test.rb +86 -0
- data/test/sass/extend_test.rb +1719 -0
- data/test/sass/fixtures/test_staleness_check_across_importers.css +1 -0
- data/test/sass/fixtures/test_staleness_check_across_importers.scss +1 -0
- data/test/sass/functions_test.rb +1984 -0
- data/test/sass/importer_test.rb +421 -0
- data/test/sass/logger_test.rb +58 -0
- data/test/sass/mock_importer.rb +49 -0
- data/test/sass/more_results/more1.css +9 -0
- data/test/sass/more_results/more1_with_line_comments.css +26 -0
- data/test/sass/more_results/more_import.css +29 -0
- data/test/sass/more_templates/_more_partial.sass +2 -0
- data/test/sass/more_templates/more1.sass +23 -0
- data/test/sass/more_templates/more_import.sass +11 -0
- data/test/sass/plugin_test.rb +556 -0
- data/test/sass/results/alt.css +4 -0
- data/test/sass/results/basic.css +9 -0
- data/test/sass/results/cached_import_option.css +3 -0
- data/test/sass/results/compact.css +5 -0
- data/test/sass/results/complex.css +86 -0
- data/test/sass/results/compressed.css +1 -0
- data/test/sass/results/expanded.css +19 -0
- data/test/sass/results/filename_fn.css +3 -0
- data/test/sass/results/if.css +3 -0
- data/test/sass/results/import.css +31 -0
- data/test/sass/results/import_charset.css +5 -0
- data/test/sass/results/import_charset_1_8.css +5 -0
- data/test/sass/results/import_charset_ibm866.css +5 -0
- data/test/sass/results/import_content.css +1 -0
- data/test/sass/results/line_numbers.css +49 -0
- data/test/sass/results/mixins.css +95 -0
- data/test/sass/results/multiline.css +24 -0
- data/test/sass/results/nested.css +22 -0
- data/test/sass/results/options.css +1 -0
- data/test/sass/results/parent_ref.css +13 -0
- data/test/sass/results/script.css +16 -0
- data/test/sass/results/scss_import.css +31 -0
- data/test/sass/results/scss_importee.css +2 -0
- data/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
- data/test/sass/results/subdir/subdir.css +3 -0
- data/test/sass/results/units.css +11 -0
- data/test/sass/results/warn.css +0 -0
- data/test/sass/results/warn_imported.css +0 -0
- data/test/sass/script_conversion_test.rb +306 -0
- data/test/sass/script_test.rb +1206 -0
- data/test/sass/scss/css_test.rb +1281 -0
- data/test/sass/scss/rx_test.rb +160 -0
- data/test/sass/scss/scss_test.rb +4147 -0
- data/test/sass/scss/test_helper.rb +37 -0
- data/test/sass/source_map_test.rb +1055 -0
- data/test/sass/superselector_test.rb +210 -0
- data/test/sass/templates/_cached_import_option_partial.scss +1 -0
- data/test/sass/templates/_double_import_loop2.sass +1 -0
- data/test/sass/templates/_filename_fn_import.scss +11 -0
- data/test/sass/templates/_imported_charset_ibm866.sass +4 -0
- data/test/sass/templates/_imported_charset_utf8.sass +4 -0
- data/test/sass/templates/_imported_content.sass +3 -0
- data/test/sass/templates/_partial.sass +2 -0
- data/test/sass/templates/_same_name_different_partiality.scss +1 -0
- data/test/sass/templates/alt.sass +16 -0
- data/test/sass/templates/basic.sass +23 -0
- data/test/sass/templates/bork1.sass +2 -0
- data/test/sass/templates/bork2.sass +2 -0
- data/test/sass/templates/bork3.sass +2 -0
- data/test/sass/templates/bork4.sass +2 -0
- data/test/sass/templates/bork5.sass +3 -0
- data/test/sass/templates/cached_import_option.scss +3 -0
- data/test/sass/templates/compact.sass +17 -0
- data/test/sass/templates/complex.sass +305 -0
- data/test/sass/templates/compressed.sass +15 -0
- data/test/sass/templates/double_import_loop1.sass +1 -0
- data/test/sass/templates/expanded.sass +17 -0
- data/test/sass/templates/filename_fn.scss +18 -0
- data/test/sass/templates/if.sass +11 -0
- data/test/sass/templates/import.sass +12 -0
- data/test/sass/templates/import_charset.sass +9 -0
- data/test/sass/templates/import_charset_1_8.sass +6 -0
- data/test/sass/templates/import_charset_ibm866.sass +11 -0
- data/test/sass/templates/import_content.sass +4 -0
- data/test/sass/templates/importee.less +2 -0
- data/test/sass/templates/importee.sass +19 -0
- data/test/sass/templates/line_numbers.sass +13 -0
- data/test/sass/templates/mixin_bork.sass +5 -0
- data/test/sass/templates/mixins.sass +76 -0
- data/test/sass/templates/multiline.sass +20 -0
- data/test/sass/templates/nested.sass +25 -0
- data/test/sass/templates/nested_bork1.sass +2 -0
- data/test/sass/templates/nested_bork2.sass +2 -0
- data/test/sass/templates/nested_bork3.sass +2 -0
- data/test/sass/templates/nested_bork4.sass +2 -0
- data/test/sass/templates/nested_import.sass +2 -0
- data/test/sass/templates/nested_mixin_bork.sass +6 -0
- data/test/sass/templates/options.sass +2 -0
- data/test/sass/templates/parent_ref.sass +25 -0
- data/test/sass/templates/same_name_different_ext.sass +2 -0
- data/test/sass/templates/same_name_different_ext.scss +1 -0
- data/test/sass/templates/same_name_different_partiality.scss +1 -0
- data/test/sass/templates/script.sass +101 -0
- data/test/sass/templates/scss_import.scss +12 -0
- data/test/sass/templates/scss_importee.scss +1 -0
- data/test/sass/templates/single_import_loop.sass +1 -0
- data/test/sass/templates/subdir/import_up1.scss +1 -0
- data/test/sass/templates/subdir/import_up2.scss +1 -0
- data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
- data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
- data/test/sass/templates/subdir/subdir.sass +6 -0
- data/test/sass/templates/units.sass +11 -0
- data/test/sass/templates/warn.sass +3 -0
- data/test/sass/templates/warn_imported.sass +4 -0
- data/test/sass/test_helper.rb +8 -0
- data/test/sass/util/multibyte_string_scanner_test.rb +147 -0
- data/test/sass/util/normalized_map_test.rb +51 -0
- data/test/sass/util/subset_map_test.rb +91 -0
- data/test/sass/util_test.rb +438 -0
- data/test/sass/value_helpers_test.rb +179 -0
- data/test/test_helper.rb +110 -0
- data/vendor/listen/CHANGELOG.md +1 -0
- data/vendor/listen/CONTRIBUTING.md +38 -0
- data/vendor/listen/Gemfile +20 -0
- data/vendor/listen/Guardfile +8 -0
- data/vendor/listen/LICENSE +20 -0
- data/vendor/listen/README.md +349 -0
- data/vendor/listen/Rakefile +5 -0
- data/vendor/listen/Vagrantfile +96 -0
- data/vendor/listen/lib/listen.rb +54 -0
- data/vendor/listen/lib/listen/adapter.rb +327 -0
- data/vendor/listen/lib/listen/adapters/bsd.rb +75 -0
- data/vendor/listen/lib/listen/adapters/darwin.rb +48 -0
- data/vendor/listen/lib/listen/adapters/linux.rb +81 -0
- data/vendor/listen/lib/listen/adapters/polling.rb +58 -0
- data/vendor/listen/lib/listen/adapters/windows.rb +91 -0
- data/vendor/listen/lib/listen/directory_record.rb +406 -0
- data/vendor/listen/lib/listen/listener.rb +323 -0
- data/vendor/listen/lib/listen/turnstile.rb +32 -0
- data/vendor/listen/lib/listen/version.rb +3 -0
- data/vendor/listen/listen.gemspec +28 -0
- data/vendor/listen/spec/listen/adapter_spec.rb +149 -0
- data/vendor/listen/spec/listen/adapters/bsd_spec.rb +36 -0
- data/vendor/listen/spec/listen/adapters/darwin_spec.rb +37 -0
- data/vendor/listen/spec/listen/adapters/linux_spec.rb +47 -0
- data/vendor/listen/spec/listen/adapters/polling_spec.rb +68 -0
- data/vendor/listen/spec/listen/adapters/windows_spec.rb +30 -0
- data/vendor/listen/spec/listen/directory_record_spec.rb +1250 -0
- data/vendor/listen/spec/listen/listener_spec.rb +258 -0
- data/vendor/listen/spec/listen/turnstile_spec.rb +56 -0
- data/vendor/listen/spec/listen_spec.rb +67 -0
- data/vendor/listen/spec/spec_helper.rb +25 -0
- data/vendor/listen/spec/support/adapter_helper.rb +666 -0
- data/vendor/listen/spec/support/directory_record_helper.rb +57 -0
- data/vendor/listen/spec/support/fixtures_helper.rb +29 -0
- data/vendor/listen/spec/support/listeners_helper.rb +179 -0
- data/vendor/listen/spec/support/platform_helper.rb +15 -0
- metadata +217 -76
- data/extra/sass-spec-ref.sh +0 -40
- data/lib/sass/deprecation.rb +0 -55
- data/lib/sass/logger/delayed.rb +0 -50
- data/lib/sass/script/value/callable.rb +0 -25
- data/lib/sass/script/value/function.rb +0 -19
data/lib/sass/stack.rb
CHANGED
@@ -98,31 +98,11 @@ module Sass
|
|
98
98
|
with_frame(filename, line, :mixin, name) {yield}
|
99
99
|
end
|
100
100
|
|
101
|
-
# Pushes a function frame onto the stack.
|
102
|
-
#
|
103
|
-
# @param filename [String] See \{Frame#filename}.
|
104
|
-
# @param line [String] See \{Frame#line}.
|
105
|
-
# @param name [String] See \{Frame#name}.
|
106
|
-
# @yield [] A block in which the new frame is on the stack.
|
107
|
-
def with_function(filename, line, name)
|
108
|
-
with_frame(filename, line, :function, name) {yield}
|
109
|
-
end
|
110
|
-
|
111
|
-
# Pushes a function frame onto the stack.
|
112
|
-
#
|
113
|
-
# @param filename [String] See \{Frame#filename}.
|
114
|
-
# @param line [String] See \{Frame#line}.
|
115
|
-
# @param name [String] See \{Frame#name}.
|
116
|
-
# @yield [] A block in which the new frame is on the stack.
|
117
|
-
def with_directive(filename, line, name)
|
118
|
-
with_frame(filename, line, :directive, name) {yield}
|
119
|
-
end
|
120
|
-
|
121
101
|
def to_s
|
122
|
-
(frames.reverse + [nil]
|
102
|
+
Sass::Util.enum_with_index(Sass::Util.enum_cons(frames.reverse + [nil], 2)).
|
123
103
|
map do |(frame, caller), i|
|
124
|
-
"#{i == 0 ?
|
125
|
-
" of #{frame.filename ||
|
104
|
+
"#{i == 0 ? "on" : "from"} line #{frame.line}" +
|
105
|
+
" of #{frame.filename || "an unknown file"}" +
|
126
106
|
(caller && caller.name ? ", in `#{caller.name}'" : "")
|
127
107
|
end.join("\n")
|
128
108
|
end
|
@@ -36,8 +36,9 @@ module Sass
|
|
36
36
|
@splat = splat
|
37
37
|
super()
|
38
38
|
|
39
|
-
|
40
|
-
|
39
|
+
if %w[and or not].include?(name)
|
40
|
+
raise Sass::SyntaxError.new("Invalid function name \"#{name}\".")
|
41
|
+
end
|
41
42
|
end
|
42
43
|
end
|
43
44
|
end
|
data/lib/sass/tree/node.rb
CHANGED
@@ -69,7 +69,7 @@ module Sass
|
|
69
69
|
|
70
70
|
# The line of the document on which this node appeared.
|
71
71
|
#
|
72
|
-
# @return [
|
72
|
+
# @return [Fixnum]
|
73
73
|
attr_accessor :line
|
74
74
|
|
75
75
|
# The source range in the document on which this node appeared.
|
@@ -83,15 +83,13 @@ module Sass
|
|
83
83
|
attr_writer :filename
|
84
84
|
|
85
85
|
# The options hash for the node.
|
86
|
-
# See {file:SASS_REFERENCE.md#
|
86
|
+
# See {file:SASS_REFERENCE.md#options the Sass options documentation}.
|
87
87
|
#
|
88
88
|
# @return [{Symbol => Object}]
|
89
89
|
attr_reader :options
|
90
90
|
|
91
91
|
def initialize
|
92
92
|
@children = []
|
93
|
-
@filename = nil
|
94
|
-
@options = nil
|
95
93
|
end
|
96
94
|
|
97
95
|
# Sets the options hash for the node and all its children.
|
@@ -151,7 +149,7 @@ module Sass
|
|
151
149
|
# @return [Boolean]
|
152
150
|
def invisible?; false; end
|
153
151
|
|
154
|
-
# The output style. See {file:SASS_REFERENCE.md#
|
152
|
+
# The output style. See {file:SASS_REFERENCE.md#options the Sass options documentation}.
|
155
153
|
#
|
156
154
|
# @return [Symbol]
|
157
155
|
def style
|
data/lib/sass/tree/prop_node.rb
CHANGED
@@ -20,11 +20,7 @@ module Sass::Tree
|
|
20
20
|
|
21
21
|
# The value of the property.
|
22
22
|
#
|
23
|
-
#
|
24
|
-
# CSS variables, it will contain multiple strings and nodes representing
|
25
|
-
# interpolation. Any adjacent strings will be merged together.
|
26
|
-
#
|
27
|
-
# @return [Array<String, Sass::Script::Tree::Node>]
|
23
|
+
# @return [Sass::Script::Tree::Node]
|
28
24
|
attr_accessor :value
|
29
25
|
|
30
26
|
# The value of the property
|
@@ -43,7 +39,7 @@ module Sass::Tree
|
|
43
39
|
# * This is a child property of another property
|
44
40
|
# * The parent property has a value, and thus will be rendered
|
45
41
|
#
|
46
|
-
# @return [
|
42
|
+
# @return [Fixnum]
|
47
43
|
attr_accessor :tabs
|
48
44
|
|
49
45
|
# The source range in which the property name appears.
|
@@ -56,22 +52,14 @@ module Sass::Tree
|
|
56
52
|
# @return [Sass::Source::Range]
|
57
53
|
attr_accessor :value_source_range
|
58
54
|
|
59
|
-
# Whether this represents a CSS custom property.
|
60
|
-
#
|
61
|
-
# @return [Boolean]
|
62
|
-
def custom_property?
|
63
|
-
name.first.is_a?(String) && name.first.start_with?("--")
|
64
|
-
end
|
65
|
-
|
66
55
|
# @param name [Array<String, Sass::Script::Tree::Node>] See \{#name}
|
67
|
-
# @param value [
|
56
|
+
# @param value [Sass::Script::Tree::Node] See \{#value}
|
68
57
|
# @param prop_syntax [Symbol] `:new` if this property uses `a: b`-style syntax,
|
69
58
|
# `:old` if it uses `:a b`-style syntax
|
70
59
|
def initialize(name, value, prop_syntax)
|
71
60
|
@name = Sass::Util.strip_string_array(
|
72
61
|
Sass::Util.merge_adjacent_strings(name))
|
73
|
-
@value =
|
74
|
-
@value = Sass::Util.strip_string_array(@value) unless custom_property?
|
62
|
+
@value = value
|
75
63
|
@tabs = 0
|
76
64
|
@prop_syntax = prop_syntax
|
77
65
|
super()
|
@@ -93,10 +81,9 @@ module Sass::Tree
|
|
93
81
|
# @return [String] The message
|
94
82
|
def pseudo_class_selector_message
|
95
83
|
if @prop_syntax == :new ||
|
96
|
-
|
97
|
-
!value.
|
98
|
-
!value.
|
99
|
-
!value.first.value.value.empty?
|
84
|
+
!value.is_a?(Sass::Script::Tree::Literal) ||
|
85
|
+
!value.value.is_a?(Sass::Script::Value::String) ||
|
86
|
+
!value.value.value.empty?
|
100
87
|
return ""
|
101
88
|
end
|
102
89
|
|
@@ -111,52 +98,74 @@ module Sass::Tree
|
|
111
98
|
# @param fmt [Symbol] `:scss` or `:sass`.
|
112
99
|
def declaration(opts = {:old => @prop_syntax == :old}, fmt = :sass)
|
113
100
|
name = self.name.map {|n| n.is_a?(String) ? n : n.to_sass(opts)}.join
|
114
|
-
value = self.value.map {|n| n.is_a?(String) ? n : n.to_sass(opts)}.join
|
115
|
-
value = "(#{value})" if value_needs_parens?
|
116
|
-
|
117
101
|
if name[0] == ?:
|
118
|
-
raise Sass::SyntaxError.new("The \"#{name}: #{value}\"" +
|
102
|
+
raise Sass::SyntaxError.new("The \"#{name}: #{self.class.val_to_sass(value, opts)}\"" +
|
119
103
|
" hack is not allowed in the Sass indented syntax")
|
120
104
|
end
|
121
105
|
|
122
|
-
# The indented syntax doesn't support newlines in custom property values,
|
123
|
-
# but we can losslessly convert them to spaces instead.
|
124
|
-
value = value.tr("\n", " ") if fmt == :sass
|
125
|
-
|
126
106
|
old = opts[:old] && fmt == :sass
|
127
|
-
|
107
|
+
initial = old ? ':' : ''
|
108
|
+
mid = old ? '' : ':'
|
109
|
+
"#{initial}#{name}#{mid} #{self.class.val_to_sass(value, opts)}".rstrip
|
128
110
|
end
|
129
111
|
|
130
112
|
# A property node is invisible if its value is empty.
|
131
113
|
#
|
132
114
|
# @return [Boolean]
|
133
115
|
def invisible?
|
134
|
-
|
116
|
+
resolved_value.empty?
|
135
117
|
end
|
136
118
|
|
137
119
|
private
|
138
120
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
root.is_a?(Sass::Script::Tree::Operation) &&
|
146
|
-
root.operator == :div &&
|
147
|
-
root.operand1.is_a?(Sass::Script::Tree::Literal) &&
|
148
|
-
root.operand1.value.is_a?(Sass::Script::Value::Number) &&
|
149
|
-
root.operand1.value.original.nil? &&
|
150
|
-
root.operand2.is_a?(Sass::Script::Tree::Literal) &&
|
151
|
-
root.operand2.value.is_a?(Sass::Script::Value::Number) &&
|
152
|
-
root.operand2.value.original.nil?
|
121
|
+
def check!
|
122
|
+
if @options[:property_syntax] && @options[:property_syntax] != @prop_syntax
|
123
|
+
raise Sass::SyntaxError.new(
|
124
|
+
"Illegal property syntax: can't use #{@prop_syntax} syntax when " +
|
125
|
+
":property_syntax => #{@options[:property_syntax].inspect} is set.")
|
126
|
+
end
|
153
127
|
end
|
154
128
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
129
|
+
class << self
|
130
|
+
# @private
|
131
|
+
def val_to_sass(value, opts)
|
132
|
+
val_to_sass_comma(value, opts).to_sass(opts)
|
133
|
+
end
|
134
|
+
|
135
|
+
private
|
136
|
+
|
137
|
+
def val_to_sass_comma(node, opts)
|
138
|
+
return node unless node.is_a?(Sass::Script::Tree::Operation)
|
139
|
+
return val_to_sass_concat(node, opts) unless node.operator == :comma
|
140
|
+
|
141
|
+
Sass::Script::Tree::Operation.new(
|
142
|
+
val_to_sass_concat(node.operand1, opts),
|
143
|
+
val_to_sass_comma(node.operand2, opts),
|
144
|
+
node.operator)
|
145
|
+
end
|
146
|
+
|
147
|
+
def val_to_sass_concat(node, opts)
|
148
|
+
return node unless node.is_a?(Sass::Script::Tree::Operation)
|
149
|
+
return val_to_sass_div(node, opts) unless node.operator == :space
|
150
|
+
|
151
|
+
Sass::Script::Tree::Operation.new(
|
152
|
+
val_to_sass_div(node.operand1, opts),
|
153
|
+
val_to_sass_concat(node.operand2, opts),
|
154
|
+
node.operator)
|
155
|
+
end
|
156
|
+
|
157
|
+
def val_to_sass_div(node, opts)
|
158
|
+
unless node.is_a?(Sass::Script::Tree::Operation) && node.operator == :div &&
|
159
|
+
node.operand1.is_a?(Sass::Script::Tree::Literal) &&
|
160
|
+
node.operand1.value.is_a?(Sass::Script::Value::Number) &&
|
161
|
+
node.operand2.is_a?(Sass::Script::Tree::Literal) &&
|
162
|
+
node.operand2.value.is_a?(Sass::Script::Value::Number) &&
|
163
|
+
(!node.operand1.value.original || !node.operand2.value.original)
|
164
|
+
return node
|
165
|
+
end
|
166
|
+
|
167
|
+
Sass::Script::Value::String.new("(#{node.to_sass(opts)})")
|
168
|
+
end
|
160
169
|
end
|
161
170
|
end
|
162
171
|
end
|
data/lib/sass/tree/rule_node.rb
CHANGED
@@ -40,7 +40,7 @@ module Sass::Tree
|
|
40
40
|
# * This is a child rule of another rule
|
41
41
|
# * The parent rule has properties, and thus will be rendered
|
42
42
|
#
|
43
|
-
# @return [
|
43
|
+
# @return [Fixnum]
|
44
44
|
attr_accessor :tabs
|
45
45
|
|
46
46
|
# The entire selector source range for this rule.
|
@@ -120,34 +120,27 @@ module Sass::Tree
|
|
120
120
|
#
|
121
121
|
# @return [{#to_s => #to_s}]
|
122
122
|
def debug_info
|
123
|
-
{:filename => filename &&
|
124
|
-
("file://" + URI::DEFAULT_PARSER.escape(File.expand_path(filename))),
|
123
|
+
{:filename => filename && ("file://" + Sass::Util.escape_uri(File.expand_path(filename))),
|
125
124
|
:line => line}
|
126
125
|
end
|
127
126
|
|
128
127
|
# A rule node is invisible if it has only placeholder selectors.
|
129
128
|
def invisible?
|
130
|
-
resolved_rules.members.all? {|seq| seq.
|
129
|
+
resolved_rules.members.all? {|seq| seq.has_placeholder?}
|
131
130
|
end
|
132
131
|
|
133
132
|
private
|
134
133
|
|
135
134
|
def try_to_parse_non_interpolated_rules
|
136
135
|
@parsed_rules = nil
|
137
|
-
return unless @rule.all? {|t| t.
|
136
|
+
return unless @rule.all? {|t| t.kind_of?(String)}
|
138
137
|
|
139
138
|
# We don't use real filename/line info because we don't have it yet.
|
140
139
|
# When we get it, we'll set it on the parsed rules if possible.
|
141
|
-
parser = nil
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
@parsed_rules = parser.parse_selector rescue nil
|
146
|
-
end
|
147
|
-
|
148
|
-
# If parsing produces a warning, throw away the result so we can parse
|
149
|
-
# later with the real filename info.
|
150
|
-
@parsed_rules = nil unless warnings.empty?
|
140
|
+
parser = Sass::SCSS::StaticParser.new(@rule.join.strip, nil, nil, 1)
|
141
|
+
# rubocop:disable RescueModifier
|
142
|
+
@parsed_rules = parser.parse_selector rescue nil
|
143
|
+
# rubocop:enable RescueModifier
|
151
144
|
end
|
152
145
|
end
|
153
146
|
end
|
@@ -4,8 +4,6 @@ class Sass::Tree::Visitors::CheckNesting < Sass::Tree::Visitors::Base
|
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
@parents = []
|
7
|
-
@parent = nil
|
8
|
-
@current_mixin_def = nil
|
9
7
|
end
|
10
8
|
|
11
9
|
def visit(node)
|
@@ -31,7 +29,7 @@ class Sass::Tree::Visitors::CheckNesting < Sass::Tree::Visitors::Base
|
|
31
29
|
if parent.is_a?(Sass::Tree::AtRootNode) && parent.resolved_value
|
32
30
|
old_parents = @parents
|
33
31
|
@parents = @parents.reject {|p| parent.exclude_node?(p)}
|
34
|
-
@parent = @parents.reverse.
|
32
|
+
@parent = Sass::Util.enum_with_index(@parents.reverse).
|
35
33
|
find {|p, i| !transparent_parent?(p, @parents[-i - 2])}.first
|
36
34
|
|
37
35
|
begin
|
@@ -92,8 +90,9 @@ class Sass::Tree::Visitors::CheckNesting < Sass::Tree::Visitors::Base
|
|
92
90
|
|
93
91
|
VALID_EXTEND_PARENTS = [Sass::Tree::RuleNode, Sass::Tree::MixinDefNode, Sass::Tree::MixinNode]
|
94
92
|
def invalid_extend_parent?(parent, child)
|
95
|
-
|
96
|
-
|
93
|
+
unless is_any_of?(parent, VALID_EXTEND_PARENTS)
|
94
|
+
return "Extend directives may only be used within rules."
|
95
|
+
end
|
97
96
|
end
|
98
97
|
|
99
98
|
INVALID_IMPORT_PARENTS = CONTROL_NODES +
|
@@ -111,13 +110,15 @@ class Sass::Tree::Visitors::CheckNesting < Sass::Tree::Visitors::Base
|
|
111
110
|
end
|
112
111
|
|
113
112
|
def invalid_mixindef_parent?(parent, child)
|
114
|
-
|
115
|
-
|
113
|
+
unless (@parents.map {|p| p.class} & INVALID_IMPORT_PARENTS).empty?
|
114
|
+
return "Mixins may not be defined within control directives or other mixins."
|
115
|
+
end
|
116
116
|
end
|
117
117
|
|
118
118
|
def invalid_function_parent?(parent, child)
|
119
|
-
|
120
|
-
|
119
|
+
unless (@parents.map {|p| p.class} & INVALID_IMPORT_PARENTS).empty?
|
120
|
+
return "Functions may not be defined within control directives or other mixins."
|
121
|
+
end
|
121
122
|
end
|
122
123
|
|
123
124
|
VALID_FUNCTION_CHILDREN = [
|
@@ -125,24 +126,27 @@ class Sass::Tree::Visitors::CheckNesting < Sass::Tree::Visitors::Base
|
|
125
126
|
Sass::Tree::VariableNode, Sass::Tree::WarnNode, Sass::Tree::ErrorNode
|
126
127
|
] + CONTROL_NODES
|
127
128
|
def invalid_function_child?(parent, child)
|
128
|
-
|
129
|
-
|
129
|
+
unless is_any_of?(child, VALID_FUNCTION_CHILDREN)
|
130
|
+
"Functions can only contain variable declarations and control directives."
|
131
|
+
end
|
130
132
|
end
|
131
133
|
|
132
|
-
VALID_PROP_CHILDREN =
|
133
|
-
|
134
|
-
|
134
|
+
VALID_PROP_CHILDREN = CONTROL_NODES + [Sass::Tree::CommentNode,
|
135
|
+
Sass::Tree::PropNode,
|
136
|
+
Sass::Tree::MixinNode]
|
135
137
|
def invalid_prop_child?(parent, child)
|
136
|
-
|
137
|
-
|
138
|
+
unless is_any_of?(child, VALID_PROP_CHILDREN)
|
139
|
+
"Illegal nesting: Only properties may be nested beneath properties."
|
140
|
+
end
|
138
141
|
end
|
139
142
|
|
140
143
|
VALID_PROP_PARENTS = [Sass::Tree::RuleNode, Sass::Tree::KeyframeRuleNode, Sass::Tree::PropNode,
|
141
144
|
Sass::Tree::MixinDefNode, Sass::Tree::DirectiveNode, Sass::Tree::MixinNode]
|
142
145
|
def invalid_prop_parent?(parent, child)
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
+
unless is_any_of?(parent, VALID_PROP_PARENTS)
|
147
|
+
"Properties are only allowed within rules, directives, mixin includes, or other properties." +
|
148
|
+
child.pseudo_class_selector_message
|
149
|
+
end
|
146
150
|
end
|
147
151
|
|
148
152
|
def invalid_return_parent?(parent, child)
|
@@ -18,7 +18,6 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
|
|
18
18
|
@tabs = 0
|
19
19
|
# 2 spaces by default
|
20
20
|
@tab_chars = @options[:indent] || " "
|
21
|
-
@is_else = false
|
22
21
|
end
|
23
22
|
|
24
23
|
def visit_children(parent)
|
@@ -28,9 +27,9 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
|
|
28
27
|
res = visit_rule_level(parent.children)
|
29
28
|
|
30
29
|
if @format == :sass
|
31
|
-
"\n"
|
30
|
+
"\n" + res.rstrip + "\n"
|
32
31
|
else
|
33
|
-
" {\n" + res.rstrip + "\n#{@tab_chars * (@tabs - 1)}}\n"
|
32
|
+
" {\n" + res.rstrip + "\n#{ @tab_chars * (@tabs - 1)}}\n"
|
34
33
|
end
|
35
34
|
ensure
|
36
35
|
@tabs -= 1
|
@@ -48,14 +47,14 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
|
|
48
47
|
def visit_comment(node)
|
49
48
|
value = interp_to_src(node.value)
|
50
49
|
if @format == :sass
|
51
|
-
content = value.gsub(
|
50
|
+
content = value.gsub(/\*\/$/, '').rstrip
|
52
51
|
if content =~ /\A[ \t]/
|
53
52
|
# Re-indent SCSS comments like this:
|
54
53
|
# /* foo
|
55
54
|
# bar
|
56
55
|
# baz */
|
57
56
|
content.gsub!(/^/, ' ')
|
58
|
-
content.sub!(
|
57
|
+
content.sub!(/\A([ \t]*)\/\*/, '/*\1')
|
59
58
|
end
|
60
59
|
|
61
60
|
if content.include?("\n")
|
@@ -69,13 +68,13 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
|
|
69
68
|
end
|
70
69
|
end
|
71
70
|
|
72
|
-
content.gsub!(
|
71
|
+
content.gsub!(/\A\/\*/, '//') if node.type == :silent
|
73
72
|
content.gsub!(/^/, tab_str)
|
74
73
|
content = content.rstrip + "\n"
|
75
74
|
else
|
76
75
|
spaces = (@tab_chars * [@tabs - value[/^ */].size, 0].max)
|
77
76
|
content = if node.type == :silent
|
78
|
-
value.gsub(
|
77
|
+
value.gsub(/^[\/ ]\*/, '//').gsub(/ *\*\/$/, '')
|
79
78
|
else
|
80
79
|
value
|
81
80
|
end.gsub(/^/, spaces) + "\n"
|
@@ -105,12 +104,12 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
|
|
105
104
|
|
106
105
|
def visit_extend(node)
|
107
106
|
"#{tab_str}@extend #{selector_to_src(node.selector).lstrip}" +
|
108
|
-
"#{
|
107
|
+
"#{" !optional" if node.optional?}#{semi}\n"
|
109
108
|
end
|
110
109
|
|
111
110
|
def visit_for(node)
|
112
111
|
"#{tab_str}@for $#{dasherize(node.var)} from #{node.from.to_sass(@options)} " +
|
113
|
-
"#{node.exclusive ?
|
112
|
+
"#{node.exclusive ? "to" : "through"} #{node.to.to_sass(@options)}#{yield}"
|
114
113
|
end
|
115
114
|
|
116
115
|
def visit_function(node)
|
@@ -203,7 +202,8 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
|
|
203
202
|
|
204
203
|
unless node.args.empty? && node.keywords.empty? && node.splat.nil?
|
205
204
|
args = node.args.map(&arg_to_sass)
|
206
|
-
keywords = node.keywords.as_stored.
|
205
|
+
keywords = Sass::Util.hash_to_a(node.keywords.as_stored).
|
206
|
+
map {|k, v| "$#{dasherize(k)}: #{arg_to_sass[v]}"}
|
207
207
|
|
208
208
|
if node.splat
|
209
209
|
splat = "#{arg_to_sass[node.splat]}..."
|
@@ -280,7 +280,7 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
|
|
280
280
|
# Visit rule-level nodes and return their conversion with appropriate
|
281
281
|
# whitespace added.
|
282
282
|
def visit_rule_level(nodes)
|
283
|
-
(nodes + [nil]
|
283
|
+
Sass::Util.enum_cons(nodes + [nil], 2).map do |child, nxt|
|
284
284
|
visit(child) +
|
285
285
|
if nxt &&
|
286
286
|
(child.is_a?(Sass::Tree::CommentNode) && child.line + child.lines + 1 == nxt.line) ||
|
@@ -288,9 +288,7 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
|
|
288
288
|
child.line + 1 == nxt.line) ||
|
289
289
|
(child.is_a?(Sass::Tree::VariableNode) && nxt.is_a?(Sass::Tree::VariableNode) &&
|
290
290
|
child.line + 1 == nxt.line) ||
|
291
|
-
(child.is_a?(Sass::Tree::PropNode) && nxt.is_a?(Sass::Tree::PropNode))
|
292
|
-
(child.is_a?(Sass::Tree::MixinNode) && nxt.is_a?(Sass::Tree::MixinNode) &&
|
293
|
-
child.line + 1 == nxt.line)
|
291
|
+
(child.is_a?(Sass::Tree::PropNode) && nxt.is_a?(Sass::Tree::PropNode))
|
294
292
|
""
|
295
293
|
else
|
296
294
|
"\n"
|
@@ -342,7 +340,7 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
|
|
342
340
|
|
343
341
|
def dasherize(s)
|
344
342
|
if @options[:dasherize]
|
345
|
-
s.
|
343
|
+
s.gsub('_', '-')
|
346
344
|
else
|
347
345
|
s
|
348
346
|
end
|