Class: A11y::Lint::ErbElementNode
- Inherits:
-
Object
- Object
- A11y::Lint::ErbElementNode
- Defined in:
- lib/a11y/lint/erb_element_node.rb
Overview
Wraps a Nokogiri HTML element from an ERB template as a queryable node for lint rules.
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
Instance Method Summary collapse
- #attribute?(name) ⇒ Boolean
- #attributes ⇒ Object
- #block_body_codes ⇒ Object
- #block_has_text_children? ⇒ Boolean
- #call_node ⇒ Object
-
#children ⇒ Object
Returns direct element children wrapped as ErbElementNode objects.
-
#initialize(nokogiri_node:, line:, configuration: Configuration.new) ⇒ ErbElementNode
constructor
A new instance of ErbElementNode.
- #ruby_code ⇒ Object
- #tag_name ⇒ Object
- #text_content? ⇒ Boolean
Constructor Details
#initialize(nokogiri_node:, line:, configuration: Configuration.new) ⇒ ErbElementNode
Returns a new instance of ErbElementNode.
10 11 12 13 14 15 16 |
# File 'lib/a11y/lint/erb_element_node.rb', line 10 def initialize( nokogiri_node:, line:, configuration: Configuration.new ) @nokogiri_node = nokogiri_node @line = line @configuration = configuration end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
8 9 10 |
# File 'lib/a11y/lint/erb_element_node.rb', line 8 def configuration @configuration end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
8 9 10 |
# File 'lib/a11y/lint/erb_element_node.rb', line 8 def line @line end |
Instance Method Details
#attribute?(name) ⇒ Boolean
22 23 24 |
# File 'lib/a11y/lint/erb_element_node.rb', line 22 def attribute?(name) attributes.key?(name) end |
#attributes ⇒ Object
26 27 28 29 30 31 |
# File 'lib/a11y/lint/erb_element_node.rb', line 26 def attributes @attributes ||= @nokogiri_node .attributes .transform_values(&:value) end |
#block_body_codes ⇒ Object
41 42 43 |
# File 'lib/a11y/lint/erb_element_node.rb', line 41 def block_body_codes nil end |
#block_has_text_children? ⇒ Boolean
45 46 47 |
# File 'lib/a11y/lint/erb_element_node.rb', line 45 def block_has_text_children? false end |
#call_node ⇒ Object
33 34 35 |
# File 'lib/a11y/lint/erb_element_node.rb', line 33 def call_node nil end |
#children ⇒ Object
Returns direct element children wrapped as ErbElementNode objects. Excludes elements whose class attribute matches a configured hidden-wrapper class, since CSS-hidden subtrees do not contribute to the accessible name.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/a11y/lint/erb_element_node.rb', line 59 def children @nokogiri_node.element_children.filter_map do |child| next if hidden_wrapper?(child) ErbElementNode.new( nokogiri_node: child, line: child.line, configuration: configuration ) end end |
#ruby_code ⇒ Object
37 38 39 |
# File 'lib/a11y/lint/erb_element_node.rb', line 37 def ruby_code nil end |
#tag_name ⇒ Object
18 19 20 |
# File 'lib/a11y/lint/erb_element_node.rb', line 18 def tag_name @nokogiri_node.name end |
#text_content? ⇒ Boolean
49 50 51 52 53 |
# File 'lib/a11y/lint/erb_element_node.rb', line 49 def text_content? return false if hidden_wrapper?(@nokogiri_node) visible_text_or_output?(@nokogiri_node) end |