Merge pull request #376 from SwyserDev/fix/inputPlaceholder
fix: added placeholder attribute for input
This commit is contained in:
commit
a581a4e467
2 changed files with 18 additions and 0 deletions
|
|
@ -30,6 +30,10 @@ export class LionInput extends LionField {
|
||||||
type: Number,
|
type: Number,
|
||||||
reflect: true,
|
reflect: true,
|
||||||
},
|
},
|
||||||
|
placeholder: {
|
||||||
|
type: String,
|
||||||
|
reflect: true,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,6 +84,9 @@ export class LionInput extends LionField {
|
||||||
if (changedProps.has('step')) {
|
if (changedProps.has('step')) {
|
||||||
this.inputElement.step = this.step;
|
this.inputElement.step = this.step;
|
||||||
}
|
}
|
||||||
|
if (changedProps.has('placeholder')) {
|
||||||
|
this.inputElement.placeholder = this.placeholder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__delegateReadOnly() {
|
__delegateReadOnly() {
|
||||||
|
|
|
||||||
|
|
@ -38,4 +38,15 @@ describe('<lion-input>', () => {
|
||||||
expect(el.getAttribute('type')).to.equal('foo');
|
expect(el.getAttribute('type')).to.equal('foo');
|
||||||
expect(el.inputElement.getAttribute('type')).to.equal('foo');
|
expect(el.inputElement.getAttribute('type')).to.equal('foo');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('has an attribute that can be used to set the placeholder text of the input', async () => {
|
||||||
|
const el = await fixture(`<lion-input placeholder="text"></lion-input>`);
|
||||||
|
expect(el.getAttribute('placeholder')).to.equal('text');
|
||||||
|
expect(el.inputElement.getAttribute('placeholder')).to.equal('text');
|
||||||
|
|
||||||
|
el.placeholder = 'foo';
|
||||||
|
await el.updateComplete;
|
||||||
|
expect(el.getAttribute('placeholder')).to.equal('foo');
|
||||||
|
expect(el.inputElement.getAttribute('placeholder')).to.equal('foo');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue