Class: Sass::Tree::Visitors::Extend
- Defined in:
- lib/sass/tree/visitors/extend.rb
Overview
A visitor for performing selector inheritance on a static CSS tree.
Destructively modifies the tree.
Class Method Summary collapse
-
.visit(root, extends) ⇒ Object
Performs the given extensions on the static CSS tree based in
root
, then validates that all extends matched some selector.
Instance Method Summary collapse
-
#initialize(extends) ⇒ Extend
constructor
protected
A new instance of Extend.
-
#visit(node)
protected
If an exception is raised, this adds proper metadata to the backtrace.
-
#visit_children(parent)
protected
Keeps track of the current parent directives.
-
#visit_rule(node)
protected
Applies the extend to a single rule's selector.
Methods inherited from Base
Constructor Details
#initialize(extends) ⇒ Extend (protected)
Returns a new instance of Extend.
21 22 23 24 |
# File 'lib/sass/tree/visitors/extend.rb', line 21
def initialize(extends)
@parent_directives = []
@extends = extends
end
|
Class Method Details
.visit(root, extends) ⇒ Object
Performs the given extensions on the static CSS tree based in root
, then
validates that all extends matched some selector.
The extensions to perform on this tree.
13 14 15 16 17 |
# File 'lib/sass/tree/visitors/extend.rb', line 13
def self.visit(root, extends)
return if extends.empty?
new(extends).send(:visit, root)
check_extends_fired! extends
end
|
Instance Method Details
#visit(node) (protected)
If an exception is raised, this adds proper metadata to the backtrace.
27 28 29 30 31 32 |
# File 'lib/sass/tree/visitors/extend.rb', line 27
def visit(node)
super(node)
rescue Sass::SyntaxError => e
e.modify_backtrace(:filename => node.filename, :line => node.line)
raise e
end
|
#visit_children(parent) (protected)
Keeps track of the current parent directives.
35 36 37 38 39 40 |
# File 'lib/sass/tree/visitors/extend.rb', line 35
def visit_children(parent)
@parent_directives.push parent if parent.is_a?(Sass::Tree::DirectiveNode)
super
ensure
@parent_directives.pop if parent.is_a?(Sass::Tree::DirectiveNode)
end
|
#visit_rule(node) (protected)
Applies the extend to a single rule's selector.
43 44 45 |
# File 'lib/sass/tree/visitors/extend.rb', line 43
def visit_rule(node)
node.resolved_rules = node.resolved_rules.do_extend(@extends, @parent_directives)
end
|