lib/sass/selector/sequence.rb in haml-3.0.0.rc.2 vs lib/sass/selector/sequence.rb in haml-3.0.0.rc.3

- old
+ new

@@ -74,20 +74,30 @@ # The extensions to perform on this selector # @return [Array<Sequence>] A list of selectors generated # by extending this selector with `extends`. # These correspond to a {CommaSequence}'s {CommaSequence#members members array}. # @see CommaSequence#do_extend - def do_extend(extends, supers = []) + def do_extend(extends, seen = Set.new) paths = Haml::Util.paths(members.map do |sseq_or_op| next [[sseq_or_op]] unless sseq_or_op.is_a?(SimpleSequence) - extended = sseq_or_op.do_extend(extends, supers) + extended = sseq_or_op.do_extend(extends, seen) choices = extended.map {|seq| seq.members} choices.unshift([sseq_or_op]) unless extended.any? {|seq| seq.superselector?(sseq_or_op)} choices end) Haml::Util.flatten(paths.map {|path| weave(path)}, 1).map {|p| Sequence.new(p)} end + # Returns whether or not this selector matches all elements + # that the given selector matches (as well as possibly more). + # + # @example + # (.foo).superselector?(.foo.bar) #=> true + # (.foo).superselector?(.bar) #=> false + # (.bar .foo).superselector?(.foo) #=> false + # + # @param sseq [SimpleSequence] + # @return [Boolean] def superselector?(sseq) return false unless members.size == 1 members.last.superselector?(sseq) end