lib/sass/selector/sequence.rb
def subweave(seq1, seq2)
        return [seq2] if seq1.empty?
        return [seq1] if seq2.empty?

        return unless init = merge_initial_ops(seq1, seq2)
        seq1 = group_selectors(seq1)
        seq2 = group_selectors(seq2)
        lcs = Sass::Util.lcs(seq2, seq1) do |s1, s2|
          next s1 if s1 == s2
          next unless s1.first.is_a?(SimpleSequence) && s2.first.is_a?(SimpleSequence)
          next s2 if subweave_superselector?(s1, s2)
          next s1 if subweave_superselector?(s2, s1)
        end

        diff = [[init]]
        until lcs.empty?
          diff << chunks(seq1, seq2) {|s| subweave_superselector?(s.first, lcs.first)} << [lcs.shift]
          seq1.shift
          seq2.shift
        end
        diff << chunks(seq1, seq2) {|s| s.empty?}
        diff.reject! {|c| c.empty?}

        Sass::Util.paths(diff).map {|p| p.flatten}
      end
# This interweaves two lists of selectors,
# returning all possible orderings of them (including using unification)
# that maintain the relative ordering of the input arrays.
#
# For example, given `.foo .bar` and `.baz .bang`,
# this would return `.foo .bar .baz .bang`, `.foo .bar.baz .bang`,
# `.foo .baz .bar .bang`, `.foo .baz .bar.bang`, `.foo .baz .bang .bar`,
# and so on until `.baz .bang .foo .bar`.
#
# @param seq1 [Array<SimpleSequence or String>]
# @param seq2 [Array<SimpleSequence or String>]
# @return [Array<Array<SimpleSequence or String>>]
This interweaves two lists of selectors,
returning all possible orderings of them (including using unification)
that maintain the relative ordering of the input arrays.


This interweaves two lists of selectors returning all possible orderings of them ( including using unification ) that maintain the relative ordering of the input arrays .
def subweave(seq1, seq2)
        return [seq2] if seq1.empty?
        return [seq1] if seq2.empty?
        return unless init = merge_initial_ops(seq1, seq2)
        seq1 = group_selectors(seq1)
        seq2 = group_selectors(seq2)
        lcs = Sass::Util.lcs(seq2, seq1) do |s1, s2|
          next s1 if s1 == s2
          next unless s1.first.is_a?(SimpleSequence) && s2.first.is_a?(SimpleSequence)
          next s2 if subweave_superselector?(s1, s2)
          next s1 if subweave_superselector?(s2, s1)
        end
        diff = [[init]]
        until lcs.empty?
          diff << chunks(seq1, seq2) {|s| subweave_superselector?(s.first, lcs.first)} << [lcs.shift]
          seq1.shift
          seq2.shift
        end
        diff << chunks(seq1, seq2) {|s| s.empty?}
        diff.reject! {|c| c.empty?}
        Sass::Util.paths(diff).map {|p| p.flatten}
      end
def subweave ( seq1 , seq2 ) return [ seq2 ] if seq1 . empty? return [ seq1 ] if seq2 . empty? return unless init = merge_initial_ops ( seq1 , seq2 ) seq1 = group_selectors ( seq1 ) seq2 = group_selectors ( seq2 ) lcs = Sass :: Util . lcs ( seq2 , seq1 ) do | s1 , s2 | next s1 if s1 == s2 next unless s1 . first . is_a? ( SimpleSequence ) && s2 . first . is_a? ( SimpleSequence ) next s2 if subweave_superselector? ( s1 , s2 ) next s1 if subweave_superselector? ( s2 , s1 ) end diff = [ [ init ] ] until lcs . empty? diff << chunks ( seq1 , seq2 ) { | s | subweave_superselector? ( s . first , lcs . first ) } << [ lcs . shift ] seq1 . shift seq2 . shift end diff << chunks ( seq1 , seq2 ) { | s | s . empty? } diff . reject! { | c | c . empty? } Sass :: Util . paths ( diff ) . map { | p | p . flatten } end
This interweaves two lists of selectors,
returning all possible orderings of them (including using unification)
that maintain the relative ordering of the input arrays.
This interweaves two lists of selectors returning all possible orderings of them ( including using unification ) that maintain the relative ordering of the input arrays .
None
Array<Array<SimpleSequence or String>>
seq1
seq2
None