Class: PlatformosCheck::ImgWidthAndHeight
- Defined in:
- lib/platformos_check/checks/img_width_and_height.rb
Overview
Reports errors when trying to use parser-blocking script tags
Constant Summary collapse
- ENDS_IN_CSS_UNIT =
/(cm|mm|in|px|pt|pc|em|ex|ch|rem|vw|vh|vmin|vmax|%)$/i
Constants inherited from HtmlCheck
Constants inherited from Check
Check::CATEGORIES, Check::SEVERITIES, Check::SEVERITY_VALUES
Instance Attribute Summary
Attributes inherited from Check
#ignored_patterns, #offenses, #options, #platformos_app
Instance Method Summary collapse
Methods included from ChecksTracking
Methods inherited from Check
#==, #add_offense, all, can_disable, #can_disable?, categories, #categories, category, #code_name, doc, #doc, docs_url, #ignore!, #ignored?, #severity, severity, #severity=, #severity_value, severity_value, single_file, #single_file?, #to_s, #whole_platformos_app?
Methods included from JsonHelpers
#format_json_parse_error, #pretty_json
Instance Method Details
#on_img(node) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/platformos_check/checks/img_width_and_height.rb', line 12 def on_img(node) width = node.attributes["width"] height = node.attributes["height"] record_units_in_field_offenses("width", width, node:) record_units_in_field_offenses("height", height, node:) return if node.attributes["src"].nil? || (width && height) missing_width = width.nil? missing_height = height.nil? = if missing_width && missing_height "Missing width and height attributes" elsif missing_width "Missing width attribute" elsif missing_height "Missing height attribute" end add_offense(, node:) end |