Class: AxeCuprite::Node
- Inherits:
-
Object
- Object
- AxeCuprite::Node
- Defined in:
- lib/axe/cuprite/results.rb
Overview
A single offending DOM node within a violation.
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #all ⇒ Object
-
#any ⇒ Object
The check results that caused/contributed to the failure.
-
#contrast_data ⇒ Object
For color-contrast violations axe stores rich data under any[].data.
- #failure_summary ⇒ Object
-
#html ⇒ Object
The offending element’s outer HTML (already truncated by axe).
-
#initialize(raw) ⇒ Node
constructor
A new instance of Node.
- #none ⇒ Object
- #selector ⇒ Object
-
#target ⇒ Object
axe gives ‘target` as an array of CSS selectors (one per frame depth).
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
#raw ⇒ Object (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
#all ⇒ Object
139 140 141 |
# File 'lib/axe/cuprite/results.rb', line 139 def all Array(@raw["all"]) end |
#any ⇒ Object
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_data ⇒ Object
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_summary ⇒ Object
130 131 132 |
# File 'lib/axe/cuprite/results.rb', line 130 def failure_summary @raw["failureSummary"] end |
#html ⇒ Object
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 |
#none ⇒ Object
143 144 145 |
# File 'lib/axe/cuprite/results.rb', line 143 def none Array(@raw["none"]) end |
#selector ⇒ Object
121 122 123 |
# File 'lib/axe/cuprite/results.rb', line 121 def selector target.join(" ") end |
#target ⇒ Object
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 |