Skip to content

Commit

Permalink
fix(input): don't add empty prefix & suffix wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba committed Mar 22, 2017
1 parent c524438 commit 8fe05ab
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
19 changes: 15 additions & 4 deletions src/lib/input/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import {NgModule, ModuleWithProviders} from '@angular/core';
import {MdPlaceholder, MdInputContainer, MdHint, MdInputDirective} from './input-container';
import {ModuleWithProviders, NgModule} from '@angular/core';
import {
MdHint,
MdInputContainer,
MdInputDirective,
MdPlaceholder,
MdPrefix,
MdSuffix
} from './input-container';
import {MdTextareaAutosize} from './autosize';
import {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms';
Expand All @@ -12,7 +19,9 @@ import {PlatformModule} from '../core/platform/index';
MdInputContainer,
MdHint,
MdTextareaAutosize,
MdInputDirective
MdInputDirective,
MdPrefix,
MdSuffix,
],
imports: [
CommonModule,
Expand All @@ -24,7 +33,9 @@ import {PlatformModule} from '../core/platform/index';
MdInputContainer,
MdHint,
MdTextareaAutosize,
MdInputDirective
MdInputDirective,
MdPrefix,
MdSuffix,
],
})
export class MdInputModule {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/input/input-container.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="mat-input-wrapper">
<div class="mat-input-table">
<div class="mat-input-prefix">
<div class="mat-input-prefix" *ngIf="_prefixChildren.length">
<!-- TODO(andrewseguin): remove [md-prefix] -->
<ng-content select="[mdPrefix], [matPrefix], [md-prefix]"></ng-content>
</div>
Expand All @@ -23,7 +23,7 @@
</span>
</div>

<div class="mat-input-suffix">
<div class="mat-input-suffix" *ngIf="_suffixChildren.length">
<!-- TODO(andrewseguin): remove [md-suffix] -->
<ng-content select="[mdSuffix], [matSuffix], [md-suffix]"></ng-content>
</div>
Expand Down
18 changes: 18 additions & 0 deletions src/lib/input/input-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ export class MdHint {
}


/** The input prefix. */
@Directive({
selector: '[mdPrefix], [matPrefix], [md-prefix]'
})
export class MdPrefix {}


/** The input suffix. */
@Directive({
selector: '[mdSuffix], [matSuffix], [md-suffix]'
})
export class MdSuffix {}


/** The input directive, used to mark the input that `MdInputContainer` is wrapping. */
@Directive({
selector: `input[mdInput], textarea[mdInput], input[matInput], textarea[matInput]`,
Expand Down Expand Up @@ -289,6 +303,10 @@ export class MdInputContainer implements AfterContentInit {

@ContentChildren(MdHint) _hintChildren: QueryList<MdHint>;

@ContentChildren(MdPrefix) _prefixChildren: QueryList<MdPrefix>;

@ContentChildren(MdSuffix) _suffixChildren: QueryList<MdSuffix>;

ngAfterContentInit() {
if (!this._mdInputChild) {
throw new MdInputContainerMissingMdInputError();
Expand Down

0 comments on commit 8fe05ab

Please sign in to comment.