Skip to content

Commit 6538230

Browse files
committed
performance: small optimization when parsing svgs
1 parent 26d059f commit 6538230

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/parser.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,17 @@ export const parseSvg = (data, from) => {
169169
value: text,
170170
};
171171
pushToContent(node);
172-
} else if (/\S/.test(text)) {
173-
/** @type {import('./types.js').XastText} */
174-
const node = {
175-
type: 'text',
176-
value: text.trim(),
177-
};
178-
pushToContent(node);
172+
} else {
173+
const value = text.trim();
174+
175+
if (value !== '') {
176+
/** @type {import('./types.js').XastText} */
177+
const node = {
178+
type: 'text',
179+
value,
180+
};
181+
pushToContent(node);
182+
}
179183
}
180184
}
181185
};

0 commit comments

Comments
 (0)