Skip to content

Commit 5ab0ea7

Browse files
committed
Address comments
1 parent 18e8980 commit 5ab0ea7

File tree

5 files changed

+19
-29
lines changed

5 files changed

+19
-29
lines changed

src/demo-app/input/input-container-demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ <h4>Textarea</h4>
188188
</p>
189189

190190
<p>
191-
<md-input-container [floatingPlaceholder]="floatingLabel">
191+
<md-input-container [floatPlaceholder]="floatingLabel">
192192
<input mdInput placeholder="Placeholder">
193193
</md-input-container>
194194
</p>

src/lib/input/input-container-errors.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,3 @@ export class MdInputContainerMissingMdInputError extends MdError {
2828
'to the native input or textarea element?');
2929
}
3030
}
31-
32-
export class MdInputContainerFloatingPlaceholderInvalidError extends MdError {
33-
constructor(value: string) {
34-
super(`The value "${value}" for the floatingPlaceholder input is not valid.`);
35-
}
36-
}

src/lib/input/input-container.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('MdInputContainer', function () {
6060

6161
let inputContainer = fixture.debugElement.query(By.directive(MdInputContainer))
6262
.componentInstance as MdInputContainer;
63-
expect(inputContainer.floatingPlaceholder).toBe('auto',
63+
expect(inputContainer.floatPlaceholder).toBe('auto',
6464
'Expected MdInputContainer to set floatingLabel to auto by default.');
6565
});
6666

@@ -406,7 +406,7 @@ describe('MdInputContainer', function () {
406406
expect(textarea).not.toBeNull();
407407
});
408408

409-
it('should float when floatingPlaceholder is set to default and text is entered', () => {
409+
it('should float when floatPlaceholder is set to default and text is entered', () => {
410410
let fixture = TestBed.createComponent(MdInputContainerWithDynamicPlaceholder);
411411
fixture.detectChanges();
412412

@@ -432,7 +432,7 @@ describe('MdInputContainer', function () {
432432
expect(labelEl.classList).toContain('md-float');
433433
});
434434

435-
it('should always float the placeholder when floatingPlaceholder is set to true', () => {
435+
it('should always float the placeholder when floatPlaceholder is set to true', () => {
436436
let fixture = TestBed.createComponent(MdInputContainerWithDynamicPlaceholder);
437437
fixture.detectChanges();
438438

@@ -455,7 +455,7 @@ describe('MdInputContainer', function () {
455455
});
456456

457457

458-
it('should never float the placeholder when floatingPlaceholder is set to false', () => {
458+
it('should never float the placeholder when floatPlaceholder is set to false', () => {
459459
let fixture = TestBed.createComponent(MdInputContainerWithDynamicPlaceholder);
460460

461461
fixture.componentInstance.shouldFloat = 'never';
@@ -646,7 +646,7 @@ class MdInputContainerWithValueBinding {
646646

647647
@Component({
648648
template: `
649-
<md-input-container floatingPlaceholder="never">
649+
<md-input-container floatPlaceholder="never">
650650
<input mdInput placeholder="Label">
651651
</md-input-container>
652652
`
@@ -655,8 +655,8 @@ class MdInputContainerWithStaticPlaceholder {}
655655

656656
@Component({
657657
template: `
658-
<md-input-container [floatingPlaceholder]="shouldFloat">
659-
<input md-input placeholder="Label">
658+
<md-input-container [floatPlaceholder]="shouldFloat">
659+
<input mdInput placeholder="Label">
660660
</md-input-container>`
661661
})
662662
class MdInputContainerWithDynamicPlaceholder {

src/lib/input/input-container.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
MdInputContainerUnsupportedTypeError,
2121
MdInputContainerPlaceholderConflictError,
2222
MdInputContainerDuplicatedHintError,
23-
MdInputContainerMissingMdInputError, MdInputContainerFloatingPlaceholderInvalidError
23+
MdInputContainerMissingMdInputError
2424
} from './input-container-errors';
2525

2626

@@ -38,9 +38,8 @@ const MD_INPUT_INVALID_TYPES = [
3838
'submit'
3939
];
4040

41-
/** Valid options for the floatingPlaceholder input binding. */
42-
export type MD_INPUT_PLACEHOLDER_TYPES = 'always' | 'never' | 'auto';
43-
const MD_INPUT_PLACEHOLDER_VALUES = ['always', 'never', 'auto'];
41+
/** Type for the available floatPlaceholder values. */
42+
export type FloatPlaceholderType = 'always' | 'never' | 'auto';
4443

4544
let nextUniqueId = 0;
4645

@@ -248,10 +247,10 @@ export class MdInputContainer implements AfterContentInit {
248247
@Input() dividerColor: 'primary' | 'accent' | 'warn' = 'primary';
249248

250249
/** Whether the floating label should always float or not. */
251-
get _shouldAlwaysFloat() { return this._floatingPlaceholder === 'always'; };
250+
get _shouldAlwaysFloat() { return this._floatPlaceholder === 'always'; };
252251

253252
/** Whether the placeholder can float or not. */
254-
get _canPlaceholderFloat() { return this._floatingPlaceholder !== 'never'; }
253+
get _canPlaceholderFloat() { return this._floatPlaceholder !== 'never'; }
255254

256255
/** Text for the input hint. */
257256
@Input()
@@ -264,14 +263,11 @@ export class MdInputContainer implements AfterContentInit {
264263

265264
/** Whether the placeholder should always float, never float or float as the user types. */
266265
@Input()
267-
get floatingPlaceholder() { return this._floatingPlaceholder; }
268-
set floatingPlaceholder(value: MD_INPUT_PLACEHOLDER_TYPES) {
269-
if (value && MD_INPUT_PLACEHOLDER_VALUES.indexOf(value) === -1) {
270-
throw new MdInputContainerFloatingPlaceholderInvalidError(value);
271-
}
272-
this._floatingPlaceholder = value || 'auto';
266+
get floatPlaceholder() { return this._floatPlaceholder; }
267+
set floatPlaceholder(value: FloatPlaceholderType) {
268+
this._floatPlaceholder = value || 'auto';
273269
}
274-
private _floatingPlaceholder: MD_INPUT_PLACEHOLDER_TYPES = 'auto';
270+
private _floatPlaceholder: FloatPlaceholderType = 'auto';
275271

276272
@ContentChild(MdInputDirective) _mdInputChild: MdInputDirective;
277273

src/lib/input/input.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ be used with `md-input-container`:
3838
A placeholder is an indicative text displayed in the input zone when the input does not contain
3939
text. When text is present, the indicative text will float above this input zone.
4040

41-
The `floatingPlaceholder` attribute of `md-input-container` can be set to `never` to hide the
41+
The `floatPlaceholder` attribute of `md-input-container` can be set to `never` to hide the
4242
indicative text instead when text is present in the input.
4343

44-
When setting `floatingPlaceholder` to `always` the floating label will always show above the input.
44+
When setting `floatPlaceholder` to `always` the floating label will always show above the input.
4545

4646
A placeholder for the input can be specified in one of two ways: either using the `placeholder`
4747
attribute on the `input` or `textarea`, or using an `md-placeholder` element in the

0 commit comments

Comments
 (0)