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.
Files changed (180) hide show
  1. data/README.md +5 -4
  2. data/REVISION +1 -1
  3. data/Rakefile +6 -15
  4. data/VERSION +1 -1
  5. data/VERSION_NAME +1 -1
  6. data/lib/sass.rb +0 -1
  7. data/lib/sass/cache_stores/base.rb +1 -3
  8. data/lib/sass/cache_stores/filesystem.rb +0 -3
  9. data/lib/sass/css.rb +49 -145
  10. data/lib/sass/engine.rb +23 -47
  11. data/lib/sass/environment.rb +5 -30
  12. data/lib/sass/exec.rb +7 -30
  13. data/lib/sass/importers/base.rb +1 -2
  14. data/lib/sass/importers/filesystem.rb +13 -18
  15. data/lib/sass/less.rb +1 -1
  16. data/lib/sass/plugin.rb +8 -4
  17. data/lib/sass/plugin/compiler.rb +67 -93
  18. data/lib/sass/plugin/configuration.rb +2 -0
  19. data/lib/sass/plugin/staleness_checker.rb +4 -14
  20. data/lib/sass/repl.rb +3 -2
  21. data/lib/sass/script.rb +1 -0
  22. data/lib/sass/script/color.rb +9 -4
  23. data/lib/sass/script/funcall.rb +3 -16
  24. data/lib/sass/script/functions.rb +55 -98
  25. data/lib/sass/script/interpolation.rb +0 -9
  26. data/lib/sass/script/lexer.rb +4 -2
  27. data/lib/sass/script/list.rb +0 -8
  28. data/lib/sass/script/literal.rb +20 -5
  29. data/lib/sass/script/node.rb +0 -8
  30. data/lib/sass/script/number.rb +11 -35
  31. data/lib/sass/script/operation.rb +0 -16
  32. data/lib/sass/script/parser.rb +5 -12
  33. data/lib/sass/script/string_interpolation.rb +0 -9
  34. data/lib/sass/script/unary_operation.rb +0 -7
  35. data/lib/sass/script/variable.rb +1 -5
  36. data/lib/sass/scss/parser.rb +54 -191
  37. data/lib/sass/scss/rx.rb +3 -15
  38. data/lib/sass/scss/static_parser.rb +3 -3
  39. data/lib/sass/selector.rb +3 -15
  40. data/lib/sass/selector/abstract_sequence.rb +2 -11
  41. data/lib/sass/selector/comma_sequence.rb +3 -8
  42. data/lib/sass/selector/sequence.rb +11 -74
  43. data/lib/sass/selector/simple.rb +1 -7
  44. data/lib/sass/selector/simple_sequence.rb +8 -28
  45. data/lib/sass/shared.rb +5 -3
  46. data/lib/sass/tree/comment_node.rb +12 -25
  47. data/lib/sass/tree/debug_node.rb +1 -1
  48. data/lib/sass/tree/directive_node.rb +0 -5
  49. data/lib/sass/tree/each_node.rb +1 -1
  50. data/lib/sass/tree/extend_node.rb +1 -1
  51. data/lib/sass/tree/for_node.rb +2 -2
  52. data/lib/sass/tree/function_node.rb +1 -1
  53. data/lib/sass/tree/if_node.rb +14 -1
  54. data/lib/sass/tree/media_node.rb +4 -4
  55. data/lib/sass/tree/mixin_def_node.rb +1 -1
  56. data/lib/sass/tree/mixin_node.rb +2 -2
  57. data/lib/sass/tree/node.rb +26 -10
  58. data/lib/sass/tree/return_node.rb +1 -1
  59. data/lib/sass/tree/root_node.rb +1 -1
  60. data/lib/sass/tree/rule_node.rb +11 -9
  61. data/lib/sass/tree/variable_node.rb +1 -1
  62. data/lib/sass/tree/visitors/base.rb +1 -1
  63. data/lib/sass/tree/visitors/check_nesting.rb +36 -29
  64. data/lib/sass/tree/visitors/convert.rb +9 -16
  65. data/lib/sass/tree/visitors/cssize.rb +9 -40
  66. data/lib/sass/tree/visitors/perform.rb +23 -79
  67. data/lib/sass/tree/visitors/to_css.rb +21 -23
  68. data/lib/sass/tree/warn_node.rb +1 -1
  69. data/lib/sass/tree/while_node.rb +1 -1
  70. data/lib/sass/util.rb +9 -147
  71. data/lib/sass/version.rb +0 -14
  72. data/test/sass/cache_test.rb +0 -15
  73. data/test/sass/conversion_test.rb +8 -50
  74. data/test/sass/css2sass_test.rb +0 -33
  75. data/test/sass/engine_test.rb +32 -283
  76. data/test/sass/extend_test.rb +0 -315
  77. data/test/sass/functions_test.rb +23 -60
  78. data/test/sass/importer_test.rb +0 -110
  79. data/test/sass/more_results/more_import.css +2 -2
  80. data/test/sass/plugin_test.rb +13 -40
  81. data/test/sass/results/import.css +2 -2
  82. data/test/sass/results/import_charset.css +0 -1
  83. data/test/sass/results/import_charset_1_8.css +0 -1
  84. data/test/sass/results/import_charset_ibm866.css +0 -1
  85. data/test/sass/results/scss_import.css +2 -2
  86. data/test/sass/results/units.css +1 -1
  87. data/test/sass/script_conversion_test.rb +0 -2
  88. data/test/sass/script_test.rb +4 -28
  89. data/test/sass/scss/css_test.rb +1 -79
  90. data/test/sass/scss/scss_test.rb +16 -96
  91. data/test/sass/templates/import_charset.sass +0 -2
  92. data/test/sass/templates/import_charset_1_8.sass +0 -2
  93. data/test/sass/templates/import_charset_ibm866.sass +0 -2
  94. data/test/sass/test_helper.rb +1 -1
  95. data/test/sass/util_test.rb +0 -28
  96. data/test/test_helper.rb +0 -2
  97. data/vendor/{listen → fssm}/LICENSE +1 -1
  98. data/vendor/fssm/README.markdown +55 -0
  99. data/vendor/fssm/Rakefile +59 -0
  100. data/vendor/fssm/VERSION.yml +5 -0
  101. data/vendor/fssm/example.rb +9 -0
  102. data/vendor/fssm/fssm.gemspec +77 -0
  103. data/vendor/fssm/lib/fssm.rb +33 -0
  104. data/vendor/fssm/lib/fssm/backends/fsevents.rb +36 -0
  105. data/vendor/fssm/lib/fssm/backends/inotify.rb +26 -0
  106. data/vendor/fssm/lib/fssm/backends/polling.rb +25 -0
  107. data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +131 -0
  108. data/vendor/fssm/lib/fssm/monitor.rb +26 -0
  109. data/vendor/fssm/lib/fssm/path.rb +91 -0
  110. data/vendor/fssm/lib/fssm/pathname.rb +502 -0
  111. data/vendor/fssm/lib/fssm/state/directory.rb +57 -0
  112. data/vendor/fssm/lib/fssm/state/file.rb +24 -0
  113. data/vendor/fssm/lib/fssm/support.rb +63 -0
  114. data/vendor/fssm/lib/fssm/tree.rb +176 -0
  115. data/vendor/fssm/profile/prof-cache.rb +40 -0
  116. data/vendor/fssm/profile/prof-fssm-pathname.html +1231 -0
  117. data/vendor/fssm/profile/prof-pathname.rb +68 -0
  118. data/vendor/fssm/profile/prof-plain-pathname.html +988 -0
  119. data/vendor/fssm/profile/prof.html +2379 -0
  120. data/vendor/fssm/spec/path_spec.rb +75 -0
  121. data/vendor/fssm/spec/root/duck/quack.txt +0 -0
  122. data/vendor/fssm/spec/root/file.css +0 -0
  123. data/vendor/fssm/spec/root/file.rb +0 -0
  124. data/vendor/fssm/spec/root/file.yml +0 -0
  125. data/vendor/fssm/spec/root/moo/cow.txt +0 -0
  126. data/vendor/fssm/spec/spec_helper.rb +14 -0
  127. metadata +246 -281
  128. data/VERSION_DATE +0 -1
  129. data/lib/sass/logger.rb +0 -15
  130. data/lib/sass/logger/base.rb +0 -32
  131. data/lib/sass/logger/log_level.rb +0 -49
  132. data/lib/sass/tree/visitors/deep_copy.rb +0 -87
  133. data/lib/sass/tree/visitors/extend.rb +0 -42
  134. data/lib/sass/tree/visitors/set_options.rb +0 -97
  135. data/lib/sass/util/multibyte_string_scanner.rb +0 -134
  136. data/test/Gemfile +0 -4
  137. data/test/Gemfile.lock +0 -19
  138. data/test/sass/fixtures/test_staleness_check_across_importers.css +0 -1
  139. data/test/sass/fixtures/test_staleness_check_across_importers.scss +0 -1
  140. data/test/sass/logger_test.rb +0 -58
  141. data/test/sass/templates/_double_import_loop2.sass +0 -1
  142. data/test/sass/templates/bork5.sass +0 -3
  143. data/test/sass/templates/double_import_loop1.sass +0 -1
  144. data/test/sass/templates/nested_bork5.sass +0 -2
  145. data/test/sass/templates/single_import_loop.sass +0 -1
  146. data/test/sass/util/multibyte_string_scanner_test.rb +0 -147
  147. data/vendor/listen/CHANGELOG.md +0 -147
  148. data/vendor/listen/Gemfile +0 -23
  149. data/vendor/listen/Guardfile +0 -8
  150. data/vendor/listen/README.md +0 -312
  151. data/vendor/listen/Rakefile +0 -47
  152. data/vendor/listen/Vagrantfile +0 -96
  153. data/vendor/listen/lib/listen.rb +0 -38
  154. data/vendor/listen/lib/listen/adapter.rb +0 -167
  155. data/vendor/listen/lib/listen/adapters/darwin.rb +0 -84
  156. data/vendor/listen/lib/listen/adapters/linux.rb +0 -110
  157. data/vendor/listen/lib/listen/adapters/polling.rb +0 -66
  158. data/vendor/listen/lib/listen/adapters/windows.rb +0 -81
  159. data/vendor/listen/lib/listen/directory_record.rb +0 -318
  160. data/vendor/listen/lib/listen/listener.rb +0 -203
  161. data/vendor/listen/lib/listen/multi_listener.rb +0 -121
  162. data/vendor/listen/lib/listen/turnstile.rb +0 -28
  163. data/vendor/listen/lib/listen/version.rb +0 -3
  164. data/vendor/listen/listen.gemspec +0 -26
  165. data/vendor/listen/spec/listen/adapter_spec.rb +0 -142
  166. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -31
  167. data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -41
  168. data/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
  169. data/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -24
  170. data/vendor/listen/spec/listen/directory_record_spec.rb +0 -1138
  171. data/vendor/listen/spec/listen/listener_spec.rb +0 -155
  172. data/vendor/listen/spec/listen/multi_listener_spec.rb +0 -156
  173. data/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
  174. data/vendor/listen/spec/listen_spec.rb +0 -73
  175. data/vendor/listen/spec/spec_helper.rb +0 -18
  176. data/vendor/listen/spec/support/adapter_helper.rb +0 -716
  177. data/vendor/listen/spec/support/directory_record_helper.rb +0 -55
  178. data/vendor/listen/spec/support/fixtures_helper.rb +0 -29
  179. data/vendor/listen/spec/support/listeners_helper.rb +0 -144
  180. data/vendor/listen/spec/support/platform_helper.rb +0 -11
