fix(tool): prevented reading on potentially undefined

This commit is contained in:
Corentin Thomasset 2021-05-31 23:36:16 +02:00
parent aa06b82337
commit 2a54b80de6
No known key found for this signature in database
GPG key ID: DBD997E935996158

View file

@ -93,7 +93,6 @@ export default class BaseConverter extends Tool {
@Ref() readonly inputBaseRef!: VForm @Ref() readonly inputBaseRef!: VForm
@Ref() readonly outputBaseRef!: VForm @Ref() readonly outputBaseRef!: VForm
isMounted = false
inputError = '' inputError = ''
inputNumber = '42' inputNumber = '42'
inputBase = 10 inputBase = 10
@ -105,12 +104,8 @@ export default class BaseConverter extends Tool {
(v: number) => v <= 64 || 'Base should be <= 64' (v: number) => v <= 64 || 'Base should be <= 64'
] ]
mounted() {
this.isMounted = true
}
get outputNumber() { get outputNumber() {
if (this.isMounted && this.inputBaseRef.validate() && this.outputBaseRef.validate()) { if (this.inputBaseRef?.validate() && this.outputBaseRef?.validate()) {
try { try {
return convertBase(this.inputNumber, this.inputBase, this.outputBase) return convertBase(this.inputNumber, this.inputBase, this.outputBase)
} catch (e) { } catch (e) {