1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

[Sass] Actually allow @extend to @extend long selectors. Loop handling is still broken.

This commit is contained in:
Nathan Weizenbaum 2010-04-11 14:03:33 -07:00
parent 77dfef18c2
commit c07cd09adf
2 changed files with 11 additions and 14 deletions

View file

@ -400,21 +400,18 @@ module Sass
# by {Sequence#extend}.
# @see CommaSequence#extend
def extend(extends, supers = [])
seqs = Haml::Util.enum_with_index(members).map do |sel, i|
next unless extenders = extends[Set[sel]]
sseq_without_sel = members[0...i] + members[i+1..-1]
extenders.map do |sseq|
new_sseq = sseq.members.inject(sseq_without_sel) do |sseq2, sel2|
next unless sseq2
sel2.unify(sseq2)
end
new_sseq && [sel, new_sseq]
seqs = extends.get(members.to_set).map do |sseq, sels|
sseq_without_sel = members - sels.to_a
new_sseq = sseq.members.inject(sseq_without_sel) do |sseq2, sel2|
next unless sseq2
sel2.unify(sseq2)
end
end.flatten(1).compact.map {|sel, seq| [sel, SimpleSequence.new(seq)]}
new_sseq && [sels, new_sseq]
end.compact.map {|sels, seq| [sels, SimpleSequence.new(seq)]}
seqs.map {|_, seq| seq}.concat(
seqs.map do |sel, seq|
new_seqs = seq.extend(extends, supers.unshift(sel))
seqs.map do |sels, seq|
new_seqs = seq.extend(extends, supers.unshift(sels))
supers.shift
new_seqs
end.flatten.uniq)

View file

@ -820,7 +820,7 @@ SCSS
def test_long_extendee_matches_supersets
assert_equal <<CSS, render(<<SCSS)
.foo.bar.bap, .baz.bap {
.foo.bar.bap, .bap.baz {
a: b; }
CSS
.foo.bar.bap {a: b}
@ -830,7 +830,7 @@ SCSS
def test_long_extendee_runs_unification
assert_equal <<CSS, render(<<SCSS)
.foo.bar.bap, ns|a.baz {
ns|*.foo.bar, ns|a.baz {
a: b; }
CSS
ns|*.foo.bar {a: b}