cm-chessboard 7.4.2 → 7.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/Chessboard.js +12 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-chessboard",
3
- "version": "7.4.2",
3
+ "version": "7.4.3",
4
4
  "description": "A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.",
5
5
  "keywords": [
6
6
  "chess",
package/src/Chessboard.js CHANGED
@@ -188,9 +188,21 @@ export class Chessboard {
188
188
  }
189
189
 
190
190
  addExtension(extensionClass, props) {
191
+ if(this.hasExtension(extensionClass)) {
192
+ throw Error("extension \"" + extensionClass.name + "\" already added")
193
+ }
191
194
  this.extensions.push(new extensionClass(this, props))
192
195
  }
193
196
 
197
+ hasExtension(extensionClass) {
198
+ for (const extension of this.extensions) {
199
+ if (extension instanceof extensionClass) {
200
+ return true
201
+ }
202
+ }
203
+ return false
204
+ }
205
+
194
206
  destroy() {
195
207
  this.state.invokeExtensionPoints(EXTENSION_POINT.destroy)
196
208
  if (this.state.squareSelectEnabled) {