Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: lib/sass/selector/comma_sequence.rb lib/sass/selector/sequence.rb lib/sass/selector/simple_sequence.rb lib/sass/tree/visitors/check_nesting.rb lib/sass/tree/visitors/to_css.rb test/sass/extend_test.rb test/sass/util_test.rb
- Loading branch information
Showing
17 changed files
with
378 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# A visitor for performing selector inheritance on a static CSS tree. | ||
# | ||
# Destructively modifies the tree. | ||
class Sass::Tree::Visitors::Extend < Sass::Tree::Visitors::Base | ||
# @param root [Tree::Node] The root node of the tree to visit. | ||
# @param extends [Sass::Util::SubsetMap{Selector::Simple => | ||
# Sass::Tree::Visitors::Cssize::Extend}] | ||
# The extensions to perform on this tree. | ||
# @return [Object] The return value of \{#visit} for the root node. | ||
def self.visit(root, extends) | ||
return if extends.empty? | ||
new(extends).send(:visit, root) | ||
end | ||
|
||
protected | ||
|
||
def initialize(extends) | ||
@parent_directives = [] | ||
@extends = extends | ||
end | ||
|
||
# If an exception is raised, this adds proper metadata to the backtrace. | ||
def visit(node) | ||
super(node) | ||
rescue Sass::SyntaxError => e | ||
e.modify_backtrace(:filename => node.filename, :line => node.line) | ||
raise e | ||
end | ||
|
||
# Keeps track of the current parent directives. | ||
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 | ||
|
||
# Applies the extend to a single rule's selector. | ||
def visit_rule(node) | ||
node.resolved_rules = node.resolved_rules.do_extend(@extends, @parent_directives) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.