sass 3.1.5 → 3.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.5
1
+ 3.1.6
@@ -42,20 +42,15 @@ module Sass
42
42
  raise "#{self.class} must implement #_retrieve."
43
43
  end
44
44
 
45
- # Store an object to the Sass Cache.
45
+ # Store a {Sass::Tree::RootNode}.
46
46
  #
47
47
  # @param key [String] The key to store it under.
48
48
  # @param sha [String] The checksum for the contents that are being stored.
49
49
  # @param obj [Object] The object to cache.
50
- def store(key, sha, obj)
51
- temp = obj.before_sass_cache_store if obj.respond_to?(:before_sass_cache_store)
52
- begin
53
- _store(key, Sass::VERSION, sha, Marshal.dump(obj))
54
- ensure
55
- obj.after_sass_cache_store(temp) if obj.respond_to?(:after_sass_cache_store)
56
- end
50
+ def store(key, sha, root)
51
+ _store(key, Sass::VERSION, sha, Marshal.dump(root))
57
52
  rescue TypeError, LoadError => e
58
- Sass::Util.sass_warn "Warning. Error encountered while saving a #{obj.class.name} to cache #{path_to(key)}: #{e}"
53
+ Sass::Util.sass_warn "Warning. Error encountered while saving cache #{path_to(key)}: #{e}"
59
54
  end
60
55
 
61
56
  # Retrieve a {Sass::Tree::RootNode}.
@@ -28,6 +28,8 @@ require 'sass/tree/visitors/perform'
28
28
  require 'sass/tree/visitors/cssize'
29
29
  require 'sass/tree/visitors/convert'
30
30
  require 'sass/tree/visitors/to_css'
31
+ require 'sass/tree/visitors/deep_copy'
32
+ require 'sass/tree/visitors/set_options'
31
33
  require 'sass/tree/visitors/check_nesting'
32
34
  require 'sass/selector'
33
35
  require 'sass/environment'
@@ -307,7 +309,6 @@ module Sass
307
309
  sha = Digest::SHA1.hexdigest(@template)
308
310
 
309
311
  if root = @options[:cache_store].retrieve(key, sha)
310
- @options = root.options.merge(@options)
311
312
  root.options = @options
312
313
  return root
313
314
  end
@@ -93,6 +93,17 @@ module Sass
93
93
  @mixins_in_use ||= @parent.mixins_in_use
94
94
  end
95
95
 
96
+ def stack_trace
97
+ trace = []
98
+ stack.reverse.each_with_index do |entry, i|
99
+ msg = "#{i == 0 ? "on" : "from"} line #{entry[:line]}"
100
+ msg << " of #{entry[:filename] || "an unknown file"}"
101
+ msg << ", in `#{entry[:mixin]}'" if entry[:mixin]
102
+ trace << msg
103
+ end
104
+ trace
105
+ end
106
+
96
107
  private
97
108
 
98
109
  def parent_options
@@ -57,6 +57,14 @@ module Sass
57
57
  @args + @keywords.values
58
58
  end
59
59
 
60
+ # @see Node#deep_copy
61
+ def deep_copy
62
+ node = dup
63
+ node.instance_variable_set('@args', args.map {|a| a.deep_copy})
64
+ node.instance_variable_set('@keywords', Hash[keywords.map {|k, v| [k, v.deep_copy]}])
65
+ node
66
+ end
67
+
60
68
  protected
61
69
 
62
70
  # Evaluates the function call.
@@ -50,6 +50,15 @@ module Sass::Script
50
50
  [@before, @mid, @after].compact
51
51
  end
52
52
 
53
+ # @see Node#deep_copy
54
+ def deep_copy
55
+ node = dup
56
+ node.instance_variable_set('@before', @before.deep_copy) if @before
57
+ node.instance_variable_set('@mid', @mid.deep_copy)
58
+ node.instance_variable_set('@after', @after.deep_copy) if @after
59
+ node
60
+ end
61
+
53
62
  protected
54
63
 
55
64
  # Evaluates the interpolation.
@@ -24,6 +24,13 @@ module Sass::Script
24
24
  @separator = separator
25
25
  end
26
26
 
27
+ # @see Node#deep_copy
28
+ def deep_copy
29
+ node = dup
30
+ node.instance_variable_set('@value', value.map {|c| c.deep_copy})
31
+ node
32
+ end
33
+
27
34
  # @see Node#eq
28
35
  def eq(other)
