Id and name attributes
rlilov opened this issue · 1 comments
Excellent component @pozil . Thanks!
I am using it in a project where I have 3 lookup combo components on a screen.
To differentiate between them , I am using data-id attribute. All works, maybe the queryselector is a bit verbose, but no big deal.
I am simply curious why id and name attributes are not exposed for end user to consume.
Hi @rlilov and thanks for the feedback.
As a general rule, id
attributes shouldn't be used in LWC appart for accessibility purposes:
When a template is rendered, id values may be transformed into globally unique values. Don’t use an id selector in CSS or JavaScript because it won’t match the transformed id. Instead, use the element's class attribute or a data-* attribute like data-id.
However, you can use the name
attribute if you'd like instead of data-id
(name
doesn't need to be part of the Lookup component internal definition).