Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grit shouldn't parse HTML tags inside JS comments #30

Open
GoogleCodeExporter opened this issue Jul 8, 2015 · 0 comments
Open

Grit shouldn't parse HTML tags inside JS comments #30

GoogleCodeExporter opened this issue Jul 8, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

I have a JS file containing such comment:
         // stamp template                                                        
         // which includes parsing and applying MDV bindings before being         
         // inserted (to avoid {{}} in attribute values)                          
         // e.g. to prevent <img src="images/{{icon}}"> from generating a 404.

When this file is imported into a HTML file, GRIT treats <img> tag as a real 
HTML tag and generates an dependency for 'src'. That shouldn't happen. Here is 
an unit test demonstrating the error:

  def testTagsInJSComments(self):
    '''Tests that "<img src=...>" tags inside JS comment are ignored.'''

    files = {
      'index.js': '''
      // <img src="example.png">
      ''',
    }

    source_resources = set()
    tmp_dir = util.TempDir(files)
    for filename in files:
      source_resources.add(tmp_dir.GetPath(filename))

    resources = html_inline.GetResourceFilenames(tmp_dir.GetPath('index.js'))
    resources.add(tmp_dir.GetPath('index.js'))
    self.failUnlessEqual(resources, source_resources)
    tmp_dir.CleanUp()

Original issue reported on code.google.com by [email protected] on 11 Dec 2014 at 12:07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant