Skip to content

Commit be80634

Browse files
committed
fix bug when loading empty cell multiple times
1 parent 786be59 commit be80634

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

lib/GoogleSpreadsheetCell.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { columnToLetter } = require('./utils');
55
const { GoogleSpreadsheetFormulaError } = require('./errors');
66

77
class GoogleSpreadsheetCell {
8-
constructor(parentSheet, rowIndex, columnIndex, cellData = {}) {
8+
constructor(parentSheet, rowIndex, columnIndex, cellData) {
99
this._sheet = parentSheet; // the parent GoogleSpreadsheetWorksheet instance
1010
this._row = rowIndex;
1111
this._column = columnIndex;
@@ -14,7 +14,8 @@ class GoogleSpreadsheetCell {
1414
return this;
1515
}
1616

17-
_updateRawData(newData) {
17+
// newData can be undefined/null if the cell is totally empty and unformatted
18+
_updateRawData(newData = {}) {
1819
this._rawData = newData;
1920
this._draftData = {}; // stuff to save
2021
this._error = null;

test/cells.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ describe('Cell-based operations', () => {
7373
expect(() => { sheet.getCellByA1('A1'); }).toThrow();
7474
});
7575

76+
it('can load a cell multiple times (this was a bug)', async () => {
77+
await sheet.loadCells('J10');
78+
expect(sheet.getCellByA1('J10').value).toBeNull();
79+
await sheet.loadCells('J10');
80+
expect(sheet.getCellByA1('J10').value).toBeNull();
81+
});
82+
7683
describe('invalid filters', () => {
7784
_.each({
7885
'invalid A1 range': 'NOT-A-RANGE',

0 commit comments

Comments
 (0)