Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/space/space.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { toArray } from 'lodash-es';
import { classNames, Component, OmiProps, tag } from 'omi';

import { getClassPrefix } from '../_util/classname';
import { convertNodeListToVNodes } from '../_util/component';
import { type StyledProps } from '../common';
import { TdSpaceProps } from './type';

Expand Down Expand Up @@ -42,10 +43,6 @@ export default class Space extends Component<SpaceProps> {
this.updateHostStyle();
}

updated() {
this.updateHostStyle();
}

updateHostStyle() {
if (Array.isArray(this.props.size)) {
this.renderGap = this.props.size
Expand Down Expand Up @@ -90,7 +87,13 @@ export default class Space extends Component<SpaceProps> {
}

beforeRender(): void {
this.innerHTML = '';
// 兼容react环境:如果props.children为空,从light dom获取子节点
const childrenArr = toArray(this.props.children);
if (childrenArr.length === 0 && this.childNodes.length > 0) {
this.props.children = convertNodeListToVNodes(this.childNodes);
}

this.updateHostStyle();
}

render(props: OmiProps<SpaceProps>) {
Expand Down
Loading