Class: SvgConform::Requirements::StyleRequirement
- Inherits:
-
BaseRequirement
- Object
- Lutaml::Model::Serializable
- BaseRequirement
- SvgConform::Requirements::StyleRequirement
- Defined in:
- lib/svg_conform/requirements/style_requirement.rb
Overview
Unified style requirement that handles all style validation:
-
Style syntax validation
-
Allowed style properties (whitelist/blacklist)
-
Property value validation
Instance Method Summary collapse
Methods inherited from BaseRequirement
#collect_sax_data, #element?, #get_attribute, #get_attributes, #has_attribute?, #needs_deferred_validation?, #remove_attribute, #set_attribute, #should_check_node?, #text?, #to_s, #validate_document, #validate_sax_complete
Instance Method Details
#check(node, context) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/svg_conform/requirements/style_requirement.rb', line 32 def check(node, context) return unless element?(node) style_value = get_attribute(node, "style") return unless style_value return if style_value.strip.empty? # 1. Check for malformed style syntax check_malformed_syntax(style_value, node, context) # 2. Check for allowed/disallowed properties and validate their values check_style_properties(style_value, node, context) end |
#validate_sax_element(element, context) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/svg_conform/requirements/style_requirement.rb', line 46 def validate_sax_element(element, context) style_value = element.raw_attributes["style"] return unless style_value return if style_value.strip.empty? # 1. Check for malformed style syntax check_malformed_syntax(style_value, element, context) # 2. Check for allowed/disallowed properties and validate their values check_style_properties(style_value, element, context) end |