29
36
  Sass::Script::Bool.new(
@@ -33,6 +33,11 @@ module Sass::Script
33
33
  []
34
34
  end
35
35
 
36
+ # @see Node#deep_copy
37
+ def deep_copy
38
+ dup
39
+ end
40
+
36
41
  # Returns the options hash for this node.
37
42
  #
38
43
  # @return [{Symbol => Object}]
@@ -57,6 +57,14 @@ module Sass::Script
57
57
  Sass::Util.abstract(self)
58
58
  end
59
59
 
60
+ # Returns a deep clone of this node.
61
+ # The child nodes are cloned, but options are not.
62
+ #
63
+ # @return [Node]
64
+ def deep_copy
65
+ Sass::Util.abstract(self)
66
+ end
67
+
60
68
  protected
61
69
 
62
70
  # Converts underscores to dashes if the :dasherize option is set.
@@ -55,6 +55,14 @@ module Sass::Script
55
55
  [@operand1, @operand2]
56
56
  end
57
57
 
58
+ # @see Node#deep_copy
59
+ def deep_copy
60
+ node = dup
61
+ node.instance_variable_set('@operand1', @operand1.deep_copy)
62
+ node.instance_variable_set('@operand2', @operand2.deep_copy)
63
+ node
64
+ end
65
+
58
66
  protected
59
67
 
60
68
  # Evaluates the operation.
@@ -60,6 +60,15 @@ module Sass::Script
60
60
  [@before, @mid, @after].compact
61
61
  end
62
62
 
63
+ # @see Node#deep_copy
64
+ def deep_copy
65
+ node = dup
66
+ node.instance_variable_set('@before', @before.deep_copy) if @before
67
+ node.instance_variable_set('@mid', @mid.deep_copy)
68
+ node.instance_variable_set('@after', @after.deep_copy) if @after
69
+ node
70
+ end
71
+
63
72
  protected
64
73
 
65
74
  # Evaluates the interpolation.
@@ -38,6 +38,13 @@ module Sass::Script
38
38
  [@operand]
39
39
  end
40
40
 
41
+ # @see Node#deep_copy
42
+ def deep_copy
43
+ node = dup
44
+ node.instance_variable_set('@operand', @operand.deep_copy)
45
+ node
46
+ end
47
+
41
48
  protected
42
49
 
43
50
  # Evaluates the operation.
@@ -34,6 +34,11 @@ module Sass
34
34
  []
35
35
  end
36
36
 
37
+ # @see Node#deep_copy
38
+ def deep_copy
39
+ dup
40
+ end
41
+
37
42
  protected
38
43
 
39
44
  # Evaluates the variable.
@@ -6,12 +6,7 @@ module Sass
6
6
  class DebugNode < Node
7
7
  # The expression to print.
8
8
  # @return [Script::Node]
9
- attr_reader :expr
10
-
11
- # Returns sub nodes that are not tree children.
12
- def subnodes
13
- Array(expr)
14
- end
9
+ attr_accessor :expr
15
10
 
16
11
  # @param expr [Script::Node] The expression to print
17
12
  def initialize(expr)
@@ -11,7 +11,7 @@ module Sass::Tree
11
11
 
12
12
  # The parse tree for the list.
13
13
  # @param [Script::Node]
14
- attr_reader :list
14
+ attr_accessor :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
@@ -20,11 +20,5 @@ module Sass::Tree
20
20
  @list = list
21
21
  super()
22
22
  end
23
-
24
- # Returns sub nodes that are not tree children.
25
- def subnodes
26
- Array(list)
27
- end
28
-
29
23
  end
30
24
  end
@@ -15,7 +15,7 @@ module Sass::Tree
15
15
  # representing `#{}`-interpolation.
16
16
  #
17
17
  # @return [Array<String, Sass::Script::Node>]
18
- attr_reader :selector
18
+ attr_accessor :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_reader :from
14
+ attr_accessor :from
15
15
 
16
16
  # The parse tree for the final expression.
17
17
  # @return [Script::Node]
18
- attr_reader :to
18
+ attr_accessor :to
19
19
 
20
20
  # Whether to include `to` in the loop or stop just before.
21
21
  # @return [Boolean]
@@ -32,10 +32,5 @@ module Sass::Tree
32
32
  @exclusive = exclusive
33
33
  super()
34
34
  end
35
-
36
- # Returns sub nodes that are not tree children.
37
- def subnodes
38
- Array(from) + Array(to)
39
- end
40
35
  end
41
36
  end
@@ -22,11 +22,6 @@ module Sass
22
22
  @args = args
23
23
  super()
24
24
  end
25
-
26
- # Returns sub nodes that are not tree children.
27
- def subnodes
28
- Array(args)
29
- end
30
25
  end
31
26
  end
32
27
  end
@@ -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_reader :expr
16
+ attr_accessor :expr
17
17
 
18
18
  # The next {IfNode} in the if-else list, or `nil`.
19
19
  #
@@ -35,12 +35,6 @@ 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
-
44
38
  def _dump(f)
45
39
  Marshal.dump([self.expr, self.else, self.children])
46
40
  end
@@ -54,17 +48,5 @@ module Sass::Tree
54
48
  node.else ? node.else.instance_variable_get('@last_else') : node)
