Skip to content

Commit eda559c

Browse files
committed
Fix rules with factory function as initialValue
1 parent b3b122c commit eda559c

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/QueryBuilderGroup.vue

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,20 +208,19 @@ export default class QueryBuilderGroup extends Vue implements QueryBuilderGroupI
208208
throw new Error(`"initialValue" of "${selectedRule.identifier}" must not be an object - use a factory function!`);
209209
}
210210
211-
let initialValue: any = null; // null as sensitive default...
212-
if (typeof selectedRule.initialValue === 'function') {
213-
// Use factory function
214-
initialValue = selectedRule.initialValue();
215-
}
216-
211+
let value: any = null; // null as sensitive default...
217212
if (typeof selectedRule.initialValue !== 'undefined') {
218-
// If it exists use the primitive value
219-
({ initialValue } = selectedRule);
213+
// If a valid has been passed along, use it
214+
value = selectedRule.initialValue;
215+
}
216+
if (typeof value === 'function') {
217+
// initialValue is a factory function
218+
value = value();
220219
}
221220
222221
children.push({
223222
identifier: selectedRule.identifier,
224-
value: initialValue,
223+
value,
225224
} as Rule);
226225
227226
this.$emit(

0 commit comments

Comments
 (0)