Harmonize parseSVGLengthList usage and naming. Probably requires api change in ios as well.

This commit is contained in:
Mikael Sand
2017-07-22 20:33:05 +03:00
parent 5372355b11
commit 6b022ac861
4 changed files with 106 additions and 76 deletions
+13 -10
View File
@@ -75,18 +75,20 @@ export function extractFont(props) {
return _.defaults(ownedFont, font);
}
function parseDelta(delta) {
function parseSVGLengthList(delta) {
if (typeof delta === 'string') {
return delta.trim().replace(commaReg, ' ').split(spaceReg);
} else if (typeof delta === 'number') {
return [delta];
return [delta.toString()];
} else if (delta && typeof delta.map === 'function') {
return delta.map(d => `${d}`);
} else {
return [];
}
}
export default function(props, container) {
const {
let {
x,
y,
dx,
@@ -99,14 +101,15 @@ export default function(props, container) {
textDecoration
} = props;
let positionX = parseSVGLengthList(x);
let positionY = parseSVGLengthList(y);
const deltaX = parseSVGLengthList(dx);
const deltaY = parseSVGLengthList(dy);
rotate = parseSVGLengthList(rotate);
const deltaX = parseDelta(dx);
const deltaY = parseDelta(dy);
const rotates = parseDelta(rotate);
let { children } = props;
let content = null;
if (typeof children === 'string' || typeof children === 'number') {
const childrenString = children.toString();
if (container) {
@@ -131,13 +134,13 @@ export default function(props, container) {
font: extractFont(props),
children,
content,
positionX,
positionY,
rotate,
deltaX,
deltaY,
rotate: rotates,
method,
spacing,
startOffset: (startOffset || 0).toString(),
positionX: _.isNil(x) ? null : x.toString(),
positionY: _.isNil(y) ? null : y.toString()
};
}