Skip to content
Gx
GitHub

GX2019: one id on two elements of a component

Two elements of one component have the same static id.

Cause

An id names one element of a document. With one id on two elements, a label for, a link to #intro and a patch of Gx reach only the first one.

Gx gives no finding for two elements in two branches of one if or switch: one render holds one of them.

Example

page/Page.gx
package page

<main>
  <section id="intro">One</section>
  <section id="intro">Two</section>
</main>

gx check reports:

gx check
page/Page.gx:5:3: GX2019: the id "intro" is on two elements of the component: an id names one element

Fix

  1. Give each element its own id.
  2. For an element in a loop, use a keyed fragment: <li #row(key string) key={key}>. Gx then makes one id for each key.