Skip to content

Commit

Permalink
fix: Fix to Few Detected Bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
usernane committed Jul 8, 2024
1 parent aa6bd94 commit 94555b3
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions webfiori/ui/HTMLTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function getValue(int $rowIndex, int $colIndex) {
if ($cell != null) {
$ch = $cell->getChild(0);

if ($ch->getName() == '#TEXT') {
if ($ch->getNodeName() == '#TEXT') {
return $ch->getText();
}

Expand All @@ -170,6 +170,8 @@ public function getValue(int $rowIndex, int $colIndex) {
/**
* Removes a column from the table given column index.
*
* Note that if the table has one column, the method will not remove it.
*
* @param int $colIndex The index of the column.
*
* @return array The method will return an array that holds objects that
Expand All @@ -179,25 +181,36 @@ public function getValue(int $rowIndex, int $colIndex) {
public function removeCol(int $colIndex) : array {
$colCells = [];

if ($colIndex < $this->cols()) {
if ($colIndex < $this->cols() && $this->cols() > 1) {
foreach ($this as $row) {
$colCells[] = $row->children()->remove($colIndex);
}
$this->cols--;
}

return $colCells;
}
/**
* Removes a row given its index.
*
* Note that if the table has only one row, the method will not remove it.
*
* @param int $rowIndex The index of the row.
*
* @return TableRow|null If the row is removed, the method will return
* an object that represents the removed row. Other than that, the method
* will return null.
*/
public function removeRow(int $rowIndex) {
return $this->removeChild($rowIndex);
if ($this->rows() > 1) {
$row = $this->removeChild($rowIndex);

if ($row !== null) {
$this->rows--;
}

return $row;
}
}
/**
* Returns number of rows in the table.
Expand Down

0 comments on commit 94555b3

Please sign in to comment.