Class: Less::Node::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/sass/less.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#group

Returns the value of attribute group.



148
149
150
# File 'lib/sass/less.rb', line 148

def group
  @group
end

Instance Method Details

#sass_selector_str



183
184
185
186
187
188
# File 'lib/sass/less.rb', line 183

def sass_selector_str
  case @selector
  when /[+>~]/; "#{@selector} #{@name}"
  else @selector + @name
  end
end

#to_sass_tree



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/sass/less.rb', line 155

def to_sass_tree
  if root?
    root = Sass::Tree::RootNode.new("")
    rules.each {|r| root << r.to_sass_tree}
    return root
  end
  return if hide_in_sass
  return if !self.equal?(group.first)

  last_el = nil
  sel = group.map do |el|
    comma_sel = []
    loop do
      comma_sel << el.sass_selector_str
      break unless el.rules.size == 1 && el.rules.first.is_a?(Element)
      el = el.rules.first
    end
    last_el = el
    comma_sel = comma_sel.join(' ').gsub(' :', ':')
    comma_sel.gsub!(/^:/, '&:') unless parent.root?
    comma_sel
  end.join(', ')

  rule = Sass::Tree::RuleNode.new([sel])
  last_el.rules.each {|r| rule << r.to_sass_tree}
  return rule
end

#top(env)



150
151
152
153
# File 'lib/sass/less.rb', line 150

def top(env)
  return self if parent.equal?(env)
  return parent.top(env)
end