mountAll
The API for mountAll(); Ornata’s declarative API for initializing components from the HTML.
Import
Section titled “Import”import { mountAll } from 'ornata';
const { mountAll } = window.Ornata;Basic usage
Section titled “Basic usage”const instances = mountAll({ Counter, Disclosure,});Expected HTML
Section titled “Expected HTML”mountAll() looks for elements with a data-ornata attribute:
<section data-ornata="Counter"></section><section data-ornata="Disclosure"></section>The attribute value must match a key in the constructor map you pass to mountAll().
Return value
Section titled “Return value”Calling mountAll() returns an array of mounted instances.
const instances = mountAll({ Counter, Disclosure,});const instances = mountAll({ Counter, Disclosure,});Behavior notes
Section titled “Behavior notes”- roots are selected with
document.querySelectorAll("[data-ornata]") - each matching constructor is validated with
isComponent() - each matching root is mounted with
component.mount(rootElement) - the
data-ornataattribute is removed after mounting
See Mounting Instances for a fuller guide.