fix(chips): unable to bind to chip input placeholder (#10855)

Fixes the value that is bound to the `placeholder` input not being assigned to the `placeholder` attribute.

Fixes #10848.
This commit is contained in:
Kristiyan Kostadinov
2018-04-26 00:58:11 -04:00
committed by Andrew Seguin
parent 4ae63b3900
commit acb0bd09e1
2 changed files with 18 additions and 3 deletions
+12 -2
View File
@@ -16,7 +16,6 @@ describe('MatChipInput', () => {
let inputDebugElement: DebugElement;
let inputNativeElement: HTMLElement;
let chipInputDirective: MatChipInput;
let dir = 'ltr';
beforeEach(async(() => {
@@ -56,6 +55,15 @@ describe('MatChipInput', () => {
it('should have a default id', () => {
expect(inputNativeElement.getAttribute('id')).toBeTruthy();
});
it('should allow binding to the `placeholder` input', () => {
expect(inputNativeElement.hasAttribute('placeholder')).toBe(false);
testChipInput.placeholder = 'bound placeholder';
fixture.detectChanges();
expect(inputNativeElement.getAttribute('placeholder')).toBe('bound placeholder');
});
});
describe('[addOnBlur]', () => {
@@ -142,11 +150,13 @@ describe('MatChipInput', () => {
</mat-chip-list>
<input matInput [matChipInputFor]="chipList"
[matChipInputAddOnBlur]="addOnBlur"
(matChipInputTokenEnd)="add($event)" />
(matChipInputTokenEnd)="add($event)"
[placeholder]="placeholder" />
`
})
class TestChipInput {
addOnBlur: boolean = false;
placeholder = '';
add(_: MatChipInputEvent) {
}
+6 -1
View File
@@ -38,6 +38,7 @@ let nextUniqueId = 0;
'(focus)': '_focus()',
'(input)': '_onInput()',
'[id]': 'id',
'[attr.placeholder]': 'placeholder || null',
}
})
export class MatChipInput {
@@ -75,7 +76,11 @@ export class MatChipInput {
@Output('matChipInputTokenEnd')
chipEnd: EventEmitter<MatChipInputEvent> = new EventEmitter<MatChipInputEvent>();
/** The input's placeholder text. */
/**
* The input's placeholder text.
* @deprecated Bind to the `placeholder` attribute directly.
* @deletion-target 7.0.0
*/
@Input() placeholder: string = '';
/** Unique id for the input. */