Skip to content

html-loader get error when processing empty src in img tags #191

Closed
@mosquito1803

Description

@mosquito1803

I'm submitting a bug report

Webpack version:
3.4.1

HTML-Loader version:
0.5.5

Please tell us about your environment:
OSX 10.13.6

Current behavior:

<div class="container"></div>
<script src="https://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
<script>
    var $container = $(".container");

    // this dom is converted from es6, for this page must support ie8, and doing this will get an error Can't resolve './\"\"'
    var dom1 = "<img src=\"\" />";

    $container.append(dom1);

    // this is another example, which will lead to a xxxHTMLLINKxxx link in html
    var dom2 = '<img src="" />';
    
    $container.append(dom2);
</script>

Code above provide two cases:

  • first one is code converted from es6, and will result in an error Can't resolve './\"\"'
  • second one will become something like <img src="xxxHTMLLINKxxx0.57464132184163710.241630956172443xxx">

Expected/desired behavior:

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.

Add the code above in html with a html-loader in webpack.

  • What is the expected behavior?

Both the two cases should be <img src=""> after processed by html-loader

  • What is the motivation for changing the behavior?

This is found when using jquery-lazyload. Usually I write an img tag with a data-original attribute and sometimes add an empty src, which will result in such a problem. Although it is possible to avoid this by removing the empty source or add a link, I think this should be solved by the loader itself.

  • Browser: all

  • Language: ES6 & ES5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions