ionic-team / ionic-team/ionicons

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

Ouverte
#888 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
help wanted type: bug
Langage dominant
TypeScript
Étoiles
18.2k
Forks
2.1k
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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?

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
typescript
Domaine
frontend
Type d'issue
Bug
Difficulté
2/5
Temps estimé
1-3 heures
Activité
À l'abandon
Clarté
Clairement spécifiée
Accessibilité débutants
45/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.