Edit this page

up.fragment [up-id]
HTML selector

Sets an unique identifier for this element.

This identifier is used in target derivation to create a CSS selector that matches this element precisely.

If the element already has other attributes that make a good identifier, like a good [id] or [class] attribute, it is not necessary to also set [up-id].

Example

Take this element:

<a href="/">Homepage</a>

Unpoly cannot generate a good CSS selector for this element:

up.fragment.toTarget(element)
// throws error: up.CannotTarget

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.fragment.toTarget(element)
// returns '[up-id="link-to-home"]'

Modifying attributes

up-id

A string that uniquely identifies this element.