Skip to content

Commit cc745c7

Browse files
committed
allow custom child elements
also add a comment for anyone unfamiliar with the input style
1 parent 27435a3 commit cc745c7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var FileInput = React.createClass({
88
parent: {
99
position: 'relative'
1010
},
11+
// "invisible" above the text
1112
file: {
1213
position: 'absolute',
1314
top: 0,
@@ -32,6 +33,7 @@ var FileInput = React.createClass({
3233
},
3334

3435
render: function() {
36+
3537
return React.DOM.div({
3638
style: this.state.styles.parent
3739
},
@@ -47,8 +49,8 @@ var FileInput = React.createClass({
4749
style: this.state.styles.file
4850
}),
4951

50-
// Emulated file input
51-
React.DOM.input({
52+
// Emulated file input for when there are no children
53+
this.props.children || React.DOM.input({
5254
type: 'text',
5355
tabIndex: -1,
5456
name: this.props.name + '_filename',
@@ -58,7 +60,8 @@ var FileInput = React.createClass({
5860
placeholder: this.props.placeholder,
5961
disabled: this.props.disabled,
6062
style: this.state.styles.text
61-
}));
63+
})
64+
);
6265
}
6366
});
6467

0 commit comments

Comments
 (0)