Skip to content

Commit 968aefc

Browse files
committed
fix: handle multi-line svg
1 parent c416a3c commit 968aefc

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/src/util/jquery_prefilter.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ define(() => {
1010
const filteredHtml = html.replaceAll(rxhtmlTag, '<$1></$2>');
1111
if (filteredHtml !== html) {
1212
// Ignore svg content because it is actually XML
13-
const cleanedHtml = html.replaceAll(/<svg[^>]*>(.*?)<\/svg>/g, '').trim();
13+
const cleanedHtml = html
14+
.replaceAll(/<svg[^>]*>(.*?)<\/svg>/gs, '')
15+
.trim();
1416

1517
const result = rxhtmlTag.exec(cleanedHtml);
1618
if (cleanedHtml && result && result[0] !== cleanedHtml) {

tests/jquery_prefilter.test.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,29 @@ it('handles multi-line html', () => {
6969

7070
assertFilter(
7171
`
72-
<div/>
73-
<svg><path/></svg>
72+
<div
73+
data-label="abc"
74+
/>
7475
<span/>
7576
`,
7677
`
77-
<div></div>
78-
<svg><path></path></svg>
78+
<div
79+
data-label="abc"
80+
></div>
7981
<span></span>
8082
`,
8183
true,
8284
);
8385
});
86+
87+
it('handles multi-line svg', () => {
88+
assertFilter(
89+
`<svg id="mol1">
90+
<line x1="100" y1="51.36" />
91+
</svg>`,
92+
`<svg id="mol1">
93+
<line x1="100" y1="51.36" />
94+
</svg>`,
95+
false,
96+
);
97+
});

0 commit comments

Comments
 (0)