@@ -6,7 +6,7 @@ module Sass
6
6
  class DebugNode < Node
7
7
  # The expression to print.
8
8
  # @return [Script::Node]
9
- attr_accessor :expr
9
+ attr_reader :expr
10
10
 
11
11
  # @param expr [Script::Node] The expression to print
12
12
  def initialize(expr)
@@ -19,10 +19,5 @@ module Sass::Tree
19
19
  @value = value
20
20
  super()
21
21
  end
22
-
23
- # @return [String] The name of the directive, including `@`.
24
- def name
25
- value.gsub(/ .*$/, '')
26
- end
27
22
  end
28
23
  end
@@ -11,7 +11,7 @@ module Sass::Tree
11
11
 
12
12
  # The parse tree for the list.
13
13
  # @param [Script::Node]
14
- attr_accessor :list
14
+ attr_reader :list
15
15
 
16
16
  # @param var [String] The name of the loop variable
17
17
  # @param list [Script::Node] The parse tree for the list
@@ -15,7 +15,7 @@ module Sass::Tree
15
15
  # representing `#{}`-interpolation.
16
16
  #
17
17
  # @return [Array<String, Sass::Script::Node>]
18
- attr_accessor :selector
18
+ attr_reader :selector
19
19
 
20
20
  # @param selector [Array<String, Sass::Script::Node>]
