aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2023-09-03 08:07:53 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2023-09-03 08:07:53 +0200
commitdd884bc205e1b476497af3fd8cabcdf85c95125e (patch)
treea863cb7a2a906bcd0d7824d98c8f47738b32399c /src
parent9ed85cff5eb3783efc25c070f07b6bcf71c44e07 (diff)
downloadsvg.js-dd884bc205e1b476497af3fd8cabcdf85c95125e.tar.gz
svg.js-dd884bc205e1b476497af3fd8cabcdf85c95125e.zip
only apply color conversion to attributes that can take a color (fixes #1241)
Diffstat (limited to 'src')
-rw-r--r--src/modules/core/attr.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/modules/core/attr.js b/src/modules/core/attr.js
index a96f706..36b331b 100644
--- a/src/modules/core/attr.js
+++ b/src/modules/core/attr.js
@@ -4,6 +4,16 @@ import Color from '../../types/Color.js'
import SVGArray from '../../types/SVGArray.js'
import SVGNumber from '../../types/SVGNumber.js'
+const colorAttributes = new Set([
+ 'fill',
+ 'stroke',
+ 'color',
+ 'bgcolor',
+ 'stop-color',
+ 'flood-color',
+ 'lighting-color'
+])
+
const hooks = []
export function registerAttrHook(fn) {
hooks.push(fn)
@@ -53,7 +63,7 @@ export default function attr(attr, val, ns) {
// ensure correct numeric values (also accepts NaN and Infinity)
if (typeof val === 'number') {
val = new SVGNumber(val)
- } else if (Color.isColor(val)) {
+ } else if (colorAttributes.has(attr) && Color.isColor(val)) {
// ensure full hex color
val = new Color(val)
} else if (val.constructor === Array) {