🐛 Fix problem rendering some SVG filters

This commit is contained in:
alonso.torres 2022-03-31 11:21:15 +02:00
parent 34fd9d0d88
commit 785ae01a51
3 changed files with 22 additions and 22 deletions

View file

@ -175,12 +175,12 @@
(obj/set! styles "fill" (str "url(#fill-0-" render-id ")")) (obj/set! styles "fill" (str "url(#fill-0-" render-id ")"))
;; imported svgs can have fill and fill-opacity attributes ;; imported svgs can have fill and fill-opacity attributes
(obj/contains? svg-styles "fill") (and (some? svg-styles) (obj/contains? svg-styles "fill"))
(-> styles (-> styles
(obj/set! "fill" (obj/get svg-styles "fill")) (obj/set! "fill" (obj/get svg-styles "fill"))
(obj/set! "fillOpacity" (obj/get svg-styles "fillOpacity"))) (obj/set! "fillOpacity" (obj/get svg-styles "fillOpacity")))
(obj/contains? svg-attrs "fill") (and (some? svg-attrs) (obj/contains? svg-attrs "fill"))
(-> styles (-> styles
(obj/set! "fill" (obj/get svg-attrs "fill")) (obj/set! "fill" (obj/get svg-attrs "fill"))
(obj/set! "fillOpacity" (obj/get svg-attrs "fillOpacity"))) (obj/set! "fillOpacity" (obj/get svg-attrs "fillOpacity")))

View file

@ -350,7 +350,7 @@
(obj/without ["fill" "fillOpacity"])))] (obj/without ["fill" "fillOpacity"])))]
(obj/set! props "fill" (dm/fmt "url(#fill-0-%)" render-id))) (obj/set! props "fill" (dm/fmt "url(#fill-0-%)" render-id)))
(obj/contains? svg-styles "fill") (and (some? svg-styles) (obj/contains? svg-styles "fill"))
(let [style (let [style
(-> (obj/get props "style") (-> (obj/get props "style")
(obj/clone) (obj/clone)
@ -359,7 +359,7 @@
(-> props (-> props
(obj/set! "style" style))) (obj/set! "style" style)))
(obj/contains? svg-attrs "fill") (and (some? svg-attrs) (obj/contains? svg-attrs "fill"))
(let [style (let [style
(-> (obj/get props "style") (-> (obj/get props "style")
(obj/clone) (obj/clone)

View file

@ -43,7 +43,8 @@
transform-mask? (and (= :mask tag) transform-mask? (and (= :mask tag)
(= "userSpaceOnUse" (get attrs :maskUnits "objectBoundingBox"))) (= "userSpaceOnUse" (get attrs :maskUnits "objectBoundingBox")))
attrs (-> attrs attrs
(-> attrs
(usvg/update-attr-ids prefix-id) (usvg/update-attr-ids prefix-id)
(usvg/clean-attrs) (usvg/clean-attrs)
;; This clasname will be used to change the transform on the viewport ;; This clasname will be used to change the transform on the viewport
@ -59,8 +60,7 @@
transform-gradient? (add-matrix :gradientTransform transform) transform-gradient? (add-matrix :gradientTransform transform)
transform-pattern? (add-matrix :patternTransform transform) transform-pattern? (add-matrix :patternTransform transform)
transform-clippath? (add-matrix :transform transform) transform-clippath? (add-matrix :transform transform)
(or transform-filter? (or transform-filter? transform-mask?) (merge bounds)))
transform-mask?) (merge attrs bounds)))
[wrapper wrapper-props] (if (= tag :mask) [wrapper wrapper-props] (if (= tag :mask)
["g" #js {:className "svg-mask-wrapper" ["g" #js {:className "svg-mask-wrapper"