From d85dd19816df7ec74eb3e4dd31b3c4d63c6119aa Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sat, 30 Jul 2016 20:33:32 +0800 Subject: Update slide rendering to reduce DOM wrap and avoid duplicate rendering slides --- public/js/reveal-markdown.js | 2 +- public/js/slide.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'public/js') diff --git a/public/js/reveal-markdown.js b/public/js/reveal-markdown.js index ca22e09c..a969967c 100755 --- a/public/js/reveal-markdown.js +++ b/public/js/reveal-markdown.js @@ -355,7 +355,7 @@ var rendered = md.render(markdown); rendered = preventXSS(rendered); var result = postProcess(rendered); - section.innerHTML = result[0].outerHTML; + section.innerHTML = result[0].innerHTML; addAttributes( section, section, null, section.getAttribute( 'data-element-attributes' ) || section.parentNode.getAttribute( 'data-element-attributes' ) || DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR, diff --git a/public/js/slide.js b/public/js/slide.js index 795f47be..4c2f1ff9 100644 --- a/public/js/slide.js +++ b/public/js/slide.js @@ -55,10 +55,14 @@ viewAjaxCallback = function () { }; function renderSlide(event) { - var title = document.title; - finishView($(event.currentSlide)); - document.title = title; - Reveal.layout(); + var markdown = $(event.currentSlide); + if (!markdown.attr('data-rendered')) { + var title = document.title; + finishView(markdown); + markdown.attr('data-rendered', 'true'); + document.title = title; + Reveal.layout(); + } } Reveal.addEventListener('ready', renderSlide); -- cgit v1.2.3