Class: LightningcssRb::AST::Selectors::PseudoClass

Inherits:
Base
  • Object
show all
Defined in:
lib/lightningcss_rb/ast/selectors/pseudo_class.rb

Instance Attribute Summary

Attributes inherited from Base

#node

Instance Method Summary collapse

Methods inherited from Base

from_ast, #initialize, node_attr_reader, #to_s

Constructor Details

This class inherits a constructor from LightningcssRb::AST::Selectors::Base

Instance Method Details

#to_cssObject

rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/AbcSize



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/lightningcss_rb/ast/selectors/pseudo_class.rb', line 9

def to_css # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/AbcSize
  case kind
  when "not"    then ":not(#{render_selector_list(node[:selectors])})"
  when "is"     then ":is(#{render_selector_list(node[:selectors])})"
  when "where"  then ":where(#{render_selector_list(node[:selectors])})"
  when "has"    then ":has(#{render_selector_list(node[:selectors])})"
  when "any"    then ":#{vendor_prefix_str(node[:vendorPrefix])}any(#{render_selector_list(node[:selectors])})"
  when "host"   then node[:selectors] ? ":host(#{render_selector(node[:selectors])})" : ":host"
  when "local"  then ":local(#{render_selector(node[:selector])})"
  when "global" then ":global(#{render_selector(node[:selector])})"
  when "lang"   then ":lang(#{node[:languages].join(", ")})"
  when "dir"    then ":dir(#{node[:direction]})"
  when "webkit-scrollbar" then ":#{node[:value]}"
  when "nth-child"        then ":nth-child(#{nth_str}#{of_str})"
  when "nth-last-child"   then ":nth-last-child(#{nth_str}#{of_str})"
  when "nth-of-type"      then ":nth-of-type(#{nth_str})"
  when "nth-last-of-type" then ":nth-last-of-type(#{nth_str})"
  when "nth-col"          then ":nth-col(#{nth_str})"
  when "nth-last-col"     then ":nth-last-col(#{nth_str})"
  when "active-view-transition-type" then ":active-view-transition-type(#{node[:type].join(", ")})"
  when "state"  then ":state(#{node[:state]})"
  when "custom" then ":#{node[:name]}"
  when "custom-function" then ":#{node[:name]}()"
  else ":#{kind}"
  end
end