marijnh / Eloquent-JavaScript

The sources for the Eloquent JavaScript book
https://eloquentjavascript.net
2.99k stars 790 forks source link

Pixel editor app, Chapter 19 #554

Closed alexpi closed 3 years ago

alexpi commented 3 years ago

In the historyUpdateState() function there is an if (state.done.length == 0) return state; check. Is this really needed? The undo button becomes disabled as soon as the done array is empty, so this line seems like it would never have any effect.

marijnh commented 3 years ago

You're right that that situation wouldn't occur in the app as it is implemented here, but I think it's reasonable for the state update function to handle any valid updates, even if they aren't fired by the code, so I'd prefer to leave it the way it is.