Skip to content

Commit 07f5fc4

Browse files
committed
fix: added placeholder attribute for input
1 parent 91ebd2f commit 07f5fc4

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

packages/input/src/LionInput.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ export class LionInput extends LionField {
3030
type: Number,
3131
reflect: true,
3232
},
33+
placeholder: {
34+
type: String,
35+
reflect: true,
36+
},
3337
};
3438
}
3539

@@ -80,6 +84,9 @@ export class LionInput extends LionField {
8084
if (changedProps.has('step')) {
8185
this.inputElement.step = this.step;
8286
}
87+
if (changedProps.has('placeholder')) {
88+
this.inputElement.placeholder = this.placeholder;
89+
}
8390
}
8491

8592
__delegateReadOnly() {

packages/input/test/lion-input.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,15 @@ describe('<lion-input>', () => {
3838
expect(el.getAttribute('type')).to.equal('foo');
3939
expect(el.inputElement.getAttribute('type')).to.equal('foo');
4040
});
41+
42+
it('has an attribute that can be used to set the placeholder text of the input', async () => {
43+
const el = await fixture(`<lion-input placeholder="text"></lion-input>`);
44+
expect(el.getAttribute('placeholder')).to.equal('text');
45+
expect(el.inputElement.getAttribute('placeholder')).to.equal('text');
46+
47+
el.placeholder = 'foo';
48+
await el.updateComplete;
49+
expect(el.getAttribute('placeholder')).to.equal('foo');
50+
expect(el.inputElement.getAttribute('placeholder')).to.equal('foo');
51+
});
4152
});

0 commit comments

Comments
 (0)