krux / prescribe

Tiny HTML parser in JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't handle slightly corrupted HTML

sethyates opened this issue · comments

Browsers can handle this:

document.write('<img src"abc.jpg"><div>WORKS</div>')

Well Firefox prints <img src"abc.jpg"="">, but the div is still there.

Postscribe can't handle this.

<html>
<style>img { display: none }</style>
<div id="js">
<script>document.write('<img src"abc.jpg"><div>OK</div>')</script>
</div>
<div id="ps1"></div>
<div id="ps2"></div>
<script src="https://raw.github.com/krux/postscribe/master/dist/postscribe.js"></script>
<script>
postscribe('#ps1', '<script>document.write(\'<div>OK</div>\')</sc' + 'ript>');
postscribe('#ps2', '<script>document.write(\'<img src"abc.jpg"><div>OK</div>\')</sc' + 'ript>');
</script>
</html>

Expected behavior: 3 times OK. Actual behavior: 2 times OK