arturadib / strapdown

Instant and elegant Markdown documents in the browser
http://strapdownjs.com
MIT License
2.48k stars 410 forks source link

Call replaceChild on parent #27

Open memeplex opened 10 years ago

memeplex commented 10 years ago

The right way to do this

document.body.replaceChild(newNode, markdownEl);

is

markdownEl.parentNode.replaceChild(newNode, markdownEl);

otherwise some browsers get confused in some sites (try, for example, to put strapdown inside blogspot, it won't work but the second line fixes the issue)

ndossougbe commented 10 years ago

+1 on this.

It would allow to use Strapdown on something else than bare-bones html. Right now

has to be a direct child of body. Trying to add a table of content, more complex style, etc. is needlessly complicated because of that.</p> </div> </div> <div class="page-bar-simple"> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>