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.



90
91
92
# File 'lib/axe/cuprite/results.rb', line 90

def initialize(raw)
  @raw = raw || {}
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



88
89
90
# File 'lib/axe/cuprite/results.rb', line 88

def raw
  @raw
end

Instance Method Details

#allObject



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

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

#anyObject

The check results that caused/contributed to the failure.



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

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



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

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



108
109
110
# File 'lib/axe/cuprite/results.rb', line 108

def failure_summary
  @raw["failureSummary"]
end

#htmlObject

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



104
105
106
# File 'lib/axe/cuprite/results.rb', line 104

def html
  @raw["html"]
end

#noneObject



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

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

#selectorObject



99
100
101
# File 'lib/axe/cuprite/results.rb', line 99

def selector
  target.join(" ")
end

#targetObject

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



95
96
97
# File 'lib/axe/cuprite/results.rb', line 95

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