From b943b1d69cc81c655c9d920762c627f84a1239c2 Mon Sep 17 00:00:00 2001 From: Philipp Dieter Date: Tue, 2 Nov 2021 00:56:50 +0100 Subject: [PATCH] [BUGFIX] Replacing attribute with html-parser breaks escaping --- index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 684d52e..95e8344 100644 --- a/index.js +++ b/index.js @@ -39,15 +39,17 @@ HtmlWebpackAlterDataPlugin.prototype.apply = function (compiler) { if (!attribute) { continue; } + var attributeReplace = attribute; for (var [source, target] of Object.entries(manifest)) { - attribute = attribute.replace( + attributeReplace = attributeReplace.replace( this.options.assetPrefix + source + '#', 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); } }