Class: Sass::Tree::ExtendNode

Inherits:
Node
  • Object
show all
Defined in:
lib/sass/tree/extend_node.rb

Overview

A static node reprenting an @extend directive.

See Also:

Constant Summary

Constants inherited from Node

Node::SAVED_OPTIONS

Instance Attribute Summary

Attributes inherited from Node

#children, #filename, #has_children, #line, #options

Instance Method Summary collapse

Methods inherited from Node

#<<, #==, #_around_dump, #_cssize, #_perform, #_to_s, #balance, #check_child!, #children_to_src, #cssize!, #dasherize, #do_extend, #each, #invalid_child?, #invisible?, #perform, #perform_children, #run_interp, #selector_to_sass, #selector_to_scss, #selector_to_src, #semi, #style, #to_s, #to_sass, #to_scss

Constructor Details

#initialize(selector) ⇒ ExtendNode

Returns a new instance of ExtendNode.

Parameters:



12
13
14
15
# File 'lib/sass/tree/extend_node.rb', line 12

def initialize(selector)
  @selector = selector
  super()
end

Instance Method Details

#cssize(extends, parent)

Registers this extension in the extends subset map.

Parameters:

See Also:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/sass/tree/extend_node.rb', line 23

def cssize(extends, parent)
  @resolved_selector.members.each do |seq|
    if seq.members.size > 1
      raise Sass::SyntaxError.new("Can't extend #{seq.to_a.join}: can't extend nested selectors")
    end

    sseq = seq.members.first
    if !sseq.is_a?(Sass::Selector::SimpleSequence)
      raise Sass::SyntaxError.new("Can't extend #{seq.to_a.join}: invalid selector")
    end

    sel = sseq.members
    parent.resolved_rules.members.each do |seq|
      if !seq.members.last.is_a?(Sass::Selector::SimpleSequence)
        raise Sass::SyntaxError.new("#{seq} can't extend: invalid selector")
      end

      extends[sel] = seq
    end
  end

  []
end

#perform!(environment) (protected)

Runs SassScript interpolation in the selector, and then parses the result into a Selector::CommaSequence.

Parameters:

  • environment (Sass::Environment)

    The lexical environment containing variable and mixin values



59
60
61
62
63
# File 'lib/sass/tree/extend_node.rb', line 59

def perform!(environment)
  @resolved_selector = Sass::SCSS::CssParser.new(run_interp(@selector, environment), self.line).
    parse_selector(self.filename)
  super
end

#to_src(tabs, opts, fmt) (protected)

See Also:



50
51
52
# File 'lib/sass/tree/extend_node.rb', line 50

def to_src(tabs, opts, fmt)
  "#{'  ' * tabs}@extend #{selector_to_src(@selector, tabs, opts, fmt).lstrip}#{semi fmt}\n"
end