@osimatic/helpers-js 1.5.9 → 1.5.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/form_helper.js CHANGED
@@ -11,7 +11,8 @@ class FormHelper {
11
11
  FormHelper.buttonLoader(this, 'loading');
12
12
  FormHelper.hideFormErrors(form);
13
13
  if (typeof onSubmitCallback == 'function') {
14
- onSubmitCallback(form, submitButton);
14
+ const jq = wasJQuery && typeof $ !== 'undefined';
15
+ onSubmitCallback(jq ? $(form) : form, jq ? $(submitButton) : submitButton);
15
16
  }
16
17
  };
17
18
  return wasJQuery && typeof $ !== 'undefined' ? $(form) : form;
@@ -384,7 +385,9 @@ class FormHelper {
384
385
  button.classList.add('disabled');
385
386
  }
386
387
  if (action === 'stop' || action === 'reset') {
387
- button.innerHTML = button.dataset.btnText;
388
+ if (button.dataset.btnText !== undefined) {
389
+ button.innerHTML = button.dataset.btnText;
390
+ }
388
391
  button.classList.remove('disabled');
389
392
  button.disabled = false;
390
393
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.5.9",
3
+ "version": "1.5.11",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -687,6 +687,15 @@ describe('FormHelper', () => {
687
687
 
688
688
  expect(result).toBe(btn);
689
689
  });
690
+
691
+ test('should not overwrite innerHTML with "undefined" when reset called before loading', () => {
692
+ const form = setupForm();
693
+ const btn = addButton(form, 'validate', 'Submit');
694
+
695
+ FormHelper.buttonLoader(btn, 'reset');
696
+
697
+ expect(btn.innerHTML).toBe('Submit');
698
+ });
690
699
  });
691
700
 
692
701
  describe('getInputValue', () => {