Class: Sass::Selector::Pseudo

Inherits:
Simple
  • Object
show all
Defined in:
/var/www/sass-pages/.sass/lib/sass/selector.rb

Overview

A pseudoclass (e.g. :visited) or pseudoelement (e.g. ::first-line) selector. It can have arguments (e.g. :nth-child(2n+1)).

Constant Summary

Instance Attribute Summary

Instance Method Summary

Methods inherited from Simple

#eql?, #hash, #inspect, #to_s, #unify_namespaces

Constructor Details

- (Pseudo) initialize(type, name, arg)

A new instance of Pseudo

Parameters:

  • (Symbol) type — See #type
  • (Array<String, Sass::Script::Node>) name — The name of the selector
  • (nil, Array<String, Sass::Script::Node>) arg — The argument to the selector, or nil if no argument was given


316
317
318
319
320
# File '/var/www/sass-pages/.sass/lib/sass/selector.rb', line 316

def initialize(type, name, arg)
  @type = type
  @name = name
  @arg = arg
end

Instance Attribute Details

- (Array<String, Sass::Script::Node>?) arg (readonly)

The argument to the selector, or nil if no argument was given.

This may include SassScript nodes that will be run during resolution. Note that this should not include SassScript nodes after resolution has taken place.

Returns:



310
311
312
# File '/var/www/sass-pages/.sass/lib/sass/selector.rb', line 310

def arg
  @arg
end

- (Array<String, Sass::Script::Node>) name (readonly)

The name of the selector.

Returns:



300
301
302
# File '/var/www/sass-pages/.sass/lib/sass/selector.rb', line 300

def name
  @name
end

- (Symbol) type (readonly)

The type of the selector. :class if this is a pseudoclass selector, :element if it’s a pseudoelement.

Returns:

  • (Symbol)


288
289
290
# File '/var/www/sass-pages/.sass/lib/sass/selector.rb', line 288

def type
  @type
end

Instance Method Details

- (Boolean) final?

Returns:

  • (Boolean)


322
323
324
# File '/var/www/sass-pages/.sass/lib/sass/selector.rb', line 322

def final?
  type == :class && FINAL_SELECTORS.include?(name.first)
end

- to_a

See Also:

  • Selector#to_a


327
328
329
330
331
# File '/var/www/sass-pages/.sass/lib/sass/selector.rb', line 327

def to_a
  res = [@type == :class ? ":" : "::"] + @name
  (res << "(").concat(Sass::Util.strip_string_array(@arg)) << ")" if @arg
  res
end

- unify(sels)

Returns nil if this is a pseudoelement selector and sels contains a pseudoelement selector different than this one.

See Also:

  • Selector#unify


337
338
339
340
341
342
343
344
# File '/var/www/sass-pages/.sass/lib/sass/selector.rb', line 337

def unify(sels)
  return if type == :element && sels.any? do |sel|
    sel.is_a?(Pseudo) && sel.type == :element &&
      (sel.name != self.name || sel.arg != self.arg)
  end
  return sels + [self] if final?
  super
end