Class: AxeCuprite::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/axe/cuprite/results.rb

Overview

A single offending DOM node within a violation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Node

Returns a new instance of Node.



119
120
121
# File 'lib/axe/cuprite/results.rb', line 119

def initialize(raw)
  @raw = DeepFreeze.call(raw || {})
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



117
118
119
# File 'lib/axe/cuprite/results.rb', line 117

def raw
  @raw
end

Instance Method Details

#allObject



146
147
148
# File 'lib/axe/cuprite/results.rb', line 146

def all
  Array(@raw["all"])
end

#anyObject

The check results that caused/contributed to the failure.



142
143
144
# File 'lib/axe/cuprite/results.rb', line 142

def any
  Array(@raw["any"])
end

#contrast_dataObject

For color-contrast violations axe stores rich data under any[].data. Returns a ContrastData (or nil if this node has no contrast data).



156
157
158
159
160
161
# File 'lib/axe/cuprite/results.rb', line 156

def contrast_data
  check = any.find { |c| c.is_a?(Hash) && c["data"].is_a?(Hash) && c["data"].key?("contrastRatio") }
  return nil unless check

  ContrastData.new(check["data"])
end

#failure_summaryObject



137
138
139
# File 'lib/axe/cuprite/results.rb', line 137

def failure_summary
  @raw["failureSummary"]
end

#htmlObject

The offending element’s outer HTML (already truncated by axe).



133
134
135
# File 'lib/axe/cuprite/results.rb', line 133

def html
  @raw["html"]
end

#noneObject



150
151
152
# File 'lib/axe/cuprite/results.rb', line 150

def none
  Array(@raw["none"])
end

#selectorObject



128
129
130
# File 'lib/axe/cuprite/results.rb', line 128

def selector
  target.join(" ")
end

#targetObject

axe gives ‘target` as an array of CSS selectors (one per frame depth).



124
125
126
# File 'lib/axe/cuprite/results.rb', line 124

def target
  Array(@raw["target"])
end