sass 3.1.21 → 3.2.0.alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -4
- data/REVISION +1 -1
- data/Rakefile +6 -15
- data/VERSION +1 -1
- data/VERSION_NAME +1 -1
- data/lib/sass.rb +0 -1
- data/lib/sass/cache_stores/base.rb +1 -3
- data/lib/sass/cache_stores/filesystem.rb +0 -3
- data/lib/sass/css.rb +49 -145
- data/lib/sass/engine.rb +23 -47
- data/lib/sass/environment.rb +5 -30
- data/lib/sass/exec.rb +7 -30
- data/lib/sass/importers/base.rb +1 -2
- data/lib/sass/importers/filesystem.rb +13 -18
- data/lib/sass/less.rb +1 -1
- data/lib/sass/plugin.rb +8 -4
- data/lib/sass/plugin/compiler.rb +67 -93
- data/lib/sass/plugin/configuration.rb +2 -0
- data/lib/sass/plugin/staleness_checker.rb +4 -14
- data/lib/sass/repl.rb +3 -2
- data/lib/sass/script.rb +1 -0
- data/lib/sass/script/color.rb +9 -4
- data/lib/sass/script/funcall.rb +3 -16
- data/lib/sass/script/functions.rb +55 -98
- data/lib/sass/script/interpolation.rb +0 -9
- data/lib/sass/script/lexer.rb +4 -2
- data/lib/sass/script/list.rb +0 -8
- data/lib/sass/script/literal.rb +20 -5
- data/lib/sass/script/node.rb +0 -8
- data/lib/sass/script/number.rb +11 -35
- data/lib/sass/script/operation.rb +0 -16
- data/lib/sass/script/parser.rb +5 -12
- data/lib/sass/script/string_interpolation.rb +0 -9
- data/lib/sass/script/unary_operation.rb +0 -7
- data/lib/sass/script/variable.rb +1 -5
- data/lib/sass/scss/parser.rb +54 -191
- data/lib/sass/scss/rx.rb +3 -15
- data/lib/sass/scss/static_parser.rb +3 -3
- data/lib/sass/selector.rb +3 -15
- data/lib/sass/selector/abstract_sequence.rb +2 -11
- data/lib/sass/selector/comma_sequence.rb +3 -8
- data/lib/sass/selector/sequence.rb +11 -74
- data/lib/sass/selector/simple.rb +1 -7
- data/lib/sass/selector/simple_sequence.rb +8 -28
- data/lib/sass/shared.rb +5 -3
- data/lib/sass/tree/comment_node.rb +12 -25
- data/lib/sass/tree/debug_node.rb +1 -1
- data/lib/sass/tree/directive_node.rb +0 -5
- data/lib/sass/tree/each_node.rb +1 -1
- data/lib/sass/tree/extend_node.rb +1 -1
- data/lib/sass/tree/for_node.rb +2 -2
- data/lib/sass/tree/function_node.rb +1 -1
- data/lib/sass/tree/if_node.rb +14 -1
- data/lib/sass/tree/media_node.rb +4 -4
- data/lib/sass/tree/mixin_def_node.rb +1 -1
- data/lib/sass/tree/mixin_node.rb +2 -2
- data/lib/sass/tree/node.rb +26 -10
- data/lib/sass/tree/return_node.rb +1 -1
- data/lib/sass/tree/root_node.rb +1 -1
- data/lib/sass/tree/rule_node.rb +11 -9
- data/lib/sass/tree/variable_node.rb +1 -1
- data/lib/sass/tree/visitors/base.rb +1 -1
- data/lib/sass/tree/visitors/check_nesting.rb +36 -29
- data/lib/sass/tree/visitors/convert.rb +9 -16
- data/lib/sass/tree/visitors/cssize.rb +9 -40
- data/lib/sass/tree/visitors/perform.rb +23 -79
- data/lib/sass/tree/visitors/to_css.rb +21 -23
- data/lib/sass/tree/warn_node.rb +1 -1
- data/lib/sass/tree/while_node.rb +1 -1
- data/lib/sass/util.rb +9 -147
- data/lib/sass/version.rb +0 -14
- data/test/sass/cache_test.rb +0 -15
- data/test/sass/conversion_test.rb +8 -50
- data/test/sass/css2sass_test.rb +0 -33
- data/test/sass/engine_test.rb +32 -283
- data/test/sass/extend_test.rb +0 -315
- data/test/sass/functions_test.rb +23 -60
- data/test/sass/importer_test.rb +0 -110
- data/test/sass/more_results/more_import.css +2 -2
- data/test/sass/plugin_test.rb +13 -40
- data/test/sass/results/import.css +2 -2
- data/test/sass/results/import_charset.css +0 -1
- data/test/sass/results/import_charset_1_8.css +0 -1
- data/test/sass/results/import_charset_ibm866.css +0 -1
- data/test/sass/results/scss_import.css +2 -2
- data/test/sass/results/units.css +1 -1
- data/test/sass/script_conversion_test.rb +0 -2
- data/test/sass/script_test.rb +4 -28
- data/test/sass/scss/css_test.rb +1 -79
- data/test/sass/scss/scss_test.rb +16 -96
- data/test/sass/templates/import_charset.sass +0 -2
- data/test/sass/templates/import_charset_1_8.sass +0 -2
- data/test/sass/templates/import_charset_ibm866.sass +0 -2
- data/test/sass/test_helper.rb +1 -1
- data/test/sass/util_test.rb +0 -28
- data/test/test_helper.rb +0 -2
- data/vendor/{listen → fssm}/LICENSE +1 -1
- data/vendor/fssm/README.markdown +55 -0
- data/vendor/fssm/Rakefile +59 -0
- data/vendor/fssm/VERSION.yml +5 -0
- data/vendor/fssm/example.rb +9 -0
- data/vendor/fssm/fssm.gemspec +77 -0
- data/vendor/fssm/lib/fssm.rb +33 -0
- data/vendor/fssm/lib/fssm/backends/fsevents.rb +36 -0
- data/vendor/fssm/lib/fssm/backends/inotify.rb +26 -0
- data/vendor/fssm/lib/fssm/backends/polling.rb +25 -0
- data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +131 -0
- data/vendor/fssm/lib/fssm/monitor.rb +26 -0
- data/vendor/fssm/lib/fssm/path.rb +91 -0
- data/vendor/fssm/lib/fssm/pathname.rb +502 -0
- data/vendor/fssm/lib/fssm/state/directory.rb +57 -0
- data/vendor/fssm/lib/fssm/state/file.rb +24 -0
- data/vendor/fssm/lib/fssm/support.rb +63 -0
- data/vendor/fssm/lib/fssm/tree.rb +176 -0
- data/vendor/fssm/profile/prof-cache.rb +40 -0
- data/vendor/fssm/profile/prof-fssm-pathname.html +1231 -0
- data/vendor/fssm/profile/prof-pathname.rb +68 -0
- data/vendor/fssm/profile/prof-plain-pathname.html +988 -0
- data/vendor/fssm/profile/prof.html +2379 -0
- data/vendor/fssm/spec/path_spec.rb +75 -0
- data/vendor/fssm/spec/root/duck/quack.txt +0 -0
- data/vendor/fssm/spec/root/file.css +0 -0
- data/vendor/fssm/spec/root/file.rb +0 -0
- data/vendor/fssm/spec/root/file.yml +0 -0
- data/vendor/fssm/spec/root/moo/cow.txt +0 -0
- data/vendor/fssm/spec/spec_helper.rb +14 -0
- metadata +246 -281
- data/VERSION_DATE +0 -1
- data/lib/sass/logger.rb +0 -15
- data/lib/sass/logger/base.rb +0 -32
- data/lib/sass/logger/log_level.rb +0 -49
- data/lib/sass/tree/visitors/deep_copy.rb +0 -87
- data/lib/sass/tree/visitors/extend.rb +0 -42
- data/lib/sass/tree/visitors/set_options.rb +0 -97
- data/lib/sass/util/multibyte_string_scanner.rb +0 -134
- data/test/Gemfile +0 -4
- data/test/Gemfile.lock +0 -19
- data/test/sass/fixtures/test_staleness_check_across_importers.css +0 -1
- data/test/sass/fixtures/test_staleness_check_across_importers.scss +0 -1
- data/test/sass/logger_test.rb +0 -58
- data/test/sass/templates/_double_import_loop2.sass +0 -1
- data/test/sass/templates/bork5.sass +0 -3
- data/test/sass/templates/double_import_loop1.sass +0 -1
- data/test/sass/templates/nested_bork5.sass +0 -2
- data/test/sass/templates/single_import_loop.sass +0 -1
- data/test/sass/util/multibyte_string_scanner_test.rb +0 -147
- data/vendor/listen/CHANGELOG.md +0 -147
- data/vendor/listen/Gemfile +0 -23
- data/vendor/listen/Guardfile +0 -8
- data/vendor/listen/README.md +0 -312
- data/vendor/listen/Rakefile +0 -47
- data/vendor/listen/Vagrantfile +0 -96
- data/vendor/listen/lib/listen.rb +0 -38
- data/vendor/listen/lib/listen/adapter.rb +0 -167
- data/vendor/listen/lib/listen/adapters/darwin.rb +0 -84
- data/vendor/listen/lib/listen/adapters/linux.rb +0 -110
- data/vendor/listen/lib/listen/adapters/polling.rb +0 -66
- data/vendor/listen/lib/listen/adapters/windows.rb +0 -81
- data/vendor/listen/lib/listen/directory_record.rb +0 -318
- data/vendor/listen/lib/listen/listener.rb +0 -203
- data/vendor/listen/lib/listen/multi_listener.rb +0 -121
- data/vendor/listen/lib/listen/turnstile.rb +0 -28
- data/vendor/listen/lib/listen/version.rb +0 -3
- data/vendor/listen/listen.gemspec +0 -26
- data/vendor/listen/spec/listen/adapter_spec.rb +0 -142
- data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -31
- data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -41
- data/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
- data/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -24
- data/vendor/listen/spec/listen/directory_record_spec.rb +0 -1138
- data/vendor/listen/spec/listen/listener_spec.rb +0 -155
- data/vendor/listen/spec/listen/multi_listener_spec.rb +0 -156
- data/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
- data/vendor/listen/spec/listen_spec.rb +0 -73
- data/vendor/listen/spec/spec_helper.rb +0 -18
- data/vendor/listen/spec/support/adapter_helper.rb +0 -716
- data/vendor/listen/spec/support/directory_record_helper.rb +0 -55
- data/vendor/listen/spec/support/fixtures_helper.rb +0 -29
- data/vendor/listen/spec/support/listeners_helper.rb +0 -144
- data/vendor/listen/spec/support/platform_helper.rb +0 -11
data/lib/sass/tree/debug_node.rb
CHANGED
data/lib/sass/tree/each_node.rb
CHANGED
data/lib/sass/tree/for_node.rb
CHANGED
@@ -11,11 +11,11 @@ module Sass::Tree
|
|
11
11
|
|
12
12
|
# The parse tree for the initial expression.
|
13
13
|
# @return [Script::Node]
|
14
|
-
|
14
|
+
attr_reader :from
|
15
15
|
|
16
16
|
# The parse tree for the final expression.
|
17
17
|
# @return [Script::Node]
|
18
|
-
|
18
|
+
attr_reader :to
|
19
19
|
|
20
20
|
# Whether to include `to` in the loop or stop just before.
|
21
21
|
# @return [Boolean]
|
@@ -13,7 +13,7 @@ module Sass
|
|
13
13
|
# the default value of the argument
|
14
14
|
#
|
15
15
|
# @return [Array<Script::Node>]
|
16
|
-
|
16
|
+
attr_reader :args
|
17
17
|
|
18
18
|
# @param name [String] The function name
|
19
19
|
# @param args [Array<(Script::Node, Script::Node)>] The arguments for the function.
|
data/lib/sass/tree/if_node.rb
CHANGED
@@ -13,7 +13,7 @@ module Sass::Tree
|
|
13
13
|
# If this is nil, this is an `@else` node, not an `@else if`.
|
14
14
|
#
|
15
15
|
# @return [Script::Expr]
|
16
|
-
|
16
|
+
attr_reader :expr
|
17
17
|
|
18
18
|
# The next {IfNode} in the if-else list, or `nil`.
|
19
19
|
#
|
@@ -35,6 +35,12 @@ module Sass::Tree
|
|
35
35
|
@last_else = node
|
36
36
|
end
|
37
37
|
|
38
|
+
# @see Node#options=
|
39
|
+
def options=(options)
|
40
|
+
super
|
41
|
+
self.else.options = options if self.else
|
42
|
+
end
|
43
|
+
|
38
44
|
def _dump(f)
|
39
45
|
Marshal.dump([self.expr, self.else, self.children])
|
40
46
|
end
|
@@ -48,5 +54,12 @@ module Sass::Tree
|
|
48
54
|
node.else ? node.else.instance_variable_get('@last_else') : node)
|
49
55
|
node
|
50
56
|
end
|
57
|
+
|
58
|
+
# @see Node#deep_copy
|
59
|
+
def deep_copy
|
60
|
+
node = super
|
61
|
+
node.else = self.else.deep_copy if self.else
|
62
|
+
node
|
63
|
+
end
|
51
64
|
end
|
52
65
|
end
|
data/lib/sass/tree/media_node.rb
CHANGED
@@ -6,9 +6,9 @@ module Sass::Tree
|
|
6
6
|
#
|
7
7
|
# @see Sass::Tree
|
8
8
|
class MediaNode < DirectiveNode
|
9
|
-
# The media query
|
9
|
+
# The media query (e.g. `print` or `screen`).
|
10
10
|
#
|
11
|
-
# @return [
|
11
|
+
# @return [String]
|
12
12
|
attr_accessor :query
|
13
13
|
|
14
14
|
# @see RuleNode#tabs
|
@@ -17,7 +17,7 @@ module Sass::Tree
|
|
17
17
|
# @see RuleNode#group_end
|
18
18
|
attr_accessor :group_end
|
19
19
|
|
20
|
-
# @param query [
|
20
|
+
# @param query [String] See \{#query}
|
21
21
|
def initialize(query)
|
22
22
|
@query = query
|
23
23
|
@tabs = 0
|
@@ -26,7 +26,7 @@ module Sass::Tree
|
|
26
26
|
|
27
27
|
# @see DirectiveNode#value
|
28
28
|
def value
|
29
|
-
"@media #{query
|
29
|
+
"@media #{query}"
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -13,7 +13,7 @@ module Sass
|
|
13
13
|
# and the parse tree for the default value of the argument.
|
14
14
|
#
|
15
15
|
# @return [Array<(Script::Node, Script::Node)>]
|
16
|
-
|
16
|
+
attr_reader :args
|
17
17
|
|
18
18
|
# @param name [String] The mixin name
|
19
19
|
# @param args [Array<(Script::Node, Script::Node)>] See \{#args}
|
data/lib/sass/tree/mixin_node.rb
CHANGED
@@ -13,11 +13,11 @@ module Sass::Tree
|
|
13
13
|
|
14
14
|
# The arguments to the mixin.
|
15
15
|
# @return [Array<Script::Node>]
|
16
|
-
|
16
|
+
attr_reader :args
|
17
17
|
|
18
18
|
# A hash from keyword argument names to values.
|
19
19
|
# @return [{String => Script::Node}]
|
20
|
-
|
20
|
+
attr_reader :keywords
|
21
21
|
|
22
22
|
# @param name [String] The name of the mixin
|
23
23
|
# @param args [Array<Script::Node>] See \{#args}
|
data/lib/sass/tree/node.rb
CHANGED
@@ -65,7 +65,8 @@ module Sass
|
|
65
65
|
# @param options [{Symbol => Object}] The options
|
66
66
|
# @see #options
|
67
67
|
def options=(options)
|
68
|
-
|
68
|
+
children.each {|c| c.options = options}
|
69
|
+
@options = options
|
69
70
|
end
|
70
71
|
|
71
72
|
# @private
|
@@ -132,12 +133,25 @@ module Sass
|
|
132
133
|
Sass::Tree::Visitors::ToCss.visit(self)
|
133
134
|
end
|
134
135
|
|
135
|
-
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
|
139
|
-
|
140
|
-
|
136
|
+
# Converts a static CSS tree (e.g. the output of \{Tree::Visitors::Cssize})
|
137
|
+
# into another static CSS tree,
|
138
|
+
# with the given extensions applied to all relevant {RuleNode}s.
|
139
|
+
#
|
140
|
+
# @todo Link this to the reference documentation on `@extend`
|
141
|
+
# when such a thing exists.
|
142
|
+
#
|
143
|
+
# @param extends [Sass::Util::SubsetMap{Selector::Simple => Selector::Sequence}]
|
144
|
+
# The extensions to perform on this tree
|
145
|
+
# @return [Tree::Node] The resulting tree of static CSS nodes.
|
146
|
+
# @raise [Sass::SyntaxError] Only if there's a programmer error
|
147
|
+
# and this is not a static CSS tree
|
148
|
+
def do_extend(extends)
|
149
|
+
node = dup
|
150
|
+
node.children = children.map {|c| c.do_extend(extends)}
|
151
|
+
node
|
152
|
+
rescue Sass::SyntaxError => e
|
153
|
+
e.modify_backtrace(:filename => filename, :line => line)
|
154
|
+
raise e
|
141
155
|
end
|
142
156
|
|
143
157
|
# Iterates through each node in the tree rooted at this node
|
@@ -145,9 +159,9 @@ module Sass
|
|
145
159
|
#
|
146
160
|
# @yield node
|
147
161
|
# @yieldparam node [Node] a node in the tree
|
148
|
-
def each
|
162
|
+
def each(&block)
|
149
163
|
yield self
|
150
|
-
children.each {|c| c.each
|
164
|
+
children.each {|c| c.each(&block)}
|
151
165
|
end
|
152
166
|
|
153
167
|
# Converts a node to Sass code that will generate it.
|
@@ -171,7 +185,9 @@ module Sass
|
|
171
185
|
#
|
172
186
|
# @return [Node]
|
173
187
|
def deep_copy
|
174
|
-
|
188
|
+
node = dup
|
189
|
+
node.children = children.map {|c| c.deep_copy}
|
190
|
+
node
|
175
191
|
end
|
176
192
|
|
177
193
|
protected
|
data/lib/sass/tree/root_node.rb
CHANGED
@@ -20,7 +20,7 @@ module Sass
|
|
20
20
|
result = Visitors::Perform.visit(self)
|
21
21
|
Visitors::CheckNesting.visit(result) # Check again to validate mixins
|
22
22
|
result, extends = Visitors::Cssize.visit(result)
|
23
|
-
|
23
|
+
result = result.do_extend(extends) unless extends.empty?
|
24
24
|
result.to_s
|
25
25
|
end
|
26
26
|
end
|
data/lib/sass/tree/rule_node.rb
CHANGED
@@ -50,13 +50,6 @@ module Sass::Tree
|
|
50
50
|
# @return [Boolean]
|
51
51
|
attr_accessor :group_end
|
52
52
|
|
53
|
-
# The stack trace.
|
54
|
-
# This is only readable in a CSS tree as it is written during the perform step
|
55
|
-
# and only when the :trace_selectors option is set.
|
56
|
-
#
|
57
|
-
# @return [Array<String>]
|
58
|
-
attr_accessor :stack_trace
|
59
|
-
|
60
53
|
# @param rule [Array<String, Sass::Script::Node>]
|
61
54
|
# The CSS rule. See \{#rule}
|
62
55
|
def initialize(rule)
|
@@ -103,6 +96,15 @@ module Sass::Tree
|
|
103
96
|
last.is_a?(String) && last[-1] == ?,
|
104
97
|
end
|
105
98
|
|
99
|
+
# Extends this Rule's selector with the given `extends`.
|
100
|
+
#
|
101
|
+
# @see Node#do_extend
|
102
|
+
def do_extend(extends)
|
103
|
+
node = dup
|
104
|
+
node.resolved_rules = resolved_rules.do_extend(extends)
|
105
|
+
node
|
106
|
+
end
|
107
|
+
|
106
108
|
# A hash that will be associated with this rule in the CSS document
|
107
109
|
# if the {file:SASS_REFERENCE.md#debug_info-option `:debug_info` option} is enabled.
|
108
110
|
# This data is used by e.g. [the FireSass Firebug extension](https://addons.mozilla.org/en-US/firefox/addon/103988).
|
@@ -119,8 +121,8 @@ module Sass::Tree
|
|
119
121
|
if @rule.all? {|t| t.kind_of?(String)}
|
120
122
|
# We don't use real filename/line info because we don't have it yet.
|
121
123
|
# When we get it, we'll set it on the parsed rules if possible.
|
122
|
-
parser = Sass::SCSS::StaticParser.new(@rule.join.strip,
|
123
|
-
@parsed_rules = parser.parse_selector rescue nil
|
124
|
+
parser = Sass::SCSS::StaticParser.new(@rule.join.strip, 1)
|
125
|
+
@parsed_rules = parser.parse_selector('') rescue nil
|
124
126
|
end
|
125
127
|
end
|
126
128
|
end
|
@@ -33,7 +33,7 @@ module Sass::Tree::Visitors
|
|
33
33
|
# @return [Object] The return value of the `visit_*` method for this node.
|
34
34
|
def visit(node)
|
35
35
|
method = "visit_#{node_name node}"
|
36
|
-
if self.respond_to?(method
|
36
|
+
if self.respond_to?(method)
|
37
37
|
self.send(method, node) {visit_children(node)}
|
38
38
|
else
|
39
39
|
visit_children(node)
|
@@ -2,14 +2,13 @@
|
|
2
2
|
class Sass::Tree::Visitors::CheckNesting < Sass::Tree::Visitors::Base
|
3
3
|
protected
|
4
4
|
|
5
|
-
def initialize
|
6
|
-
@parents = []
|
7
|
-
end
|
8
|
-
|
9
5
|
def visit(node)
|
10
|
-
if error = @parent && (
|
11
|
-
|
12
|
-
|
6
|
+
if error = (@parent && (
|
7
|
+
try_send("invalid_#{node_name @parent}_child?", @parent, node) ||
|
8
|
+
try_send("invalid_#{node_name node}_parent?", @parent, node))) ||
|
9
|
+
(@real_parent && (
|
10
|
+
try_send("invalid_#{node_name @real_parent}_real_child?", @real_parent, node) ||
|
11
|
+
try_send("invalid_#{node_name node}_real_parent?", @real_parent, node)))
|
13
12
|
raise Sass::SyntaxError.new(error)
|
14
13
|
end
|
15
14
|
super
|
@@ -18,16 +17,16 @@ class Sass::Tree::Visitors::CheckNesting < Sass::Tree::Visitors::Base
|
|
18
17
|
raise e
|
19
18
|
end
|
20
19
|
|
21
|
-
|
22
|
-
|
20
|
+
PARENT_CLASSES = [ Sass::Tree::EachNode, Sass::Tree::ForNode, Sass::Tree::IfNode,
|
21
|
+
Sass::Tree::ImportNode, Sass::Tree::MixinNode, Sass::Tree::WhileNode]
|
23
22
|
def visit_children(parent)
|
24
23
|
old_parent = @parent
|
25
|
-
@parent = parent unless is_any_of?(parent,
|
26
|
-
@
|
24
|
+
@parent = parent unless is_any_of?(parent, PARENT_CLASSES)
|
25
|
+
old_real_parent, @real_parent = @real_parent, parent
|
27
26
|
super
|
28
27
|
ensure
|
29
28
|
@parent = old_parent
|
30
|
-
@
|
29
|
+
@real_parent = old_real_parent
|
31
30
|
end
|
32
31
|
|
33
32
|
def visit_root(node)
|
@@ -49,10 +48,10 @@ class Sass::Tree::Visitors::CheckNesting < Sass::Tree::Visitors::Base
|
|
49
48
|
"@charset may only be used at the root of a document." unless parent.is_a?(Sass::Tree::RootNode)
|
50
49
|
end
|
51
50
|
|
52
|
-
|
51
|
+
INVALID_EXTEND_PARENTS = [Sass::Tree::RuleNode, Sass::Tree::MixinDefNode]
|
53
52
|
def invalid_extend_parent?(parent, child)
|
54
|
-
unless is_any_of?(parent,
|
55
|
-
|
53
|
+
unless is_any_of?(parent, INVALID_EXTEND_PARENTS)
|
54
|
+
"Extend directives may only be used within rules."
|
56
55
|
end
|
57
56
|
end
|
58
57
|
|
@@ -60,19 +59,23 @@ class Sass::Tree::Visitors::CheckNesting < Sass::Tree::Visitors::Base
|
|
60
59
|
"Functions may only be defined at the root of a document." unless parent.is_a?(Sass::Tree::RootNode)
|
61
60
|
end
|
62
61
|
|
63
|
-
|
64
|
-
Sass::Tree::CommentNode, Sass::Tree::DebugNode, Sass::Tree::
|
65
|
-
Sass::Tree::
|
66
|
-
|
62
|
+
INVALID_FUNCTION_CHILDREN = [
|
63
|
+
Sass::Tree::CommentNode, Sass::Tree::DebugNode, Sass::Tree::EachNode,
|
64
|
+
Sass::Tree::ForNode, Sass::Tree::IfNode, Sass::Tree::ReturnNode,
|
65
|
+
Sass::Tree::VariableNode, Sass::Tree::WarnNode, Sass::Tree::WhileNode
|
66
|
+
]
|
67
67
|
def invalid_function_child?(parent, child)
|
68
|
-
unless is_any_of?(child,
|
68
|
+
unless is_any_of?(child, INVALID_FUNCTION_CHILDREN)
|
69
69
|
"Functions can only contain variable declarations and control directives."
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
INVALID_IMPORT_PARENTS =
|
73
|
+
INVALID_IMPORT_PARENTS = [
|
74
|
+
Sass::Tree::IfNode, Sass::Tree::ForNode, Sass::Tree::WhileNode,
|
75
|
+
Sass::Tree::EachNode, Sass::Tree::MixinDefNode
|
76
|
+
]
|
74
77
|
def invalid_import_parent?(parent, child)
|
75
|
-
|
78
|
+
if is_any_of?(@real_parent, INVALID_IMPORT_PARENTS)
|
76
79
|
return "Import directives may not be used within control directives or mixins."
|
77
80
|
end
|
78
81
|
return if parent.is_a?(Sass::Tree::RootNode)
|
@@ -87,21 +90,25 @@ class Sass::Tree::Visitors::CheckNesting < Sass::Tree::Visitors::Base
|
|
87
90
|
raise e
|
88
91
|
end
|
89
92
|
|
93
|
+
def invalid_import_real_parent?(parent, child)
|
94
|
+
|
95
|
+
end
|
96
|
+
|
90
97
|
def invalid_mixindef_parent?(parent, child)
|
91
98
|
"Mixins may only be defined at the root of a document." unless parent.is_a?(Sass::Tree::RootNode)
|
92
99
|
end
|
93
100
|
|
94
|
-
|
101
|
+
INVALID_PROP_CHILDREN = [Sass::Tree::CommentNode, Sass::Tree::PropNode]
|
95
102
|
def invalid_prop_child?(parent, child)
|
96
|
-
unless is_any_of?(child,
|
103
|
+
unless is_any_of?(child, INVALID_PROP_CHILDREN)
|
97
104
|
"Illegal nesting: Only properties may be nested beneath properties."
|
98
105
|
end
|
99
106
|
end
|
100
107
|
|
101
|
-
|
102
|
-
|
108
|
+
INVALID_PROP_PARENTS = [Sass::Tree::RuleNode, Sass::Tree::PropNode,
|
109
|
+
Sass::Tree::MixinDefNode, Sass::Tree::DirectiveNode]
|
103
110
|
def invalid_prop_parent?(parent, child)
|
104
|
-
unless is_any_of?(parent,
|
111
|
+
unless is_any_of?(parent, INVALID_PROP_PARENTS)
|
105
112
|
"Properties are only allowed within rules, directives, or other properties." + child.pseudo_class_selector_message
|
106
113
|
end
|
107
114
|
end
|
@@ -119,9 +126,9 @@ class Sass::Tree::Visitors::CheckNesting < Sass::Tree::Visitors::Base
|
|
119
126
|
return false
|
120
127
|
end
|
121
128
|
|
122
|
-
def try_send(method, *args)
|
129
|
+
def try_send(method, *args, &block)
|
123
130
|
return unless respond_to?(method)
|
124
|
-
send(method, *args)
|
131
|
+
send(method, *args, &block)
|
125
132
|
end
|
126
133
|
end
|
127
134
|
|
@@ -32,7 +32,7 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
|
|
32
32
|
visit(child) +
|
33
33
|
if nxt &&
|
34
34
|
(child.is_a?(Sass::Tree::CommentNode) &&
|
35
|
-
child.line + child.
|
35
|
+
child.line + child.value.count("\n") + 1 == nxt.line) ||
|
36
36
|
(child.is_a?(Sass::Tree::ImportNode) && nxt.is_a?(Sass::Tree::ImportNode) &&
|
37
37
|
child.line + 1 == nxt.line) ||
|
38
38
|
(child.is_a?(Sass::Tree::VariableNode) && nxt.is_a?(Sass::Tree::VariableNode) &&
|
@@ -49,13 +49,8 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def visit_comment(node)
|
52
|
-
value = node.value.map do |r|
|
53
|
-
next r if r.is_a?(String)
|
54
|
-
"\#{#{r.to_sass(@options)}}"
|
55
|
-
end.join
|
56
|
-
|
57
52
|
content = if @format == :sass
|
58
|
-
content = value.gsub(/\*\/$/, '').rstrip
|
53
|
+
content = node.value.gsub(/\*\/$/, '').rstrip
|
59
54
|
if content =~ /\A[ \t]/
|
60
55
|
# Re-indent SCSS comments like this:
|
61
56
|
# /* foo
|
@@ -83,11 +78,11 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
|
|
83
78
|
content.gsub!(/^/, tab_str)
|
84
79
|
content.rstrip + "\n"
|
85
80
|
else
|
86
|
-
spaces = (' ' * [@tabs - value[/^ */].size, 0].max)
|
81
|
+
spaces = (' ' * [@tabs - node.value[/^ */].size, 0].max)
|
87
82
|
content = if node.silent
|
88
|
-
value.gsub(/^[\/ ]\*/, '//').gsub(/ *\*\/$/, '')
|
83
|
+
node.value.gsub(/^[\/ ]\*/, '//').gsub(/ *\*\/$/, '')
|
89
84
|
else
|
90
|
-
value
|
85
|
+
node.value
|
91
86
|
end.gsub(/^/, spaces) + "\n"
|
92
87
|
content
|
93
88
|
end
|
@@ -138,7 +133,6 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
|
|
138
133
|
elsif node.expr; "else if"
|
139
134
|
else; "else"
|
140
135
|
end
|
141
|
-
@is_else = false
|
142
136
|
str = "#{tab_str}@#{name}"
|
143
137
|
str << " #{node.expr.to_sass(@options)}" if node.expr
|
144
138
|
str << yield
|
@@ -155,7 +149,7 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
|
|
155
149
|
end
|
156
150
|
|
157
151
|
def visit_media(node)
|
158
|
-
"#{tab_str}@media #{node.query
|
152
|
+
"#{tab_str}@media #{node.query}#{yield}"
|
159
153
|
end
|
160
154
|
|
161
155
|
def visit_mixindef(node)
|
@@ -178,8 +172,7 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
|
|
178
172
|
def visit_mixin(node)
|
179
173
|
unless node.args.empty? && node.keywords.empty?
|
180
174
|
args = node.args.map {|a| a.to_sass(@options)}.join(", ")
|
181
|
-
keywords =
|
182
|
-
map {|k, v| "$#{dasherize(k)}: #{v.to_sass(@options)}"}.join(', ')
|
175
|
+
keywords = node.keywords.map {|k, v| "$#{dasherize(k)}: #{v.to_sass(@options)}"}.join(', ')
|
183
176
|
arglist = "(#{args}#{', ' unless args.empty? || keywords.empty?}#{keywords})"
|
184
177
|
end
|
185
178
|
"#{tab_str}#{@format == :sass ? '+' : '@include '}#{dasherize(node.name)}#{arglist}#{semi}\n"
|
@@ -232,7 +225,7 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
|
|
232
225
|
def selector_to_sass(sel)
|
233
226
|
sel.map do |r|
|
234
227
|
if r.is_a?(String)
|
235
|
-
r.gsub(/(,
|
228
|
+
r.gsub(/(,[ \t]*)?\n\s*/) {$1 ? $1 + "\n" : " "}
|
236
229
|
else
|
237
230
|
"\#{#{r.to_sass(@options)}}"
|
238
231
|
end
|
@@ -241,7 +234,7 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
|
|
241
234
|
|
242
235
|
def selector_to_scss(sel)
|
243
236
|
sel.map {|r| r.is_a?(String) ? r : "\#{#{r.to_sass(@options)}}"}.
|
244
|
-
join.gsub(/^[ \t]*/, tab_str)
|
237
|
+
join.gsub(/^[ \t]*/, tab_str)
|
245
238
|
end
|
246
239
|
|
247
240
|
def semi
|