mliebelt / pgn-viewer

Simple PGN viewer with the necessary features to display chess games
GNU General Public License v3.0
161 stars 44 forks source link

Switching between games in a multigame PGN does not work #477

Open jiri-matejka opened 10 months ago

jiri-matejka commented 10 months ago

I have a PGN with multiple games, using view modus.

Switching between games does not reset the game to the beginning and throws the exception.

Reproducing:

  1. Select the first game (default)
  2. Advance the game by one move
  3. Switch to another game
  4. The chessboard is not reset and the following exception occurs.
Uncaught TypeError: g is null
    D https://cdn.jsdelivr.net/npm/@mliebelt/pgn-viewer@1.6.6/lib/dist.min.js:7
    generateMoves https://cdn.jsdelivr.net/npm/@mliebelt/pgn-viewer@1.6.6/lib/dist.min.js:7
dist.min.js:7:166969

and

Uncaught TypeError: M.forEach is not a function
    g https://cdn.jsdelivr.net/npm/@mliebelt/pgn-viewer@1.6.6/lib/dist.min.js:7
    g https://cdn.jsdelivr.net/npm/@mliebelt/pgn-viewer@1.6.6/lib/dist.min.js:7
    g https://cdn.jsdelivr.net/npm/@mliebelt/pgn-viewer@1.6.6/lib/dist.min.js:7
    g https://cdn.jsdelivr.net/npm/@mliebelt/pgn-viewer@1.6.6/lib/dist.min.js:7
    eachMove https://cdn.jsdelivr.net/npm/@mliebelt/pgn-viewer@1.6.6/lib/dist.min.js:7
    readMoves https://cdn.jsdelivr.net/npm/@mliebelt/pgn-viewer@1.6.6/lib/dist.min.js:7
    loadOne https://cdn.jsdelivr.net/npm/@mliebelt/pgn-viewer@1.6.6/lib/dist.min.js:7
    generateMoves https://cdn.jsdelivr.net/npm/@mliebelt/pgn-viewer@1.6.6/lib/dist.min.js:7
dist.min.js:7:85566

Codepen: https://codepen.io/jiri-matejka/pen/YzBxzbJ To view the errors in the codepen, check the browser console, not the codepen console.

PGN file: https://gist.github.com/jiri-matejka/0cd6ddf156c8dba307516d192e3d226a

mliebelt commented 10 months ago

Excellent bug report, I will try to address that as soon as possible. I have a similar report of not being able to use the multigame viewer and switching programmatically, this seems to be related. See mliebelt/PgnViewerJS#477

jiri-matejka commented 10 months ago

Thanks a lot. That other bug report is also from me, and I don't think they are related. The other issue is just about supporting Z0 non-standard mark and it prevents the PgnViewer to be initialized. While thig bug occurs when the PgnViewer is correctly initialized.

jiri-matejka commented 10 months ago

Let me add one detail, in your Many games example, there are also some exceptions logged to console, when I switch from the first to second game, and the board is not reset.

https://mliebelt.github.io/PgnViewerJS/examples/1101.html

I get:

Uncaught TypeError: Cannot read properties of null (reading 'parentNode')
mliebelt commented 10 months ago

Thanks a lot. That other bug report is also from me, and I don't think they are related. The other issue is just about supporting Z0 non-standard mark and it prevents the PgnViewer to be initialized. While thig bug occurs when the PgnViewer is correctly initialized.

Sorry, I got the reference wrong. I have now linked the correct issue, with a similar symptom.