ajax333221 / isepic-chess

♞ JavaScript chess utility library.
MIT License
16 stars 3 forks source link

fenGet() temporal board not being removed #41

Closed ajax333221 closed 1 year ago

ajax333221 commented 1 year ago

With the recent changes, removeBoard(board); takes the board fake_board_fenGet and attempts to remove it instead of removing the board board_fenGet.

Resulting in the board showing in some places:

The fix is simple, this should do it: board = _cloneBoardToObj({ boardName: 'fake_board_fenGet' }, board); to board = _cloneBoardToObj({ boardName: board.boardName }, board);

With this, now removeBoard() should remove it with no problem, however I am a bit against passing a fake methodless board around, because much of the time, after successfully selecting a board, it is assumed we can call any board methods, so we should also do one of these:

To prevent future bugs in removeBoard() if we ever try to call a board method after selecting it and before deleting it.

ajax333221 commented 1 year ago

At the end, I didn't do either of these:

    -change removeBoard(board); to removeBoard(board.boardName); with some comment.
    -or, make board still reference the board_fenGet by never killing the reference.

I decided to keep the board name as a string instead, and remove the board with it.