Ensures a container element has an id attribute, generating one when
missing. Returns the (possibly newly assigned) id.
MAIDR resolves layer selectors via document.querySelector, which is
page-global — a bare selector like "rect.bar" would collide with any
other chart on the page. By stamping the container with a stable id and
prefixing all emitted selectors with #<id>, we guarantee 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.
Ensures a container element has an
idattribute, generating one when missing. Returns the (possibly newly assigned) id.MAIDR resolves layer selectors via
document.querySelector, which is page-global — a bare selector like"rect.bar"would collide with any other chart on the page. By stamping the container with a stable id and prefixing all emitted selectors with#<id>, we guarantee 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.