slight refacter
This commit is contained in:
parent
fd8f0fcecf
commit
1d465c61ef
|
@ -32,18 +32,17 @@ export function psJSXMap(ps: T.PsJSX, target: "p" | "f", dealWithString: (ps: T.
|
||||||
p: (target === "p" ? base : sec).props.children,
|
p: (target === "p" ? base : sec).props.children,
|
||||||
f: (target === "p" ? sec : base).props.children,
|
f: (target === "p" ? sec : base).props.children,
|
||||||
})
|
})
|
||||||
: base.props.children.map((x: string | JSX.Element, i: number) => {
|
: base.props.children.map((x: string | JSX.Element, i: number) => (
|
||||||
if (typeof x === "string") {
|
(typeof x === "string")
|
||||||
return dealWithString({
|
? dealWithString({
|
||||||
p: (target === "p" ? x : sec.props.children[i]),
|
p: (target === "p" ? x : sec.props.children[i]),
|
||||||
f: (target === "p" ? sec.props.children[i] : x),
|
f: (target === "p" ? sec.props.children[i] : x),
|
||||||
});
|
})
|
||||||
}
|
: psJSXMap({
|
||||||
return psJSXMap({
|
|
||||||
p: (target === "p" ? x : sec.props.children[i]),
|
p: (target === "p" ? x : sec.props.children[i]),
|
||||||
f: (target === "p" ? sec.props.children[i] : x),
|
f: (target === "p" ? sec.props.children[i] : x),
|
||||||
}, target, dealWithString);
|
}, target, dealWithString)
|
||||||
}),
|
)),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -68,12 +67,9 @@ export function JSXMap(e: JSX.Element, f: (s: string) => string): JSX.Element {
|
||||||
...e.props,
|
...e.props,
|
||||||
children: typeof e.props.children === "string"
|
children: typeof e.props.children === "string"
|
||||||
? f(e.props.children)
|
? f(e.props.children)
|
||||||
: e.props.children.map((x: string | JSX.Element) => {
|
: e.props.children.map((x: string | JSX.Element) => (
|
||||||
if (typeof x === "string") {
|
(typeof x === "string") ? f(x) : JSXMap(x, f)
|
||||||
return f(x);
|
)),
|
||||||
}
|
|
||||||
return JSXMap(x, f);
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
Loading…
Reference in New Issue