diff --git a/dev.html b/dev.html
index b64c5b6..235377d 100644
--- a/dev.html
+++ b/dev.html
@@ -31,7 +31,8 @@
diff --git a/src/board.element.spec.ts b/src/board.element.spec.ts
index 7763b14..025f426 100644
--- a/src/board.element.spec.ts
+++ b/src/board.element.spec.ts
@@ -80,4 +80,58 @@ describe(GoBoardElement.name, () => {
expect(board.getSpace("C18")).to.be.null;
});
+
+ it("should submit the default key value to a form", async () => {
+ const board = await fixture(html`
+
+ `);
+
+ return new Promise((resolve) => {
+ board.addEventListener("submit", (e) => {
+ e.preventDefault();
+
+ const form = new FormData(board);
+
+ expect(form.get("game")).to.equal(
+ "*************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************"
+ );
+
+ resolve();
+ });
+
+ board.querySelector("button")?.click();
+ });
+ });
+
+ it("should submit updated key when stones are added", async () => {
+ const board = await fixture(html`
+
+ `);
+
+ return new Promise((resolve) => {
+ board.addEventListener("submit", (e) => {
+ e.preventDefault();
+
+ const form = new FormData(board);
+
+ expect(form.get("game")).to.equal(
+ "******************************************************************************************************************************************************************************************************************************************************************************************************************************************************BA1******************"
+ );
+
+ resolve();
+ });
+
+ board.querySelector("button")?.click();
+ });
+ });
});
diff --git a/src/board.element.ts b/src/board.element.ts
index 70e71f8..9000411 100644
--- a/src/board.element.ts
+++ b/src/board.element.ts
@@ -225,7 +225,15 @@ export class GoBoardElement extends HTMLElement {
#spaces = new Map();
#header = this.dom.query("#header")!;
#prevKey = "";
- #currentKey = this.key();
+ #currentKey = Array.from({ length: this.rows * this.cols })
+ .map(() => "*")
+ .join("");
+
+ constructor() {
+ super();
+
+ this.#internals.setFormValue(this.#currentKey);
+ }
attributeChangedCallback(attr: string, old: string, val: string) {
if (this.debug) {
@@ -275,13 +283,13 @@ export class GoBoardElement extends HTMLElement {
for (let [space, stone] of this.#spaces) {
if (stone !== null) {
- key += space + stone.color[0].toUpperCase();
+ key += stone.color[0].toUpperCase() + space;
} else {
key += "*";
}
}
- return btoa(key);
+ return key;
}
reset() {