Skip to content

Commit f3c40ec

Browse files
committed
* form-helper: refactor constructor to utilize class properties for default options and improve control registration logic
1 parent f5d8bcf commit f3c40ec

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

lib/form-helper/src/vanilla/form-helper.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export class FormHelper {
1313
throwError: true,
1414
};
1515

16+
declare ['constructor']: typeof FormHelper;
17+
1618
/**
1719
* 选项。 Options.
1820
*/
@@ -29,12 +31,13 @@ export class FormHelper {
2931
protected _cachedFields: Map<string, Cash>;
3032

3133
constructor(selector: Selector, options?: FormHelperOptions) {
34+
const {DEFAULT, globalControls} = this.constructor;
3235
this._options = {
33-
...FormHelper.DEFAULT,
36+
...DEFAULT,
3437
...options,
3538
controls: {
36-
...FormHelper.globalControls,
37-
...FormHelper.DEFAULT.controls,
39+
...globalControls,
40+
...DEFAULT.controls,
3841
...options?.controls,
3942
},
4043
};
@@ -188,7 +191,7 @@ export class FormHelper {
188191
};
189192

190193
static registerControl(type: string, finder: FormControlFinder) {
191-
FormHelper.globalControls[type] = finder;
194+
this.globalControls[type] = finder;
192195
}
193196
}
194197

0 commit comments

Comments
 (0)