Method: Sass::Script::Functions#selector_nest
- Defined in:
- lib/sass/script/functions.rb
#selector_nest($selectors...) ⇒ Sass::Script::Value::List
Return a new selector with all selectors in $selectors nested beneath
one another as though they had been nested in the stylesheet as
$selector1 { $selector2 { ... } }.
Unlike most selector functions, selector-nest allows the
parent selector & to be used in any selector but the first.
2654 2655 2656 2657 2658 2659 2660 2661 2662 |
# File 'lib/sass/script/functions.rb', line 2654
def selector_nest(*selectors)
if selectors.empty?
raise ArgumentError.new("$selectors: At least one selector must be passed")
end
parsed = [parse_selector(selectors.first, :selectors)]
parsed += selectors[1..-1].map {|sel| parse_selector(sel, :selectors, true)}
parsed.inject {|result, child| child.resolve_parent_refs(result)}.to_sass_script
end
|