From 4cd447e0ccedb258fab549e1edae2b473bd88778 Mon Sep 17 00:00:00 2001 From: John Kenny Date: Thu, 17 Oct 2024 17:13:26 -0700 Subject: [PATCH] Don't inline symbols that are d with a width/height. --- plugins/inlineUse.js | 12 ++++++++---- test/plugins/inlineUse.08.svg.txt | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 test/plugins/inlineUse.08.svg.txt diff --git a/plugins/inlineUse.js b/plugins/inlineUse.js index d9f9a82..6294e53 100644 --- a/plugins/inlineUse.js +++ b/plugins/inlineUse.js @@ -106,11 +106,15 @@ export const fn = (root, params, info) => { * @returns {boolean} */ function inlineUse(use, def) { - // Don't inline if has children, or has a width or height attribute. + // Don't inline if has children. + if (use.children.length > 0) { + return false; + } + + // Don't inline symbols that are d with a width/height. if ( - use.children.length > 0 || - use.attributes.width || - use.attributes.height + (use.attributes.width || use.attributes.height) && + def.name === 'symbol' ) { return false; } diff --git a/test/plugins/inlineUse.08.svg.txt b/test/plugins/inlineUse.08.svg.txt new file mode 100644 index 0000000..a2661d2 --- /dev/null +++ b/test/plugins/inlineUse.08.svg.txt @@ -0,0 +1,17 @@ +Ignore width and height when inlining a path. + +=== + + + + + + + + +@@@ + + + + +