metasmile / grit-i18n

Automatically exported from code.google.com/p/grit-i18n
BSD 2-Clause "Simplified" License
1 stars 2 forks source link

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

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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 dzhi...@chromium.org on 11 Dec 2014 at 12:07