use different ids

This commit is contained in:
Bernard Xie 2023-01-03 15:28:51 -08:00
parent dfd66232fc
commit 6b3634ec4c
No known key found for this signature in database
GPG key ID: 3C3E0036CE0F892C
2 changed files with 3 additions and 3 deletions

View file

@ -5,7 +5,7 @@ window.addEventListener("DOMContentLoaded", () => {
function init(reconnectDelay) { function init(reconnectDelay) {
const d2ErrDiv = window.document.querySelector("#d2-err"); const d2ErrDiv = window.document.querySelector("#d2-err");
const d2SVG = window.document.querySelector("#d2-svg"); const d2SVG = window.document.querySelector("#d2-svg-container");
const devMode = document.body.dataset.d2DevMode === "true"; const devMode = document.body.dataset.d2DevMode === "true";
const ws = new WebSocket( const ws = new WebSocket(
@ -34,7 +34,7 @@ function init(reconnectDelay) {
// out the width, height and viewbox out of the top level SVG tag and update those manually. // out the width, height and viewbox out of the top level SVG tag and update those manually.
d2SVG.innerHTML = msg.svg; d2SVG.innerHTML = msg.svg;
const svgEl = d2SVG.querySelector("svg"); const svgEl = d2SVG.querySelector("#d2-svg");
let width = parseInt(svgEl.getAttribute("width"), 10); let width = parseInt(svgEl.getAttribute("width"), 10);
let height = parseInt(svgEl.getAttribute("height"), 10); let height = parseInt(svgEl.getAttribute("height"), 10);
if (isInit) { if (isInit) {

View file

@ -430,7 +430,7 @@ func (w *watcher) handleRoot(hw http.ResponseWriter, r *http.Request) {
</head> </head>
<body data-d2-dev-mode=%t> <body data-d2-dev-mode=%t>
<div id="d2-err" style="display: none"></div> <div id="d2-err" style="display: none"></div>
<div id="d2-svg"></div> <div id="d2-svg-container"></div>
</body> </body>
</html>`, w.outputPath, w.devMode) </html>`, w.outputPath, w.devMode)
} }