Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

120
Views
svg polygon style.fill problem with patterns

I have a script that generates polygons and attach them to an SVG element. When I generate the polygon I can change it's style simply like this:

part.style.strokeWidth = 2;
part.style.stroke = '#fd9f31';
part.style.fill = '#fd9f31';

However if I try to use a pattern as fill it won't work

part.style.fill = 'url(#diagonalHatch)'

Also I noticed that in the outerHTML of the object it appears like

<polygon style="stroke-width: 2; stroke: rgb(253, 159, 49); fill: url(&quot;#diagonalHatch&quot;);" points="9.21 -11.75 ...etc

I think the problem is with those 2 &quot ; any idea on how to escape them? I tried also to change it by using setAttribute and setAttributeNS but it doesn't seem to work. I also tried to use regex to modify the outerHTML but after putting it back it's again the same as before.

Thanks for helping :)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!