diff --git a/core/themes/claro/js/tabledrag.es6.js b/core/themes/claro/js/tabledrag.es6.js index b0824430d3..d445d4964a 100644 --- a/core/themes/claro/js/tabledrag.es6.js +++ b/core/themes/claro/js/tabledrag.es6.js @@ -323,7 +323,6 @@ * 'Drupal.tableDrag.showWeight' localStorage value. */ initColumns() { - const self = this; const { $table } = this; let hidden; let cell; @@ -352,9 +351,13 @@ .parent() .find('> td') .index(cell.get(0)) + 1; - $table - .find('> thead > tr, > tbody > tr, > tr') - .each(self.addColspanClass(columnIndex)); + + const rows = $table[0].find( + 'table > thead > tr, table > tbody > tr, table > tr', + ); + Array.prototype.forEach.call(rows, row => { + this.addColspanClass(row, columnIndex); + }); } }); this.displayColumns(showWeight); @@ -365,35 +368,34 @@ * * In order to adjust the colspan instead of hiding them altogether. * + * @param {HTMLElement} row + * The row HTML element which columns to add colspan class. * @param {number} columnIndex * The column index to add colspan class to. * * @return {function} * Function to add colspan class. */ - addColspanClass(columnIndex) { - return function addColspanClass() { - // Get the columnIndex and adjust for any colspans in this row. - const $row = $(this); - let index = columnIndex; - const cells = $row.children(); - let cell; - cells.each(function checkColspan(n) { - if (n < index && this.colSpan && this.colSpan > 1) { - index -= this.colSpan - 1; - } - }); - if (index > 0) { - cell = cells.filter(`:nth-child(${index})`); - if (cell[0].colSpan && cell[0].colSpan > 1) { - // If this cell has a colspan, mark it so we can reduce the colspan. - cell.addClass('tabledrag-has-colspan'); - } else { - // Mark this cell so we can hide it. - cell.addClass('tabledrag-hide'); - } + addColspanClass(row, columnIndex) { + // Get the columnIndex and adjust for any colspans in this row. + const $row = $(row); + let index = columnIndex; + const cells = $row.children(); + cells.each((n, cell) => { + if (n < index && cell.colSpan && cell.colSpan > 1) { + index -= cell.colSpan - 1; } - }; + }); + if (index > 0) { + const cell = cells.filter(`:nth-child(${index})`); + if (cell[0].colSpan && cell[0].colSpan > 1) { + // If this cell has a colspan, mark it so we can reduce the colspan. + cell.addClass('tabledrag-has-colspan'); + } else { + // Mark this cell so we can hide it. + cell.addClass('tabledrag-hide'); + } + } }, /** diff --git a/core/themes/claro/js/tabledrag.js b/core/themes/claro/js/tabledrag.js index f52ecbd2cc..86d23db470 100644 --- a/core/themes/claro/js/tabledrag.js +++ b/core/themes/claro/js/tabledrag.js @@ -102,7 +102,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi initColumns: function initColumns() { var _this2 = this; - var self = this; var $table = this.$table; var hidden; var cell; @@ -122,33 +121,33 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (hidden && cell[0]) { columnIndex = cell.parent().find('> td').index(cell.get(0)) + 1; - $table.find('> thead > tr, > tbody > tr, > tr').each(self.addColspanClass(columnIndex)); + var rows = $table[0].find('table > thead > tr, table > tbody > tr, table > tr'); + Array.prototype.forEach.call(rows, function (row) { + _this2.addColspanClass(row, columnIndex); + }); } }); this.displayColumns(showWeight); }, - addColspanClass: function addColspanClass(columnIndex) { - return function addColspanClass() { - var $row = $(this); - var index = columnIndex; - var cells = $row.children(); - var cell; - cells.each(function checkColspan(n) { - if (n < index && this.colSpan && this.colSpan > 1) { - index -= this.colSpan - 1; - } - }); + addColspanClass: function addColspanClass(row, columnIndex) { + var $row = $(row); + var index = columnIndex; + var cells = $row.children(); + cells.each(function (n, cell) { + if (n < index && cell.colSpan && cell.colSpan > 1) { + index -= cell.colSpan - 1; + } + }); - if (index > 0) { - cell = cells.filter(":nth-child(".concat(index, ")")); + if (index > 0) { + var cell = cells.filter(":nth-child(".concat(index, ")")); - if (cell[0].colSpan && cell[0].colSpan > 1) { - cell.addClass('tabledrag-has-colspan'); - } else { - cell.addClass('tabledrag-hide'); - } + if (cell[0].colSpan && cell[0].colSpan > 1) { + cell.addClass('tabledrag-has-colspan'); + } else { + cell.addClass('tabledrag-hide'); } - }; + } }, displayColumns: function displayColumns(displayWeight) { if (displayWeight) {