Skip to content

Commit 70b2756

Browse files
committed
nav.js: guard against double CM render
1 parent 69e623c commit 70b2756

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

assets/nav.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,14 @@
127127
allBlocks.forEach((el, i) => {
128128
console.log('block', i, 'tag:', el.tagName, 'class:', el.className, 'display:', getComputedStyle(el).display, 'content len:', el.textContent.trim().length);
129129
});
130+
if (document.querySelector('.cm-editor-wrap')) return; // already rendered
130131
document.querySelectorAll('.syntax-block, .impl-block').forEach(el => {
131132
el.style.cssText = 'display:none!important;visibility:hidden!important;height:0!important;overflow:hidden!important;';
132133
if (!el.parentNode) return;
133134
const code = el.textContent.trim();
134135
if (!code) return;
135136
const wrap = document.createElement('div');
137+
wrap.className = 'cm-editor-wrap';
136138
el.parentNode.insertBefore(wrap, el);
137139
const cm = CodeMirror(wrap, {
138140
value: code,

0 commit comments

Comments
 (0)