Skip to content

1.x: HTML comment delimiters inside <script> ends the tag #46

Open
papandreou opened this Issue Apr 24, 2012 · 1 comment

2 participants

@papandreou
var rawHtml = '<script>document.write("<!--hello-->");</script>',
    htmlparser = require('./lib/htmlparser'),
    handler = new htmlparser.DefaultHandler(),
    parser = new htmlparser.Parser(handler);
parser.parseComplete(rawHtml);
console.warn(require('util').inspect(handler.dom, false, null));

Output:

[ { raw: 'script',
    data: 'script',
    type: 'script',
    name: 'script',
    children: 
     [ { raw: 'document.write("',
         data: 'document.write("',
         type: 'text' },
       { raw: 'hello', data: 'hello', type: 'comment' },
       { raw: '");', data: '");', type: 'text' } ] } ]

Expected output:

[ { raw: 'script',
    data: 'script',
    type: 'script',
    name: 'script',
    children: 
     [ { raw: 'document.write("<!--hello-->");',
         data: 'document.write("<!--hello-->");',
         type: 'text' } ] } ]
@tautologistics
Owner

If you have a patch or pull request I will apply it to the 1.x branch, otherwise I am focusing efforts on getting 2.x tested and released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.