Fix pieceStyle CSS class manipulation #476
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current behavior to set the CSS class according to
configuration.pieceStyle
just adds it as an extra class to the board element:However, that's not accurate, because it only works the first time the render function (e.g.
pgnView
) is called. Then, it keeps adding more classes, leading to an inconsistent behavior that can be reproduced easily in the configuration builder site by switching between different piece styles more than once.To solve that, I've defined the
PieceStyle
enum type, but it's not strictly needed. I've also written a small algorithm (setPieceStyleClass
function) that probably isn't the most performing solution, but I think it's simple, correct and good enough - Of course, any suggestion is more than welcome! :) cc/ @mliebeltNote that I also updated the built artifacts for the docs page.