55
49
  node
56
50
  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
64
-
65
- # Returns sub nodes that are not tree children.
66
- def subnodes
67
- Array(expr) + Array(self.else)
68
- end
69
51
  end
70
52
  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_reader :args
16
+ attr_accessor :args
17
17
 
18
18
  # @param name [String] The mixin name
19
19
  # @param args [Array<(Script::Node, Script::Node)>] See \{#args}
@@ -22,11 +22,6 @@ module Sass
22
22
  @args = args
23
23
  super()
24
24
  end
25
-
26
- # Returns sub nodes that are not tree children.
27
- def subnodes
28
- Array(args)
29
- end
30
25
  end
31
26
  end
32
27
  end
@@ -13,11 +13,11 @@ module Sass::Tree
13
13
 
14
14
  # The arguments to the mixin.
15
15
  # @return [Array<Script::Node>]
16
- attr_reader :args
16
+ attr_accessor :args
17
17
 
18
18
  # A hash from keyword argument names to values.
19
19
  # @return [{String => Script::Node}]
20
- attr_reader :keywords
20
+ attr_accessor :keywords
21
21
 
22
22
  # @param name [String] The name of the mixin
23
23
  # @param args [Array<Script::Node>] See \{#args}
@@ -28,10 +28,5 @@ module Sass::Tree
28
28
  @keywords = keywords
29
29
  super()
30
30
  end
31
-
32
- # Returns sub nodes that are not tree children.
33
- def subnodes
34
- Array(args) + (keywords||{}).values
35
- end
36
31
  end
37
32
  end
@@ -65,11 +65,7 @@ module Sass
65
65
  # @param options [{Symbol => Object}] The options
66
66
  # @see #options
67
67
  def options=(options)
68
- children.each {|c| c.options = options}
69
- if respond_to?(:subnodes)
70
- subnodes.each {|n| n.options = options if n.respond_to?(:options=)}
71
- end
72
- @options = options
68
+ Sass::Tree::Visitors::SetOptions.visit(self, options)
73
69
  end
74
70
 
75
71
  # @private
@@ -188,19 +184,7 @@ module Sass
188
184
  #
189
185
  # @return [Node]
190
186
  def deep_copy
191
- node = dup
192
- node.children = children.map {|c| c.deep_copy}
193
- node
194
- end
195
-
196
- def before_sass_cache_store
197
- o = self.options
198
- self.options = {}
199
- return o
200
- end
201
-
202
- def after_sass_cache_store(o)
203
- self.options = o
187
+ Sass::Tree::Visitors::DeepCopy.visit(self)
204
188
  end
205
189
 
206
190
  protected
@@ -55,11 +55,6 @@ module Sass::Tree
55
55
  super()
56
56
  end
57
57
 
58
- # Returns sub nodes that are not tree children.
59
- def subnodes
60
- Array(name).select{|n| n.is_a?(Sass::Script::Node)} + [value]
61
- end
62
-
63
58
  # Compares the names and values of two properties.
64
59
  #
65
60
  # @param other [Object] The object to compare with
@@ -6,18 +6,13 @@ module Sass
6
6
  class ReturnNode < Node
7
7
  # The expression to return.
8
8
  # @type [Script::Node]
9
- attr_reader :expr
9
+ attr_accessor :expr
10
10
 
11
11
  # @param expr [Script::Node] The expression to return
12
12
  def initialize(expr)
13
13
  @expr = expr
14
14
  super()
15
15
  end
16
-
17
- # Returns sub nodes that are not tree children.
18
- def subnodes
19
- Array(expr)
20
- end
21
16
  end
22
17
  end
23
18
  end
@@ -50,6 +50,13 @@ 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
+
53
60
  # @param rule [Array<String, Sass::Script::Node>]
54
61
  # The CSS rule. See \{#rule}
55
62
  def initialize(rule)
@@ -115,11 +122,6 @@ module Sass::Tree
115
122
  :line => self.line}
116
123
  end
117
124
 
118
- # Returns sub nodes that are not tree children.
119
- def subnodes
120
- rule.select{|r| r.is_a?(Sass::Script::Node)}
121
- end
122
-
123
125
  private
124
126
 
125
127
  def try_to_parse_non_interpolated_rules