Javascript- Failed to execute 'observe' on 'MutationObserver'

Viewed 400

I'm trying to create a tic tac toe game in javascript. I seem to be getting an error saying: Uncaught TypeError: Failed to execute 'observe' on 'MutationObserver': The options object must set at least one of 'attributes', 'characterData', or 'childList' to true..

It is on this line:

  board.positions.forEach((el) => observer.observe(el,config));

It is on the function at the start of the game:

function TicTacToeGame() {
    const board = new Board();
    const humanPlayer = new HumanPlayer(board);
    const computerPlayer = new ComputerPlayer(board);
    let turn = 0;

    this.start = function () {
    const config = {childlist: true};
    const observer = new MutationObserver(()=> takeTurn());
    board.positions.forEach((el) => observer.observe(el,config));
   takeTurn();
    }

I've tried to look up the error but can't find anything similar to it.

1 Answers

Try childList instead of childlist in your config.

Related