lib/prawn/svg/attributes/clip_path.rb in prawn-svg-0.23.1 vs lib/prawn/svg/attributes/clip_path.rb in prawn-svg-0.24.0
- old
+ new
@@ -1,14 +1,13 @@
module Prawn::SVG::Attributes::ClipPath
def parse_clip_path_attribute_and_call
- return unless clip_path = attributes['clip-path']
+ return unless clip_path = properties.clip_path
+ return if clip_path == 'none'
- if (matches = clip_path.strip.match(/\Aurl\(#(.*)\)\z/)).nil?
- document.warnings << "Only clip-path attributes with the form 'url(#xxx)' are supported"
- elsif (clip_path_element = @document.elements_by_id[matches[1]]).nil?
- document.warnings << "clip-path ID '#{matches[1]}' not defined"
- elsif clip_path_element.source.name != "clipPath"
- document.warnings << "clip-path ID '#{matches[1]}' does not point to a clipPath tag"
+ clip_path_element = extract_element_from_url_id_reference(clip_path, 'clipPath')
+
+ if clip_path_element.nil?
+ document.warnings << "Could not resolve clip-path URI to a clipPath element"
else
add_call_and_enter 'save_graphics_state'
add_calls_from_element clip_path_element
add_call "clip"
end