Skip to content

Commit 2c0d11b

Browse files
committed
fix dom is null
1 parent 3fb4135 commit 2c0d11b

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ ReactDom.render(
6161
| defaultOpen | boolean | false | default open menu |
6262
| width | string | `60vw` | children width |
6363
| placement | string | `left` | `left` or `right` |
64-
| level | string or array | `all` | With the drawer level element. `all` / className / id / tagName / array |
64+
| level | string or array | `all` | With the drawer level element. `all`/ null / className / id / tagName / array |
6565
| levelTransition | string | `transform .3s cubic-bezier(0.78, 0.14, 0.15, 0.86)` | level css transition |
66-
| parent | string | `body` | parent element. |
66+
| parent | string | `body` | parent element. if is `null` use React.creactElement |
6767
| onChange | function | null | change callback(open) |
6868
| onSwitch | function | null | icon or bg click function |
6969

examples/change.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Demo extends React.Component {
3939
onChange={this.onChange}
4040
open={this.state.open}
4141
onSwitch={this.onTouchEnd}
42-
iconChild={null}
42+
iconChild={false}
4343
level={null}
4444
>
4545
<Menu

src/Drawer.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ class Drawer extends React.PureComponent {
4949
};
5050
}
5151
componentDidMount() {
52-
this.container = this.props.parent ? this.defaultGetContainer() : ReactDOM.findDOMNode(this);
52+
this.dom = ReactDOM.findDOMNode(this);
5353
this.getParentAndLevelDom();
54+
this.container = this.props.parent ? this.defaultGetContainer() : this.dom;
5455
this.forceUpdate();
5556
}
5657

@@ -95,7 +96,7 @@ class Drawer extends React.PureComponent {
9596
}
9697
const { level, parent } = this.props;
9798
this.levelDom = [];
98-
this.parent = parent && document.querySelectorAll(parent)[0] || this.container.parentNode;
99+
this.parent = parent && document.querySelectorAll(parent)[0] || this.dom.parentNode;
99100
if (level === 'all') {
100101
const children = Array.prototype.slice.call(this.parent.children);
101102
children.forEach(child => {

0 commit comments

Comments
 (0)