Sets an unique identifier for this element.
This identifier is used by up.element.toSelector()
to create a CSS selector that matches this element precisely.
If the element already has other attributes that make a good identifier,
like a [id]
, [class]
or [aria-label]
, it is not necessary to
set [up-id]
.
Take this element:
<a href="/">Homepage</a>
Unpoly cannot generate a good CSS selector for this element:
up.element.toSelector(element)
// returns 'a'
We can improve this by assigning an [up-id]
:
<a href="/" up-id="link-to-home">Open user 4</a>
The attribute value is used to create a better selector:
up.element.toSelector(element)
// returns '[up-id="link-to-home"]'
A string that uniquely identifies this element.