2
0
Эх сурвалжийг харах

replace existing tag by controlling DOM.

Yuto Iwata 7 жил өмнө
parent
commit
ab972b976f

+ 6 - 1
src/client/js/util/reveal/plugins/growi-renderer.js

@@ -6,7 +6,12 @@
   let sections = document.querySelectorAll( '[data-markdown]'), section;
   for (let i = 0, len = sections.length; i < len; i++ ) {
     section = sections[i];
-    section.innerHTML = '<h1>hoge</h1>';
+    // remove all existing children.
+    while (section.firstChild) section.removeChild(section.firstChild);
+    // add h1 DOM 'Hoge'.
+    let h1 = document.createElement('h1');
+    h1.appendChild(document.createTextNode('Hoge'));
+    section.appendChild(h1);
   }
   const GrowiRenderer = require('../../GrowiRenderer');
   let growiRenderer = new GrowiRenderer(root.crowi, root.crowiRenderer, {mode: 'editor'});