Class | Sass::Selector::Sequence
In: | lib/sass/selector/sequence.rb
Parent: | AbstractSequence

An operator-separated sequence of {SimpleSequence simple selector sequences}.

### Methods

do_extend filename= inspect line= new resolve_parent_refs superselector? to_a

### Attributes

members | [R] | The array of {SimpleSequence simple selector sequences}, operators, and newlines. The operators are strings such as `"+"` and `">"` representing the corresponding CSS operators. Newlines are also newline strings; these aren‘t semantically relevant, but they do affect formatting. @return [Array<SimpleSequence, String>]

### Public Class methods

new(seqs_and_ops)

@param seqs_and_ops [Array<SimpleSequence, String>] See \{members}

[Source]

        # File lib/sass/selector/sequence.rb, line 38
    38:       def initialize(seqs_and_ops)
    39:         @members = seqs_and_ops
    40:       end

### Public Instance methods

do_extend(extends, seen = Set.new)

Non-destructively extends this selector with the extensions specified in a hash (which should be populated via {Sass::Tree::Node#cssize}).

@overload def do_extend(extends) @param extends [Haml::Util::SubsetMap{Selector::Simple => Selector::Sequence}]

      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

[Source]

        # File lib/sass/selector/sequence.rb, line 79
    79:       def do_extend(extends, seen = Set.new)
    80:         paths = Haml::Util.paths(members.map do |sseq_or_op|
    81:             next [[sseq_or_op]] unless sseq_or_op.is_a?(SimpleSequence)
    82:             extended = sseq_or_op.do_extend(extends, seen)
    83:             choices = extended.map {|seq| seq.members}
    84:             choices.unshift([sseq_or_op]) unless extended.any? {|seq| seq.superselector?(sseq_or_op)}
    85:             choices
    86:           end)
    87:         Haml::Util.flatten(paths.map {|path| weave(path)}, 1).map {|p| Sequence.new(p)}
    88:       end

filename=(filename)

Sets the name of the file in which this selector was declared, or `nil` if it was not declared in a file (e.g. on stdin). This also sets the filename for all child selectors.

@param filename [String, nil] @return [String, nil]

[Source]

        # File lib/sass/selector/sequence.rb, line 22
    22:       def filename=(filename)
    23:         members.each {|m| m.filename = filename if m.is_a?(SimpleSequence)}
    24:         filename
    25:       end

inspect()

Returns a string representation of the sequence. This is basically the selector string.

@return [String]

[Source]

         # File lib/sass/selector/sequence.rb, line 117
    117:       def inspect
    118:         members.map {|m| m.inspect}.join(" ")
    119:       end

line=(line)

Sets the line of the Sass template on which this selector was declared. This also sets the line for all child selectors.

@param line [Fixnum] @return [Fixnum]

[Source]

        # File lib/sass/selector/sequence.rb, line 11
    11:       def line=(line)
    12:         members.each {|m| m.line = line if m.is_a?(SimpleSequence)}
    13:         line
    14:       end

resolve_parent_refs(super_seq)

Resolves the {Parent} selectors within this selector by replacing them with the given parent selector, handling commas appropriately.

@param super_seq [Sequence] The parent selector sequence @return [Sequence] This selector, with parent references resolved @raise [Sass::SyntaxError] If a parent selector is invalid

[Source]

        # File lib/sass/selector/sequence.rb, line 49
    49:       def resolve_parent_refs(super_seq)
    50:         members = @members
    51:         members.slice!(0) if nl = (members.first == "\n")
    52:         unless members.any? do |seq_or_op|
    53:             seq_or_op.is_a?(SimpleSequence) && seq_or_op.members.first.is_a?(Parent)
    54:           end
    55:           members = []
    56:           members << "\n" if nl
    57:           members << SimpleSequence.new([Parent.new])
    58:           members += @members
    59:         end
    60:
    61:         Sequence.new(
    62:           members.map do |seq_or_op|
    63:             next seq_or_op unless seq_or_op.is_a?(SimpleSequence)
    64:             seq_or_op.resolve_parent_refs(super_seq)
    65:           end.flatten)
    66:       end

superselector?(sseq)

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]

[Source]

         # File lib/sass/selector/sequence.rb, line 100
    100:       def superselector?(sseq)
    101:         return false unless members.size == 1
    102:         members.last.superselector?(sseq)
    103:       end

to_a()

@see Simple#to_a

[Source]

         # File lib/sass/selector/sequence.rb, line 106
    106:       def to_a
    107:         ary = @members.map {|seq_or_op| seq_or_op.is_a?(SimpleSequence) ? seq_or_op.to_a : seq_or_op}
    108:         ary = Haml::Util.intersperse(ary, " ")
    109:         ary = Haml::Util.substitute(ary, [" ", "\n", " "], ["\n"])
    110:         ary.flatten.compact
    111:       end

[Validate]