[BUGFIX] Replacing attribute with html-parser breaks escaping

This commit is contained in:
Philipp Dieter 2021-11-02 00:56:50 +01:00
parent 9435030b99
commit b943b1d69c

View File

@ -39,15 +39,17 @@ HtmlWebpackAlterDataPlugin.prototype.apply = function (compiler) {
if (!attribute) { if (!attribute) {
continue; continue;
} }
var attributeReplace = attribute;
for (var [source, target] of Object.entries(manifest)) { for (var [source, target] of Object.entries(manifest)) {
attribute = attribute.replace( attributeReplace = attributeReplace.replace(
this.options.assetPrefix + source + '#', this.options.assetPrefix + source + '#',
target + '#', target + '#',
) )
} }
node.setAttribute('xlink:href', attribute); // Just use replace as using html pasrser to set attribute breaks the
// js module escaping
result = result.replace(attribute, attributeReplace);
} }
var result = root.toString();
compilation.assets[basename] = new RawSource(result); compilation.assets[basename] = new RawSource(result);
} }
} }