Fix fragile tile position lookup
This code didn't work when Trivabble was served as text/html, which adds a <tbody> tag in the DOM, while this tag is not added when Trivabble is served as application/xhtml+xml.
This commit is contained in:
parent
cdd2ca777a
commit
1f9e062014
|
@ -612,33 +612,32 @@
|
||||||
rackBCR = rack.getBoundingClientRect();
|
rackBCR = rack.getBoundingClientRect();
|
||||||
bagBCR = bag.getBoundingClientRect();
|
bagBCR = bag.getBoundingClientRect();
|
||||||
|
|
||||||
let from;
|
let from = null;
|
||||||
let index;
|
let index;
|
||||||
|
|
||||||
let p = movingTile.parentNode;
|
let p = movingTile;
|
||||||
let oldP = movingTile;
|
|
||||||
let oldOldP = null;
|
|
||||||
|
|
||||||
while (p) {
|
while (p && !from) {
|
||||||
if (p === board) {
|
index = boardCells.indexOf(p);
|
||||||
|
if (index !== -1) {
|
||||||
from = "board";
|
from = "board";
|
||||||
index = boardCells.indexOf(oldOldP);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p === rack) {
|
index = playerLetters.indexOf(p);
|
||||||
|
if (index !== -1) {
|
||||||
from = "rack";
|
from = "rack";
|
||||||
index = playerLetters.indexOf(oldP);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
oldOldP = oldP;
|
|
||||||
oldP = p;
|
|
||||||
p = p.parentNode;
|
p = p.parentNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!from) {
|
||||||
|
fatalError(new Error("Error: did not find the parent of the moving tile"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
moveCMD = {
|
moveCMD = {
|
||||||
cmd: "moveLetter",
|
cmd: "moveLetter",
|
||||||
from: from,
|
from: from,
|
||||||
|
|
Loading…
Reference in New Issue