Skip to content

Commit ab46368

Browse files
committed
fix(Quote): Trim children spaces, set empty to undefined. fix #86
1 parent a2e451f commit ab46368

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

core/src/symbol/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ export const Quote = <T extends object>(
1111
const { as, render, ...reset } = Comp;
1212
const Elm = as || 'span';
1313
const elmProps = { ...other, ...reset };
14+
// Trim the leading and trailing spaces in children,
15+
// and set it to undefined if it's an empty string or contains only spaces.
16+
// https://github.com/uiwjs/react-json-view/issues/86
17+
if (typeof elmProps.children === 'string') {
18+
const trimmed = elmProps.children.trim();
19+
elmProps.children = trimmed || undefined;
20+
}
1421
let result = { value, parentValue, keyName, keys: keys || (keyName ? [keyName] : []) };
1522
const child = render && typeof render === 'function' && render(elmProps, result);
1623
if (child) return child;

0 commit comments

Comments
 (0)