Ensures a container element has an id, generating one when missing.
MAIDR resolves layer selectors via page-global document.querySelector, so
a bare selector like "rect.bar" would collide with any other chart on the
page. Stamping the container with a stable id and prefixing emitted
selectors with #<id> guarantees page-wide uniqueness without requiring
users to set the id themselves.
Idempotent: re-calling on a container that already has an id is a no-op.
Parameters
container: Element
The root container element (or any element).
prefix: string = 'maidr'
Adapter-specific id prefix used when generating a new id.
Ensures a container element has an
id, generating one when missing.MAIDR resolves layer selectors via page-global
document.querySelector, so a bare selector like"rect.bar"would collide with any other chart on the page. Stamping the container with a stable id and prefixing emitted selectors with#<id>guarantees page-wide uniqueness without requiring users to set the id themselves.Idempotent: re-calling on a container that already has an id is a no-op.