@osimatic/helpers-js 1.5.12 → 1.5.13
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_date.js +5 -1
- package/package.json +1 -1
- package/tests/form_date.test.js +8 -0
package/form_date.js
CHANGED
|
@@ -6,7 +6,11 @@ class InputPeriod {
|
|
|
6
6
|
|
|
7
7
|
static addLinks(form) {
|
|
8
8
|
form = toEl(form);
|
|
9
|
-
|
|
9
|
+
const input = form.querySelector('input[type="date"][data-add_period_select_links]');
|
|
10
|
+
if (!input) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
let divParent = input.parentElement;
|
|
10
14
|
if (divParent.classList.contains('input-group')) {
|
|
11
15
|
divParent = divParent.parentElement;
|
|
12
16
|
}
|
package/package.json
CHANGED
package/tests/form_date.test.js
CHANGED
|
@@ -651,6 +651,14 @@ describe('InputPeriod', () => {
|
|
|
651
651
|
});
|
|
652
652
|
});
|
|
653
653
|
|
|
654
|
+
test('should not throw when form has no input[data-add_period_select_links]', () => {
|
|
655
|
+
document.body.innerHTML = `<form><div><input type="date" /></div></form>`;
|
|
656
|
+
const form = document.querySelector('form');
|
|
657
|
+
|
|
658
|
+
expect(() => InputPeriod.addLinks(form)).not.toThrow();
|
|
659
|
+
expect(form.querySelector('.select_period_links')).toBeNull();
|
|
660
|
+
});
|
|
661
|
+
|
|
654
662
|
describe('init', () => {
|
|
655
663
|
test('should set up click handlers for all period links', () => {
|
|
656
664
|
const linkSelectors = [
|