Class: SvgConform::Requirements::StylePromotionRequirement
- Inherits:
-
BaseRequirement
- Object
- Lutaml::Model::Serializable
- BaseRequirement
- SvgConform::Requirements::StylePromotionRequirement
- Defined in:
- lib/svg_conform/requirements/style_promotion_requirement.rb
Overview
Detects CSS style properties that should be promoted to attributes
Constant Summary collapse
- PROMOTABLE_PROPERTIES =
CSS properties that can be promoted to SVG attributes
%w[ fill stroke stroke-width stroke-opacity stroke-linecap stroke-linejoin fill-opacity fill-rule text-anchor font-family font-size font-weight font-style opacity visibility display ].freeze
Instance Method Summary collapse
Methods inherited from BaseRequirement
#check, #collect_sax_data, #element?, #get_attribute, #get_attributes, #has_attribute?, #needs_deferred_validation?, #remove_attribute, #set_attribute, #should_check_node?, #text?, #to_s, #validate_sax_complete
Instance Method Details
#validate_document(document, context) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/svg_conform/requirements/style_promotion_requirement.rb', line 14 def validate_document(document, context) document.xpath("//*[@style]").each do |element| style_attr = element["style"] next if style_attr.nil? || style_attr.strip.empty? validate_style_properties(element, style_attr, context) end end |
#validate_sax_element(element, context) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/svg_conform/requirements/style_promotion_requirement.rb', line 23 def validate_sax_element(element, context) style_attr = element.raw_attributes["style"] return if style_attr.nil? || style_attr.strip.empty? validate_style_properties(element, style_attr, context) end |