class Sass::Selector::SimpleSequence
of the selectors ‘.foo`, `#bar`, and `[attr=baz]`.
For example, `.foo#bar` is a simple sequence
that all apply to a single element.
A unseparated sequence of selectors
def _eql?(other)
def _eql?(other) other.base.eql?(self.base) && Haml::Util.set_eql?(other.rest, self.rest) end
def _hash
def _hash [base, Haml::Util.set_hash(rest)].hash end
def base
-
(Element, Universal, nil)
-
def base @base ||= (members.first if members.first.is_a?(Element) || members.first.is_a?(Universal)) end
def do_extend(extends, seen = Set.new)
- See: CommaSequence#do_extend -
Returns:
-
(Array
- A list of selectors generated)
Parameters:
-
extends
({Selector::Simple => Selector::Sequence}
) --
Overloads:
-
def do_extend(extends)
def do_extend(extends, seen = Set.new) 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 do |sels, seq| seq = Sequence.new(seq) seen.include?(sels) ? [] : seq.do_extend(extends, seen + [sels]) end.flatten.uniq end
def initialize(selectors)
-
selectors
(Array
) -- See \{#members}
def initialize(selectors) @members = selectors end
def inspect
-
(String)
-
def inspect members.map {|m| m.inspect}.join end
def resolve_parent_refs(super_seq)
-
(Sass::SyntaxError)
- If a parent selector is invalid
Returns:
-
(Array
- This selector, with parent references resolved.)
Parameters:
-
super_seq
(Sequence
) -- The parent selector sequence
def resolve_parent_refs(super_seq) # Parent selector only appears as the first selector in the sequence return [self] unless @members.first.is_a?(Parent) return super_seq.members if @members.size == 1 unless super_seq.members.last.is_a?(SimpleSequence) raise Sass::SyntaxError.new("Invalid parent selector: " + super_seq.to_a.join) end super_seq.members[0...-1] + [SimpleSequence.new(super_seq.members.last.members + @members[1..-1])] end
def rest
-
(Set
-)
def rest @rest ||= Set.new(base ? members[1..-1] : members) end
def superselector?(sseq)
-
(Boolean)
-
Parameters:
-
sseq
(SimpleSequence
) --
def superselector?(sseq) (base.nil? || base.eql?(sseq.base)) && rest.subset?(sseq.rest) end
def to_a
- See: Simple#to_a -
def to_a @members.map {|sel| sel.to_a}.flatten end
def unify(sels)
-
(Sass::SyntaxError)
- If this selector cannot be unified.
Returns:
-
(SimpleSequence, nil)
- A {SimpleSequence} matching both `sels` and this selector,
Parameters:
-
sels
(Array
) -- A {SimpleSequence}'s {SimpleSequence#members members array}
def unify(sels) return unless sseq = members.inject(sels) do |sseq, sel| return unless sseq sel.unify(sseq) end SimpleSequence.new(sseq) end