Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Can't handle slightly corrupted HTML #41

Closed
gabrys opened this issue Feb 24, 2014 · 6 comments
Closed

Can't handle slightly corrupted HTML #41

gabrys opened this issue Feb 24, 2014 · 6 comments

Comments

@gabrys
Copy link

gabrys commented Feb 24, 2014

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

@jnewman
Copy link
Contributor

jnewman commented Mar 3, 2014

Fixed on master. I'm going through the rest of the bugs and will release along w/ those changes.

@jnewman jnewman closed this as completed Mar 3, 2014
@gabrys
Copy link
Author

gabrys commented May 7, 2014

Just verified the test case above and it still behaves wrong (2 times OK instead of 3 times OK)

@jnewman
Copy link
Contributor

jnewman commented May 7, 2014

I'll take a look when I can. I'm happy to accept pull requests w/ broken tests, which I can then make pass...

@amardeokar
Copy link

Domify (https://github.com/component/domify) the html and get html from domified element and pass it to postscribe function. domify will correct the html if found corrupted.
el = domify(html);
newHtml = el.outerHTML;
postscribe(id, newHtml, options);

@jnewman
Copy link
Contributor

jnewman commented Aug 21, 2014

@amardeokar I'll check that out thanks.

@sethyates
Copy link

I've moved to Prescribe.

@krux krux locked and limited conversation to collaborators Apr 12, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants