Skip to content

Commit

Permalink
Merge pull request #122 from editor-js/language-tool-fix
Browse files Browse the repository at this point in the history
Improve the cells counter based on selectors
  • Loading branch information
GeekaN2 authored Feb 22, 2023
2 parents 4a94a15 + 331f895 commit 3cc5067
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@editorjs/table",
"description": "Table for Editor.js",
"version": "2.2.0",
"version": "2.2.1",
"license": "MIT",
"main": "./dist/table.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export default class Table {
* @returns {HTMLElement}
*/
getCell(row, column) {
return this.table.querySelector(`.${CSS.row}:nth-child(${row}) .${CSS.cell}:nth-child(${column})`);
return this.table.querySelectorAll(`.${CSS.row}:nth-child(${row}) .${CSS.cell}`)[column - 1];
}

/**
Expand Down Expand Up @@ -570,7 +570,7 @@ export default class Table {
*/
get numberOfColumns() {
if (this.numberOfRows) {
return this.table.querySelector(`.${CSS.row}:first-child`).childElementCount;
return this.table.querySelectorAll(`.${CSS.row}:first-child .${CSS.cell}`).length;
}

return 0;
Expand Down

0 comments on commit 3cc5067

Please sign in to comment.