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.



112
113
114
# File 'lib/axe/cuprite/results.rb', line 112

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

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



110
111
112
# File 'lib/axe/cuprite/results.rb', line 110

def raw
  @raw
end

Instance Method Details

#allObject



139
140
141
# File 'lib/axe/cuprite/results.rb', line 139

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

#anyObject

The check results that caused/contributed to the failure.



135
136
137
# File 'lib/axe/cuprite/results.rb', line 135

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).



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

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



130
131
132
# File 'lib/axe/cuprite/results.rb', line 130

def failure_summary
  @raw["failureSummary"]
end

#htmlObject

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



126
127
128
# File 'lib/axe/cuprite/results.rb', line 126

def html
  @raw["html"]
end

#noneObject



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

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

#selectorObject



121
122
123
# File 'lib/axe/cuprite/results.rb', line 121

def selector
  target.join(" ")
end

#targetObject

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



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

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