Skip to content

Commit 9bf803f

Browse files
keithamuskoddsson
andauthored
Move [data-code] to bottom script
This will now run even if the import fails Co-authored-by: Kristján Oddsson <[email protected]>
1 parent 16de35e commit 9bf803f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

docs/index.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,5 +666,22 @@
666666
const [browser, version] = getBrowser(navigator.userAgent)
667667
document.getElementById('your-browser').innerText = browser + " " + version
668668
</script>
669+
<script>
670+
for(const el of document.querySelectorAll('[data-code]')) {
671+
let supported = false
672+
const code = el.getAttribute('data-code')
673+
try {
674+
supported = eval(`${code}`)
675+
} catch (e) {
676+
supported = false
677+
}
678+
Promise.resolve(supported).then((value) => {
679+
el.setAttribute('data-supported', Boolean(value))
680+
if (!value && el.hasAttribute('data-transpiled')) {
681+
if (!value) el.textContent = '**'
682+
}
683+
})
684+
}
685+
</script>
669686
</body>
670687
</html>

0 commit comments

Comments
 (0)