mirror of
https://github.com/penpot/penpot.git
synced 2026-09-07 20:49:37 +00:00
🐛 Fix crash when converting SVG-raw shape to path (#10613)
Guard the content-to-PathData coercion on whether stp/convert-to-path actually produced a new value, so SVG-raw shapes (whose :content is a hiccup map) pass through unchanged instead of crashing. Closes #10612 AI-assisted-by: deepseek-v4-pro
This commit is contained in:
parent
f2460eee29
commit
41ebb8e80b
@ -392,7 +392,9 @@
|
|||||||
([shape]
|
([shape]
|
||||||
(convert-to-path shape {}))
|
(convert-to-path shape {}))
|
||||||
([shape objects]
|
([shape objects]
|
||||||
(-> (stp/convert-to-path shape objects)
|
(let [shape' (stp/convert-to-path shape objects)]
|
||||||
(update :content impl/path-data))))
|
(if (identical? shape shape')
|
||||||
|
shape'
|
||||||
|
(update shape' :content impl/path-data)))))
|
||||||
|
|
||||||
(dm/export impl/decode-segments)
|
(dm/export impl/decode-segments)
|
||||||
|
|||||||
@ -1370,6 +1370,15 @@
|
|||||||
;; A path shape stays a path shape unchanged
|
;; A path shape stays a path shape unchanged
|
||||||
(t/is (= :path (:type result)))))
|
(t/is (= :path (:type result)))))
|
||||||
|
|
||||||
|
(t/deftest shape-to-path-svg-raw-does-not-throw
|
||||||
|
(let [shape {:type :svg-raw :x 0.0 :y 0.0 :width 100.0 :height 50.0
|
||||||
|
:selrect (make-selrect 0.0 0.0 100.0 50.0)
|
||||||
|
:content {:tag :text :attrs {:style {}}
|
||||||
|
:content [{:tag :tspan :attrs {} :content ["x"]}]}}
|
||||||
|
result (path/convert-to-path shape {})]
|
||||||
|
(t/is (= :svg-raw (:type result)))
|
||||||
|
(t/is (some? (:content result)))))
|
||||||
|
|
||||||
(t/deftest shape-to-path-rect-with-radius
|
(t/deftest shape-to-path-rect-with-radius
|
||||||
(let [shape {:type :rect :x 0.0 :y 0.0 :width 100.0 :height 100.0
|
(let [shape {:type :rect :x 0.0 :y 0.0 :width 100.0 :height 100.0
|
||||||
:r1 10.0 :r2 10.0 :r3 10.0 :r4 10.0
|
:r1 10.0 :r2 10.0 :r3 10.0 :r4 10.0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user