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

126
Views
No se puede insertar un <polygon> dentro de un <svg> imprimiendo su html con {@html} en Svelte

Este es mi componente principal:

 <script> import ObjOne from './ObjOne.svelte' </script> <svg width="182px" height="146px" viewBox="0 0 182 146"> <ObjOne></ObjOne> </svg>

Y este es ObjOne:

 <script> let html = '<polygon id="Path" fill="#999999" points="109.9999 146.25 109.9999 98.75 182.4999 98.75 182.4999 146.25" />' </script> {@html html}

El polígono no se procesa, a menos que coloque el <polygon> directamente en el cuerpo del componente, como puede ver en el REPL. ¿Hay algún trabajo alrededor? Necesito insertar dinámicamente elementos en un <svg> . Probé con las propiedades version y xmlns en <svg> pero no funcionó.

REEMPLAZO: https://svelte.dev/repl/14b354d830184a8d994cae6d223e4c85?version=3.49.0

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Este es un problema conocido con la forma en que @html genera elementos en SVG. En este caso, el compilador no tiene suficiente contexto para saber que se supone que el elemento es un elemento SVG, por lo que terminará con el espacio de nombres incorrecto (HTML).

Como solución alternativa, podría agregar un grupo ficticio:

 <g>{@html html}</g>
about 4 years ago · Santiago Trujillo Report
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!