21
21
  # The CSS selector to extend,
@@ -11,11 +11,11 @@ module Sass::Tree
11
11
 
12
12
  # The parse tree for the initial expression.
13
13
  # @return [Script::Node]
14
- attr_accessor :from
14
+ attr_reader :from
15
15
 
16
16
  # The parse tree for the final expression.
17
17
  # @return [Script::Node]
18
- attr_accessor :to
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
- attr_accessor :args
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.
@@ -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
- attr_accessor :expr
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
@@ -6,9 +6,9 @@ module Sass::Tree
6
6
  #
7
7
  # @see Sass::Tree
8
8
  class MediaNode < DirectiveNode
9
- # The media query. A list of comma-separated queries (e.g. `print` or `screen`).
9
+ # The media query (e.g. `print` or `screen`).
10
10
  #
11
- # @return [Array<String>]
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 [Array<String>] See \{#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.join(', ')}"
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
- attr_accessor :args
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}
@@ -13,11 +13,11 @@ module Sass::Tree
13
13
 
14
14
  # The arguments to the mixin.
15
15
  # @return [Array<Script::Node>]
16
- attr_accessor :args
16
+ attr_reader :args
17
17
 
18
18
  # A hash from keyword argument names to values.
19
19
  # @return [{String => Script::Node}]
