fix: do not rely on the hasChildNodes() method

Introduced in 5ba1c28408

TIL: `hasChildNodes()` is sensitive to white spaces.
This commit is contained in:
David Larlet 2024-07-29 21:15:24 -04:00
parent 5ba1c28408
commit c240357922
No known key found for this signature in database
GPG key ID: 3E2953A359E7E7BD

View file

@ -59,7 +59,7 @@
const button = event.target.closest('button') const button = event.target.closest('button')
button.nextElementSibling.showModal() button.nextElementSibling.showModal()
const mapId = button.dataset.mapId const mapId = button.dataset.mapId
if (!document.querySelector(`#${mapId}_target`).hasChildNodes()) { if (!document.querySelector(`#${mapId}_target`).children.length) {
const previewSettings = JSON.parse(document.getElementById(mapId).textContent) const previewSettings = JSON.parse(document.getElementById(mapId).textContent)
const map = new U.Map(`${mapId}_target`, previewSettings) const map = new U.Map(`${mapId}_target`, previewSettings)
CACHE[mapId] = map CACHE[mapId] = map