Skip to content

Commit

Permalink
Add md-input-has-placeholder class to input with placeholder (#1083)
Browse files Browse the repository at this point in the history
  • Loading branch information
Subtletree authored and miguelcobain committed May 16, 2019
1 parent 2652581 commit 9037a0d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
3 changes: 2 additions & 1 deletion addon/components/paper-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export default Component.extend(FocusableMixin, ColorMixin, ChildMixin, Validati
'hasLeftIcon:md-icon-left',
'hasRightIcon:md-icon-right',
'focused:md-input-focused',
'block:md-block'
'block:md-block',
'placeholder:md-input-has-placeholder'
],
type: 'text',
autofocus: false,
Expand Down
21 changes: 20 additions & 1 deletion tests/integration/components/paper-input-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ module('Integration | Component | paper-input', function(hooks) {
});

test('renders input with placeholder', async function(assert) {
assert.expect(1);
assert.expect(2);

await render(hbs`{{paper-input placeholder="Enter value here" onChange=dummyOnChange}}`);

assert.dom('md-input-container input').hasAttribute('placeholder', 'Enter value here');
assert.dom('md-input-container').hasClass('md-input-has-placeholder');

});

Expand Down Expand Up @@ -517,6 +518,24 @@ module('Integration | Component | paper-input', function(hooks) {
assert.dom('.other-stuff').exists();
});

test('does not have md-input-has-placeholder class when no placeholder', async function(assert) {
assert.expect(1);

await render(hbs`{{paper-input onChange=dummyOnChange}}`);

assert.dom('md-input-container').doesNotHaveClass('md-input-has-placeholder');

});

test('does not have md-input-has-placeholder class when there is a label', async function(assert) {
assert.expect(1);

await render(hbs`{{paper-input label="Label here" onChange=dummyOnChange}}`);

assert.dom('md-input-container').doesNotHaveClass('md-input-has-placeholder');

});

test('aria-describedby on input elements is set properly', async function(assert) {

let errors = [{
Expand Down

0 comments on commit 9037a0d

Please sign in to comment.