Skip to content

Commit

Permalink
Merge 0773a09 into 7686339
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Dec 18, 2018
2 parents 7686339 + 0773a09 commit 08b3070
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions examples/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,15 @@ class Test extends React.Component {
>
<Upload
{...this.uploaderProps}
id="test"
component="div"
style={{ display: 'inline-block' }}
>
<a>开始上传2</a>
</Upload>
</div>

<label htmlFor="test">Label for Upload</label>
</div>

<button onClick={this.destroy}>destroy</button>
Expand Down
4 changes: 3 additions & 1 deletion src/AjaxUploader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import traverseFileTree from './traverseFileTree';

class AjaxUploader extends Component {
static propTypes = {
id: PropTypes.string,
component: PropTypes.string,
style: PropTypes.object,
prefixCls: PropTypes.string,
Expand Down Expand Up @@ -197,7 +198,7 @@ class AjaxUploader extends Component {

render() {
const {
component: Tag, prefixCls, className, disabled,
component: Tag, prefixCls, className, disabled, id,
style, multiple, accept, children, directory, openFileDialogOnClick,
} = this.props;
const cls = classNames({
Expand All @@ -220,6 +221,7 @@ class AjaxUploader extends Component {
style={style}
>
<input
id={id}
type="file"
ref={this.saveFileInput}
key={this.state.uid}
Expand Down
7 changes: 7 additions & 0 deletions tests/uploader.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ describe('uploader', () => {
ReactDOM.unmountComponentAtNode(node);
});

it('with id', (done) => {
ReactDOM.render(<Uploader id="bamboo" />, node, function init() {
expect(TestUtils.findRenderedDOMComponentWithTag(this, 'input').id).to.be('bamboo');
done();
});
});

it('create works', () => {
expect(TestUtils.scryRenderedDOMComponentsWithTag(uploader, 'span').length).to.be(1);
});
Expand Down

0 comments on commit 08b3070

Please sign in to comment.