Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit 3269ce8

Browse files
committed
Adding <Control.password>. Addresses #739
1 parent b587228 commit 3269ce8

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/components/control-component.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,24 @@ function createControlClass(s = defaultStrategy) {
747747

748748
DefaultConnectedControl.text = DefaultConnectedControlText;
749749

750+
class DefaultConnectedControlPassword extends DefaultConnectedControl {
751+
render() {
752+
return (
753+
<ConnectedControl
754+
component="input"
755+
{...this.props}
756+
mapProps={{
757+
...controlPropsMap.text,
758+
type: this.props.type || 'password',
759+
...this.props.mapProps,
760+
}}
761+
/>
762+
);
763+
}
764+
}
765+
766+
DefaultConnectedControl.password = DefaultConnectedControlPassword;
767+
750768
class DefaultConnectedControlTextArea extends DefaultConnectedControl {
751769
render() {
752770
return (

test/control-component-spec.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ Object.keys(testContexts).forEach((testKey) => {
153153
const textFieldElements = [
154154
[''],
155155
['text'],
156+
['password'],
156157
['text', 'email'],
157158
['input', 'text'],
158159
['input', 'password'],
@@ -220,9 +221,9 @@ Object.keys(testContexts).forEach((testKey) => {
220221
'testing again');
221222
});
222223

223-
if (controlType === 'text' && !type) {
224-
it('should have a type="text"', () => {
225-
assert.equal(node.getAttribute('type'), 'text');
224+
if ((controlType === 'text' || controlType === 'password') && !type) {
225+
it(`should have a type="${controlType}"`, () => {
226+
assert.equal(node.getAttribute('type'), controlType);
226227
});
227228
} else {
228229
it('should have the appropriate type attribute', () => {

0 commit comments

Comments
 (0)