Skip to content

Commit

Permalink
feat: allow all standard input type attributes
Browse files Browse the repository at this point in the history
closes #80
  • Loading branch information
ro-ka committed Jan 18, 2016
1 parent fd9eb24 commit a43c388
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Geosuggest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import React from 'react';
import GeosuggestItem from './GeosuggestItem'; // eslint-disable-line
import inputAttributes from './input-attributes';

const Geosuggest = React.createClass({
/**
Expand Down Expand Up @@ -349,16 +350,23 @@ const Geosuggest = React.createClass({
* @return {Function} The React element to render
*/
render: function() {
const attributes = {};

inputAttributes.forEach(inputAttribute => {
if (this.props[inputAttribute]) {
attributes[inputAttribute] = this.props[inputAttribute];
}
});

return (// eslint-disable-line no-extra-parens
<div className={'geosuggest ' + this.props.className}
onClick={this.onClick}>
<input
className={'geosuggest__input ' + this.props.inputClassName}
ref="geosuggestInput"
type="text"
{...attributes}
value={this.state.userInput}
placeholder={this.props.placeholder}
disabled={this.props.disabled}
onKeyDown={this.onInputKeyDown}
onChange={this.onInputChange}
onFocus={this.onFocus}
Expand Down
30 changes: 30 additions & 0 deletions src/input-attributes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Attributes allowed on input elements
*/
export default [
'autocapitalize',
'autocomplete',
'autocorrect',
'autofocus',
'autosave',
'disabled',
'form',
'formaction',
'formenctype',
'formmethod',
'formnovalidate',
'formtarget',
'height',
'inputmode',
'maxlength',
'maxlength',
'name',
'pattern',
'placeholder',
'readonly',
'required',
'selectionDirection',
'size',
'spellcheck',
'tabindex'
];

0 comments on commit a43c388

Please sign in to comment.