20
- attr_accessor :keywords
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}
@@ -65,7 +65,8 @@ module Sass
65
65
  # @param options [{Symbol => Object}] The options
66
66
  # @see #options
67
67
  def options=(options)
68
- Sass::Tree::Visitors::SetOptions.visit(self, options)
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
- # Returns a representation of the node for debugging purposes.
136
- #
137
- # @return [String]
138
- def inspect
139
- return self.class.to_s unless has_children
140
- "(#{self.class} #{children.map {|c| c.inspect}.join(' ')})"
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 {|n| yield n}}
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
- Sass::Tree::Visitors::DeepCopy.visit(self)
188
+ node = dup
189
+ node.children = children.map {|c| c.deep_copy}
190
+ node
175
191
  end
176
192
 
177
193
  protected
@@ -6,7 +6,7 @@ module Sass
6
6
  class ReturnNode < Node
7
7
  # The expression to return.
8
8
  # @type [Script::Node]
9
- attr_accessor :expr
9
+ attr_reader :expr
10
10
 
11
11
  # @param expr [Script::Node] The expression to return
12
12
  def initialize(expr)
@@ -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
- Visitors::Extend.visit(result, extends)
23
+ result = result.do_extend(extends) unless extends.empty?
24
24
  result.to_s
25
25
  end
26
26
  end
@@ -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, '', 1)
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
@@ -10,7 +10,7 @@ module Sass
10
10
 
11
11
  # The parse tree for the variable value.
12
12
  # @return [Script::Node]
13
- attr_accessor :expr
13
+ attr_reader :expr
14
14
 
15
15
  # Whether this is a guarded variable assignment (`!default`).
16
16
  # @return [Boolean]
@@ -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, true)
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
- try_send("invalid_#{node_name @parent}_child?", @parent, node) ||
12
- try_send("invalid_#{node_name node}_parent?", @parent, node))
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
- CONTROL_NODES = [Sass::Tree::EachNode, Sass::Tree::ForNode, Sass::Tree::IfNode, Sass::Tree::WhileNode]
22
- SCRIPT_NODES = [Sass::Tree::ImportNode, Sass::Tree::MixinNode] + CONTROL_NODES
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, SCRIPT_NODES)
26
- @parents.push parent
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
- @parents.pop
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
- VALID_EXTEND_PARENTS = [Sass::Tree::RuleNode, Sass::Tree::MixinDefNode]
51
+ INVALID_EXTEND_PARENTS = [Sass::Tree::RuleNode, Sass::Tree::MixinDefNode]
53
52
  def invalid_extend_parent?(parent, child)
54
- unless is_any_of?(parent, VALID_EXTEND_PARENTS)
55
- return "Extend directives may only be used within rules."
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
- VALID_FUNCTION_CHILDREN = [
64
- Sass::Tree::CommentNode, Sass::Tree::DebugNode, Sass::Tree::ReturnNode,
65
- Sass::Tree::VariableNode, Sass::Tree::WarnNode
66
- ] + CONTROL_NODES
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, VALID_FUNCTION_CHILDREN)
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 = CONTROL_NODES + [Sass::Tree::MixinDefNode]
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
- unless (@parents.map {|p| p.class} & INVALID_IMPORT_PARENTS).empty?
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
- VALID_PROP_CHILDREN = [Sass::Tree::CommentNode, Sass::Tree::PropNode, Sass::Tree::MixinNode] + CONTROL_NODES
101
+ INVALID_PROP_CHILDREN = [Sass::Tree::CommentNode, Sass::Tree::PropNode]
95
102
  def invalid_prop_child?(parent, child)
96
- unless is_any_of?(child, VALID_PROP_CHILDREN)
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
- VALID_PROP_PARENTS = [Sass::Tree::RuleNode, Sass::Tree::PropNode,
102
- Sass::Tree::MixinDefNode, Sass::Tree::DirectiveNode]
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, VALID_PROP_PARENTS)
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.lines + 1 == nxt.line) ||
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.join(', ')}#{yield}"
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 = Sass::Util.hash_to_a(node.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(/(,)?([ \t]*)\n\s*/) {$1 ? "#{$1}#{$2}\n" : " "}
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).gsub(/[ \t]*$/, '')
237
+ join.gsub(/^[ \t]*/, tab_str)
245
238
  end
246
239
 
247
240
  def semi