Просмотр исходного кода

replace existing tag by controlling DOM.

Yuto Iwata 7 лет назад
Родитель
Сommit
ab972b976f
1 измененных файлов с 6 добавлено и 1 удалено
  1. 6 1
      src/client/js/util/reveal/plugins/growi-renderer.js

+ 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'});