@@ -56,11 +56,21 @@ export class AutofillMonitor implements OnDestroy {
56
56
* @param element The element to monitor.
57
57
* @return A stream of autofill state changes.
58
58
*/
59
- monitor ( element : Element ) : Observable < AutofillEvent > {
59
+ monitor ( element : Element ) : Observable < AutofillEvent > ;
60
+
61
+ /**
62
+ * Monitor for changes in the autofill state of the given input element.
63
+ * @param element The element to monitor.
64
+ * @return A stream of autofill state changes.
65
+ */
66
+ monitor ( element : ElementRef < Element > ) : Observable < AutofillEvent > ;
67
+
68
+ monitor ( elementOrRef : Element | ElementRef < Element > ) : Observable < AutofillEvent > {
60
69
if ( ! this . _platform . isBrowser ) {
61
70
return EMPTY ;
62
71
}
63
72
73
+ const element = elementOrRef instanceof ElementRef ? elementOrRef . nativeElement : elementOrRef ;
64
74
const info = this . _monitoredElements . get ( element ) ;
65
75
66
76
if ( info ) {
@@ -103,7 +113,16 @@ export class AutofillMonitor implements OnDestroy {
103
113
* Stop monitoring the autofill state of the given input element.
104
114
* @param element The element to stop monitoring.
105
115
*/
106
- stopMonitoring ( element : Element ) {
116
+ stopMonitoring ( element : Element ) ;
117
+
118
+ /**
119
+ * Stop monitoring the autofill state of the given input element.
120
+ * @param element The element to stop monitoring.
121
+ */
122
+ stopMonitoring ( element : ElementRef < Element > ) ;
123
+
124
+ stopMonitoring ( elementOrRef : Element | ElementRef < Element > ) {
125
+ const element = elementOrRef instanceof ElementRef ? elementOrRef . nativeElement : elementOrRef ;
107
126
const info = this . _monitoredElements . get ( element ) ;
108
127
109
128
if ( info ) {
@@ -133,11 +152,11 @@ export class CdkAutofill implements OnDestroy, OnInit {
133
152
134
153
ngOnInit ( ) {
135
154
this . _autofillMonitor
136
- . monitor ( this . _elementRef . nativeElement )
155
+ . monitor ( this . _elementRef )
137
156
. subscribe ( event => this . cdkAutofill . emit ( event ) ) ;
138
157
}
139
158
140
159
ngOnDestroy ( ) {
141
- this . _autofillMonitor . stopMonitoring ( this . _elementRef . nativeElement ) ;
160
+ this . _autofillMonitor . stopMonitoring ( this . _elementRef ) ;
142
161
}
143
162
}
0 commit comments