Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

122
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda