Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,21 @@ test('a text preserved', () => {

expect(actual).toBe(expected);
});

test('title surrounding whitespace trimmed same as desc', () => {
const descTitleInput = `<svg xmlns="http://www.w3.org/2000/svg">
<desc> My Desc </desc>
<title> My Title </title>
</svg>`;

const descTitleExpected =
'<svg xmlns="http://www.w3.org/2000/svg">' +
'<desc>My Desc</desc>' +
'<title>My Title</title>' +
'</svg>';

const parsed = parseSvg(descTitleInput);
const actual = stringifySvg(parsed, {});

expect(actual).toBe(descTitleExpected);
});
2 changes: 1 addition & 1 deletion plugins/_collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const elemsGroups = {
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre
* @type {Readonly<Set<string>>}
*/
export const textElems = new Set([...elemsGroups.textContent, 'pre', 'title']);
export const textElems = new Set([...elemsGroups.textContent, 'pre']);

/**
* @type {Readonly<Set<string>>}
Expand Down
4 changes: 3 additions & 1 deletion test/plugins/inlineStyles.16.svg.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@

<svg id="Ebene_1" data-name="Ebene 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 222 57.28">
<defs/>
<title>button</title>
<title>
button
</title>
<rect width="222" height="57.28" rx="28.64" ry="28.64" style="fill:#37d0cd;stroke:red"/>
<path d="M312.75,168.66A2.15,2.15,0,0,1,311.2,165L316,160l-4.8-5a2.15,2.15,0,1,1,3.1-3l6.21,6.49a2.15,2.15,0,0,1,0,3L314.31,168a2.14,2.14,0,0,1-1.56.67Zm0,0" transform="translate(-119 -131.36)" style="fill:#fff"/>
<circle cx="33.5" cy="27.25" r="2.94" style="fill:#fff"/>
Expand Down