@@ -36,14 +36,14 @@ export default class PaperInput extends Focusable {
3636 * @type {HTMLInputElement }
3737 * @private
3838 */
39- # inputElement;
39+ inputElement ;
4040 /**
4141 * The parent this component is bound to.
4242 *
4343 * @type {PaperRadioGroup|PaperForm|PaperItem|PaperTabs }
4444 * @private
4545 */
46- # parent;
46+ parent ;
4747 /**
4848 * Marks whether the component should register itself to the supplied parent.
4949 *
@@ -97,6 +97,7 @@ export default class PaperInput extends Focusable {
9797 this . args . elementId || this . args . inputElementId || guidFor ( this ) ;
9898 this . inputElementId = this . args . inputElementId || `input-${ elementId } ` ;
9999 this . lineHeight = this . args . lineHeight || null ;
100+ this . shouldRegister = this . args . shouldRegister ?? true ;
100101
101102 // Construct Input Validation and pass through of custom attributes.
102103 this . validation = new Validation (
@@ -109,12 +110,9 @@ export default class PaperInput extends Focusable {
109110 this . args . isTouched
110111 ) ;
111112
112- if ( this . shouldRegister ) {
113- assert (
114- 'A parent component should be supplied to <PaperInput> when shouldRegister=true' ,
115- this . args . parentComponent
116- ) ;
117- this . #parent = this . args . parentComponent ;
113+ let parentComponent = this . args . parentComponent ;
114+ if ( parentComponent && this . shouldRegister ) {
115+ this . parent = parentComponent ;
118116 }
119117
120118 assert (
@@ -132,7 +130,7 @@ export default class PaperInput extends Focusable {
132130 this . registerListeners ( element ) ;
133131
134132 let inputElement = element . querySelector ( 'input, textarea' ) ;
135- this . # inputElement = inputElement ;
133+ this . inputElement = inputElement ;
136134 this . validation . didInsertNode ( inputElement ) ;
137135
138136 // setValue ensures that the input value is the same as this.value
@@ -143,8 +141,9 @@ export default class PaperInput extends Focusable {
143141 window . addEventListener ( 'resize' , this . growTextarea . bind ( this ) ) ;
144142 }
145143
146- if ( this . shouldRegister ) {
147- this . #parent. registerChild ( this ) ;
144+ let parent = this . parent ;
145+ if ( parent && this . shouldRegister ) {
146+ parent . registerChild ( this ) ;
148147 }
149148 }
150149
@@ -180,8 +179,9 @@ export default class PaperInput extends Focusable {
180179 willDestroy ( ) {
181180 super . willDestroy ( ...arguments ) ;
182181
183- if ( this . shouldRegister ) {
184- this . #parent. unregisterChild ( this ) ;
182+ let parent = this . parent ;
183+ if ( parent && this . shouldRegister ) {
184+ parent . unregisterChild ( this ) ;
185185 }
186186 }
187187
@@ -307,7 +307,7 @@ export default class PaperInput extends Focusable {
307307 */
308308 growTextarea ( ) {
309309 if ( this . args . textarea ) {
310- let inputElement = this . # inputElement;
310+ let inputElement = this . inputElement ;
311311
312312 inputElement . classList . add ( 'md-no-flex' ) ;
313313 inputElement . setAttribute ( 'rows' , '1' ) ;
@@ -318,7 +318,7 @@ export default class PaperInput extends Focusable {
318318 let lineHeight = this . lineHeight ;
319319 if ( ! lineHeight ) {
320320 inputElement . style . minHeight = '0' ;
321- lineHeight = this . # inputElement. clientHeight ;
321+ lineHeight = this . inputElement . clientHeight ;
322322 inputElement . style . minHeight = null ;
323323 }
324324 if ( lineHeight ) {
@@ -372,8 +372,8 @@ export default class PaperInput extends Focusable {
372372 // normalize falsy values to empty string
373373 value = isEmpty ( value ) ? '' : value ;
374374
375- if ( this . # inputElement. value !== value ) {
376- this . # inputElement. value = value ;
375+ if ( this . inputElement . value !== value ) {
376+ this . inputElement . value = value ;
377377 }
378378
379379 // Calculate Input Validity
0 commit comments