Skip to content

Commit

Permalink
Optimize regex for handling gradient style lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
enourbakhsh committed Oct 1, 2024
1 parent 4b4d347 commit 5f82e6e
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const draw = async function (text: string, id: string, _version: string,
// Look for all gradient styles, ensuring that nested parentheses due to color functions are handled properly
const linearGradientStyles = vertex.cssCompiledStyles
?.join('')
?.match(/fill\s*:\s*linear-gradient\(([^()]*(\([^()]*\))*[^()]*)+\)/g);
?.match(/fill\s*:\s*linear-gradient\([^()]*?(?:\([^()]*?\)[^()]*)*\)/g);

if (linearGradientStyles) {
shapeElement.style('fill', null); // Clear any existing fill
Expand Down

0 comments on commit 5f82e6e

Please sign in to comment.