From cf2359654fffb05a8b5f6c8048fb7e7bb39f962f Mon Sep 17 00:00:00 2001 From: vikasrj Date: Thu, 1 Jun 2017 18:38:27 +0530 Subject: [PATCH] issue-51: Resolved IE10 table insertion issue (#52) * issue-51: Resolved IE10 table insertion issue * issue-51: Fixed Travis comments * issue-51: added 'classlist' in el * issue-51: Removed dataset line --- src/js/grid.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/js/grid.js b/src/js/grid.js index 1ca9044..67b0e40 100644 --- a/src/js/grid.js +++ b/src/js/grid.js @@ -18,17 +18,25 @@ Grid.prototype = { markCells: function () { [].forEach.call(this._cellsElements, function (el) { var cell = { - column: parseInt(el.dataset.column, 10), - row: parseInt(el.dataset.row, 10) + column: parseInt(el.getAttribute('data-column'), 10), + row: parseInt(el.getAttribute('data-row'), 10) }, active = this._currentCell && cell.row <= this._currentCell.row && cell.column <= this._currentCell.column; if (active === true) { - el.classList.add('active'); + if ('classList' in el) { + el.classList.add('active'); + } else { + el.className += ' ' + 'active'; + } } else { - el.classList.remove('active'); + if ('classList' in el) { + el.classList.remove('active'); + } else { + el.className = (' ' + el.className).replace(' ' + 'active' + ' ', ''); + } } }.bind(this)); }, @@ -92,15 +100,13 @@ Grid.prototype = { var self = this, timer; - el.addEventListener('mouseenter', function () { + el.addEventListener('mouseenter', function (e) { clearTimeout(timer); - var dataset = this.dataset; - timer = setTimeout(function () { self._currentCell = { - column: parseInt(dataset.column, 10), - row: parseInt(dataset.row, 10) + column: parseInt(e.target.getAttribute('data-column'), 10), + row: parseInt(e.target.getAttribute('data-row'), 10) }; self.markCells(); }, 50); @@ -111,7 +117,7 @@ Grid.prototype = { var self = this; el.addEventListener('click', function (e) { e.preventDefault(); - self._callback(this.dataset.row, this.dataset.column); + self._callback(e.target.getAttribute('data-row'), e.target.getAttribute('data-column')); }); } };