mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
[Sass] Clean up the @extend impl a little.
This commit is contained in:
parent
dd55036220
commit
3ac96798bb
2 changed files with 8 additions and 11 deletions
|
@ -62,21 +62,18 @@ module Sass
|
|||
# by extending this selector with `extends`.
|
||||
# @see CommaSequence#do_extend
|
||||
def do_extend(extends, supers = [])
|
||||
seqs = extends.get(members.to_set).map do |seq, sels|
|
||||
extends.get(members.to_set).map do |seq, sels|
|
||||
# If A {@extend B} and C {...},
|
||||
# seq is A, sels is B, and self is C
|
||||
|
||||
self_without_sel = self.members - sels
|
||||
next unless unified = seq.members.last.unify(self_without_sel)
|
||||
[sels, seq.members[0...-1] + [unified]]
|
||||
end.compact.map {|sels, seq| [sels, Sequence.new(seq)]}
|
||||
|
||||
seqs.map {|_, seq| seq}.concat(
|
||||
seqs.map do |sels, seq|
|
||||
new_seqs = seq.do_extend(extends, supers.unshift(sels))[1..-1]
|
||||
supers.shift
|
||||
new_seqs
|
||||
end.flatten.uniq)
|
||||
end.compact.map {|sels, seq| [sels, Sequence.new(seq)]}.map do |sels, seq|
|
||||
seqs = seq.do_extend(extends, supers.unshift(sels))
|
||||
supers.shift
|
||||
seqs
|
||||
end.flatten.uniq
|
||||
rescue SystemStackError
|
||||
handle_extend_loop(supers)
|
||||
end
|
||||
|
|
|
@ -102,7 +102,7 @@ CSS
|
|||
SCSS
|
||||
|
||||
assert_equal <<CSS, render(<<SCSS)
|
||||
.foo.bar, .bar.baz, .foo.baz, .baz {
|
||||
.foo.bar, .bar.baz, .baz, .foo.baz {
|
||||
a: b; }
|
||||
CSS
|
||||
.foo.bar {a: b}
|
||||
|
@ -121,7 +121,7 @@ CSS
|
|||
SCSS
|
||||
|
||||
assert_equal <<CSS, render(<<SCSS)
|
||||
.foo.bar, .bar.baz, .foo.bang, .baz.bang {
|
||||
.foo.bar, .bar.baz, .baz.bang, .foo.bang {
|
||||
a: b; }
|
||||
CSS
|
||||
.foo.bar {a: b}
|
||||
|
|
Loading…
Add table
Reference in a new issue