From 163e3a9de59f5d6a8df38fa32a1e7dc4db1ad024 Mon Sep 17 00:00:00 2001
From: Catalin Mititiuc
Date: Sat, 1 Jun 2024 17:50:58 -0700
Subject: Fix/refactor tests
---
src/index.js | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
(limited to 'src/index.js')
diff --git a/src/index.js b/src/index.js
index e638910..7f914d4 100644
--- a/src/index.js
+++ b/src/index.js
@@ -80,11 +80,20 @@ function loadScenario(data) {
async function buildScenario(req) {
console.log('req', req);
+ console.log('fresh template', scenarioTemplate.querySelector('svg'));
+
const svg = scenarioTemplate.querySelector('svg').cloneNode(true);
- document.querySelector('object').contentDocument.querySelector('svg').replaceWith(svg);
- const startLocs = svg.querySelector('.start-locations');
+ // console.log('document', document.querySelector('object').contentDocument);
+
+ document.querySelector('object').contentDocument.querySelector('svg').remove();
+ document.querySelector('object').contentDocument.append(svg);
+
+ gameboard.stop();
+ recordSheet.stop();
+
const scenario = await req;
+ const startLocs = scenario.querySelector('.start-locations');
console.log(scenario);
@@ -119,17 +128,15 @@ async function buildScenario(req) {
});
const refsQuery = [...refs[filename]].join(', ');
- external.querySelectorAll(refsQuery).forEach(node => defs.append(node));
+ external.querySelectorAll(refsQuery).forEach(node => defs.append(svg.ownerDocument.importNode(node, true)));
});
});
- scenario.querySelectorAll('use.mapsheet').forEach(el => gb.prepend(el));
- grid.before(scenario.querySelector('.start-locations'));
+ scenario.querySelectorAll('use.mapsheet').forEach(el => gb.prepend(svg.ownerDocument.importNode(el, true)));
+ if (startLocs) grid.before(svg.ownerDocument.importNode(startLocs, true));
const scenarioGrid = scenario.querySelector('.grid');
- console.log('scenarioGrid', scenarioGrid);
-
if (scenarioGrid) {
grid.replaceWith(svg.ownerDocument.importNode(scenarioGrid, true));
}
--
cgit v1.2.3