@@ -10,11 +10,17 @@ import {
1010 ViewEncapsulation ,
1111 Optional ,
1212 Output ,
13- EventEmitter
13+ EventEmitter ,
14+ Renderer
1415} from '@angular/core' ;
15- import { MdError , coerceBooleanProperty } from '../core' ;
16+ import { coerceBooleanProperty } from '../core' ;
1617import { NgModel } from '@angular/forms' ;
1718import { MdFeatureDetector } from '../core/platform/feature-detector' ;
19+ import {
20+ MdInputWrapperUnsupportedTypeError ,
21+ MdInputWrapperPlaceholderConflictError ,
22+ MdInputWrapperDuplicatedHintError
23+ } from './input-wrapper-errors' ;
1824
1925
2026// Invalid input type. Using one of these will throw an MdInputWrapperUnsupportedTypeError.
@@ -35,27 +41,6 @@ const MD_INPUT_INVALID_TYPES = [
3541let nextUniqueId = 0 ;
3642
3743
38- export class MdInputWrapperPlaceholderConflictError extends MdError {
39- constructor ( ) {
40- super ( 'Placeholder attribute and child element were both specified.' ) ;
41- }
42- }
43-
44-
45- export class MdInputWrapperUnsupportedTypeError extends MdError {
46- constructor ( type : string ) {
47- super ( `Input type "${ type } " isn't supported by md-input-wrapper.` ) ;
48- }
49- }
50-
51-
52- export class MdInputWrapperDuplicatedHintError extends MdError {
53- constructor ( align : string ) {
54- super ( `A hint was already declared for 'align="${ align } "'.` ) ;
55- }
56- }
57-
58-
5944/**
6045 * The placeholder directive. The content can declare this to implement more
6146 * complex placeholders.
@@ -107,7 +92,7 @@ export class MdInputDirective implements AfterContentInit {
10792 set placeholder ( value : string ) {
10893 if ( this . _placeholder != value ) {
10994 this . _placeholder = value ;
110- this . placeholderChange . emit ( this . _placeholder ) ;
95+ this . _placeholderChange . emit ( this . _placeholder ) ;
11196 }
11297 }
11398 private _placeholder = '' ;
@@ -125,10 +110,10 @@ export class MdInputDirective implements AfterContentInit {
125110 }
126111 private _type = 'text' ;
127112
128- @Input ( )
129113 value : any ;
130114
131- @Output ( ) placeholderChange = new EventEmitter < string > ( ) ;
115+ /** Emits an event when the placeholder changes so that the `md-input-wrapper` can re-validate. */
116+ @Output ( ) _placeholderChange = new EventEmitter < string > ( ) ;
132117
133118 get empty ( ) { return ( this . value == null || this . value == '' ) && ! this . _isNeverEmpty ( ) ; }
134119
@@ -148,6 +133,7 @@ export class MdInputDirective implements AfterContentInit {
148133
149134 constructor ( private _featureDetector : MdFeatureDetector ,
150135 private _elementRef : ElementRef ,
136+ private _renderer : Renderer ,
151137 @Optional ( ) private _ngModel : NgModel ) {
152138 // Force setter to be called in case id was not specified.
153139 this . id = this . id ;
@@ -164,7 +150,7 @@ export class MdInputDirective implements AfterContentInit {
164150 }
165151
166152 /** Focus the input element. */
167- focus ( ) { this . _elementRef . nativeElement . focus ( ) ; }
153+ focus ( ) { this . _renderer . invokeElementMethod ( this . _elementRef . nativeElement , ' focus' ) ; }
168154
169155 /** Make sure the input is a supported type. */
170156 private _validateType ( ) {
@@ -231,7 +217,7 @@ export class MdInputWrapper implements AfterContentInit {
231217 this . _hintChildren . changes . subscribe ( ( ) => {
232218 this . _validateHints ( ) ;
233219 } ) ;
234- this . _mdInputChild . placeholderChange . subscribe ( ( ) => {
220+ this . _mdInputChild . _placeholderChange . subscribe ( ( ) => {
235221 this . _validatePlaceholders ( ) ;
236222 } ) ;
237223 }
0 commit comments