@@ -44,13 +44,13 @@ class Field<T> {
44
44
) {
45
45
this . $_valueRef = isRef ( value ) ? value : shallowRef ( value ) ;
46
46
47
- const initialSchema = typeof schema === "function" ? schema ( ) : schema ;
47
+ const isSchemaTypeFunction = typeof schema === "function" ;
48
+ const initialSchema = isSchemaTypeFunction ? schema ( ) : schema ;
48
49
const isNumberSchemaField = initialSchema instanceof NumberSchema ;
49
50
this . $_errorRef = computed (
50
51
schema
51
52
? ( ) => {
52
- const obtainedSchema =
53
- typeof schema === "function" ? schema ( ) : schema ;
53
+ const obtainedSchema = isSchemaTypeFunction ? schema ( ) : schema ;
54
54
55
55
// Changing `<input type="number" v-model.number="foo" />` to blank, `foo` is set to empty string.
56
56
const targetValue =
@@ -117,11 +117,13 @@ class FormsField<T extends (arg: any) => Form> {
117
117
this . $_formsRef = shallowRef ( [ ] ) ;
118
118
this . $initialize ( initialValueListOrLength ) ;
119
119
120
+ const isSchemaTypeFunction = typeof schema === "function" ;
120
121
this . $_errorRef = computed (
121
122
schema
122
123
? ( ) => {
123
- const obtainedSchema =
124
- typeof schema === "function" ? schema ( new ArraySchema ( ) ) : schema ;
124
+ const obtainedSchema = isSchemaTypeFunction
125
+ ? schema ( new ArraySchema ( ) )
126
+ : schema ;
125
127
126
128
try {
127
129
obtainedSchema . validateSync (
@@ -137,8 +139,9 @@ class FormsField<T extends (arg: any) => Form> {
137
139
: ( ) => undefined
138
140
) ;
139
141
140
- const initialSchema =
141
- typeof schema === "function" ? schema ( new ArraySchema ( ) ) : schema ;
142
+ const initialSchema = isSchemaTypeFunction
143
+ ? schema ( new ArraySchema ( ) )
144
+ : schema ;
142
145
this . $label = initialSchema ?. describe ( ) . label || "" ;
143
146
}
144
147
0 commit comments