Class: Sass::Selector::Pseudo

Inherits:
Simple
  • Object
show all
Defined in:
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)).

Instance Attribute Summary collapse

Attributes inherited from Simple

#filename, #line

Instance Method Summary collapse

Methods inherited from Simple

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

Constructor Details

#initialize(type, name, arg) ⇒ Pseudo

Returns a new instance of Pseudo.

Parameters:

  • type (Symbol)

    See #type

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

    The name of the selector

  • arg (nil, Array<String, Sass::Script::Node>)

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



309
310
311
312
313
# File 'lib/sass/selector.rb', line 309

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

Instance Attribute Details

#argArray<String, Sass::Script::Node>? (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:



303
304
305
# File 'lib/sass/selector.rb', line 303

def arg
  @arg
end

#nameArray<String, Sass::Script::Node> (readonly)

The name of the selector.

Returns:



293
294
295
# File 'lib/sass/selector.rb', line 293

def name
  @name
end

#typeSymbol (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 'lib/sass/selector.rb', line 288

def type
  @type
end

Instance Method Details

#to_a

See Also:

  • Selector#to_a


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

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 pseudoclass selector and sels contains a pseudoclass selector different than this one.

See Also:

  • Selector#unify


326
327
328
329
330
331
332
# File 'lib/sass/selector.rb', line 326

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
  super
end