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

[Sass] Document the #superselector? methods.

This commit is contained in:
Nathan Weizenbaum 2010-04-28 14:50:01 -07:00
parent 25736cf9bd
commit ab244176a9
2 changed files with 19 additions and 0 deletions

View file

@ -87,6 +87,16 @@ module Sass
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)

View file

@ -99,6 +99,15 @@ module Sass
SimpleSequence.new(sseq)
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
#
# @param sseq [SimpleSequence]
# @return [Boolean]
def superselector?(sseq)
(base.nil? || base.eql?(sseq.base)) && rest.subset?(sseq.rest)
end