@osimatic/helpers-js 1.5.4 → 1.5.5

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.
@@ -12,8 +12,9 @@ class MultipleActionInTable {
12
12
  return;
13
13
  }
14
14
 
15
- if (!table.querySelector('thead tr th[data-key="select"]')) {
16
- table.querySelector('thead tr').insertAdjacentHTML('afterbegin', '<th class="' + cellSelector + '" data-key="select"></th>');
15
+ const theadTr = table.querySelector('thead tr');
16
+ if (theadTr && !theadTr.querySelector('th[data-key="select"]')) {
17
+ theadTr.insertAdjacentHTML('afterbegin', '<th class="' + cellSelector + '" data-key="select"></th>');
17
18
  }
18
19
  table.querySelectorAll('tbody tr:not(.no_items)').forEach(tr => {
19
20
  if (!tr.querySelector('td.select')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.5.4",
3
+ "version": "1.5.5",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -139,6 +139,25 @@ describe('MultipleActionInTable', () => {
139
139
  expect(table.querySelectorAll('tbody tr td.select').length).toBe(2);
140
140
  });
141
141
 
142
+ test('should not throw when table has no <thead>', () => {
143
+ document.body.innerHTML = `
144
+ <div>
145
+ <div>
146
+ <table class="table-action_multiple">
147
+ <tbody>
148
+ <tr data-action_multiple_input_name="ids[]" data-action_multiple_item_id="1">
149
+ <td>Item 1</td>
150
+ </tr>
151
+ </tbody>
152
+ </table>
153
+ </div>
154
+ <div class="action_multiple_buttons hide"></div>
155
+ </div>`;
156
+ const table = document.querySelector('table');
157
+ expect(() => MultipleActionInTable.initCols(table)).not.toThrow();
158
+ expect(table.querySelector('th[data-key="select"]')).toBeNull();
159
+ });
160
+
142
161
  test('should skip rows with no_items class', () => {
143
162
  document.body.innerHTML = `
144
163
  <div>