Skip to content

Commit 00d537b

Browse files
committed
Pass user-defined attributes to the container element
1 parent 9d9f228 commit 00d537b

File tree

3 files changed

+18
-152
lines changed

3 files changed

+18
-152
lines changed

lib/index.js

Lines changed: 0 additions & 146 deletions
This file was deleted.

src/index.jsx renamed to src/Sortable.jsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
/* eslint consistent-return: 0 */
12
import PropTypes from 'prop-types';
23
import React, { Component } from 'react';
34
import ReactDOM from 'react-dom';
4-
import Sortable from 'sortablejs';
5+
import SortableJS from 'sortablejs';
56

67
const store = {
78
nextSibling: null,
89
activeComponent: null
910
};
1011

11-
module.exports = class extends Component {
12+
class Sortable extends Component {
1213
static propTypes = {
1314
options: PropTypes.object,
1415
onChange: PropTypes.func,
@@ -75,10 +76,10 @@ module.exports = class extends Component {
7576
setTimeout(() => {
7677
eventHandler && eventHandler(evt);
7778
}, 0);
78-
}
79+
};
7980
});
8081

81-
this.sortable = Sortable.create(ReactDOM.findDOMNode(this), options);
82+
this.sortable = SortableJS.create(ReactDOM.findDOMNode(this), options);
8283
}
8384
componentWillUnmount() {
8485
if (this.sortable) {
@@ -87,7 +88,15 @@ module.exports = class extends Component {
8788
}
8889
}
8990
render() {
90-
const { children, className, tag, style } = this.props;
91-
return React.DOM[tag]({ className, style }, children);
91+
const { tag: Component, ...props } = this.props;
92+
93+
delete props.options;
94+
delete props.onChange;
95+
96+
return (
97+
<Component {...props} />
98+
);
9299
}
93100
}
101+
102+
export default Sortable;

src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Sortable from './Sortable';
2+
3+
module.exports = Sortable;

0 commit comments

Comments
 (0)