ionic-team / ionic-team/ionicons

src tag for custom icons does not render for some svg group ids

Abierto
#888 1 comentario 0 reacciones 0 asignados Ver en GitHub
help wanted type: bug
Lenguaje dominante
TypeScript
Estrellas
18.2k
Forks
2.1k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

When adding a custom icon to ion-icon component using the src tag, some ids cause the svg to not be inserted into the DOM / rendered. For example, if you change the `g id="o"` to an id of "on" or "onon" or "one" or "OnePage" or "OnePage--my-id-1" or many other things, the icon doesn't get put inside the `icon-inner` div. Ids that I have found which do make the svg add into the ion-icon element: "a", "b", "bb", "bbb", "bbbb". "O". Removing the id from the group tag allows the icon to render into the DOM.

works:

```

```

doesn't work:

```

```

I can't think of any logical reason why changing this id arbitrarily makes this svg sometimes work and sometimes not? Also, the issue is only when the svg is used as an ionicon not when it is put inside of an ion-button directly, for example.

To reproduce, save the above xml as .svg file in the assets folder and link it with ionicons, eg: ``

EDIT: After searching through the code for ionicons, I found [this line](https://github.com/ionic-team/ionicons/blob/master/src/components/icon/validate.ts#L42). For some reason if the element value contains "on" in any case then it thinks the svg is invalid. What is the purpose behind this conditional? How could we fix it?

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Start at src/components/icon/validate.ts line 42 and inspect why SVG element values containing "on" are treated as invalid. Reproduce with the provided assets/icon.svg examples through an ion-icon src attribute, then verify that ids such as "on" render while invalid SVG handling remains intact.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
typescript
Área
frontend
Tipo de issue
Error
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.