Skip to content

Commit 4c8ea60

Browse files
committed
fix: Fix text positioning, wrong trim() call
1 parent ddef4a3 commit 4c8ea60

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ const ACCEPTED_SVG_ELEMENTS = [
4343

4444
// Attributes from SVG elements that are mapped directly.
4545
const SVG_ATTS = ["viewBox", "width", "height"];
46-
const G_ATTS = ["id"];
46+
const G_ATTS = ["id", "fill", "textAnchor", "fontFamily"];
4747

4848
const CIRCLE_ATTS = ["cx", "cy", "r"];
4949
const PATH_ATTS = ["d"];
5050
const RECT_ATTS = ["width", "height"];
5151
const LINE_ATTS = ["x1", "y1", "x2", "y2"];
5252
const LINEARG_ATTS = LINE_ATTS.concat(["id", "gradientUnits"]);
5353
const RADIALG_ATTS = CIRCLE_ATTS.concat(["id", "gradientUnits"]);
54-
const STOP_ATTS = ["offset"];
54+
const STOP_ATTS = ["offset", "stopOpacity", "stopColor"];
5555
const ELLIPSE_ATTS = ["cx", "cy", "rx", "ry"];
5656

5757
const TEXT_ATTS = ["fontFamily", "fontSize", "fontWeight"];
@@ -76,7 +76,9 @@ const COMMON_ATTS = [
7676
"scale",
7777
"origin",
7878
"originX",
79-
"originY"
79+
"originY",
80+
"stopOpacity",
81+
"stopColor"
8082
];
8183

8284
let ind = 0;
@@ -164,7 +166,7 @@ class SvgUri extends Component {
164166
trimElementChilden(children) {
165167
for (child of children) {
166168
if (typeof child === "string") {
167-
if (child.trim.length === 0)
169+
if (child.trim().length === 0)
168170
children.splice(children.indexOf(child), 1);
169171
}
170172
}
@@ -270,9 +272,7 @@ class SvgUri extends Component {
270272
);
271273
case "text":
272274
componentAtts = this.obtainComponentAtts(node, TEXT_ATTS);
273-
if (componentAtts.y) {
274-
componentAtts.y = fixYPosition(componentAtts.y, node);
275-
}
275+
276276
return (
277277
<Text key={i} {...componentAtts}>
278278
{childs}

0 commit comments

Comments
 (0)