@@ -130,7 +130,8 @@ export class RadioButton extends Component<HTMLInputElement> implements INotifyP
130
130
131
131
private changeHandler ( event : Event ) : void {
132
132
this . checked = true ; this . dataBind ( ) ;
133
- let value : string = this . isVue ? this . element . value : this . value ;
133
+ let value : string = this . element . getAttribute ( 'value' ) ;
134
+ value = this . isVue && value ? this . element . value : this . value ;
134
135
this . trigger ( 'change' , < ChangeArgs > { value : value , event : event } ) ;
135
136
if ( this . tagName === 'EJS-RADIOBUTTON' ) {
136
137
event . stopPropagation ( ) ;
@@ -181,7 +182,10 @@ export class RadioButton extends Component<HTMLInputElement> implements INotifyP
181
182
}
182
183
183
184
private focusOutHandler ( ) : void {
184
- this . getLabel ( ) . classList . remove ( 'e-focus' ) ;
185
+ let label : Element = this . getLabel ( ) ;
186
+ if ( label ) {
187
+ label . classList . remove ( 'e-focus' ) ;
188
+ }
185
189
}
186
190
187
191
protected getModuleName ( ) : string {
@@ -215,7 +219,11 @@ export class RadioButton extends Component<HTMLInputElement> implements INotifyP
215
219
}
216
220
217
221
private getLabel ( ) : Element {
218
- return this . element . nextElementSibling ;
222
+ if ( this . element ) {
223
+ return this . element . nextElementSibling ;
224
+ } else {
225
+ return null ;
226
+ }
219
227
}
220
228
221
229
private initialize ( ) : void {
@@ -227,10 +235,11 @@ export class RadioButton extends Component<HTMLInputElement> implements INotifyP
227
235
if ( this . name ) {
228
236
this . element . setAttribute ( 'name' , this . name ) ;
229
237
}
230
- if ( this . isVue && this . element . value && this . element . value === this . value ) {
238
+ let value : string = this . element . getAttribute ( 'value' ) ;
239
+ if ( this . isVue && value && value === this . value ) {
231
240
this . checked = true ;
232
241
}
233
- if ( this . value && ( ! this . isVue || ! this . element . value ) ) {
242
+ if ( this . isVue ? this . value && ! value : this . value ) {
234
243
this . element . setAttribute ( 'value' , this . value ) ;
235
244
}
236
245
if ( this . checked ) {
@@ -393,18 +402,20 @@ export class RadioButton extends Component<HTMLInputElement> implements INotifyP
393
402
394
403
private setText ( text : string ) : void {
395
404
let label : Element = this . getLabel ( ) ;
396
- let textLabel : Element = label . getElementsByClassName ( LABEL ) [ 0 ] ;
397
- if ( textLabel ) {
398
- textLabel . textContent = text ;
399
- } else {
400
- text = ( this . enableHtmlSanitizer ) ? SanitizeHtmlHelper . sanitize ( text ) : text ;
401
- textLabel = this . createElement ( 'span' , { className : LABEL , innerHTML : text } ) ;
402
- label . appendChild ( textLabel ) ;
403
- }
404
- if ( this . labelPosition === 'Before' ) {
405
- this . getLabel ( ) . classList . add ( 'e-right' ) ;
406
- } else {
407
- this . getLabel ( ) . classList . remove ( 'e-right' ) ;
405
+ if ( label ) {
406
+ let textLabel : Element = label . getElementsByClassName ( LABEL ) [ 0 ] ;
407
+ if ( textLabel ) {
408
+ textLabel . textContent = text ;
409
+ } else {
410
+ text = ( this . enableHtmlSanitizer ) ? SanitizeHtmlHelper . sanitize ( text ) : text ;
411
+ textLabel = this . createElement ( 'span' , { className : LABEL , innerHTML : text } ) ;
412
+ label . appendChild ( textLabel ) ;
413
+ }
414
+ if ( this . labelPosition === 'Before' ) {
415
+ this . getLabel ( ) . classList . add ( 'e-right' ) ;
416
+ } else {
417
+ this . getLabel ( ) . classList . remove ( 'e-right' ) ;
418
+ }
408
419
}
409
420
}
410
421
0 commit comments