vUX · Component · bring your own component
Write the markup once, mark it up with data-v-* bindings, and hand it to Component. You get cloning, field binding, event wiring and teardown, over your own HTML, styled by your own stylesheet.
Every card below is a clone of the same <template>. Mounting returns an
Instance: an object with its own node, its own data, and its own
update() and destroy(). The template itself is never touched.
The Pin and Remove buttons are wired through data-v-on, not
through any listener this page attached. Their handlers live in
config.handlers and are handed the instance's current data.
Each control writes one field through instance.update(). Only the bindings whose
value actually moved are written to the DOM: the rest are left alone.
The pill above the card reports what update() returned: the list of field names
that changed. Edit a field to a value it already holds and it reports nothing: no DOM write happens.
sync() matches data to instances by config.key. Rows that survive are
moved, not rebuilt, so anything the browser owns inside them survives too.
Try this: type into a row's text box, then press sort by score. The row moves and your text moves with it. Then press rebuild, which throws the instances away and mounts fresh ones, and the text is gone. That difference is the whole point of keying.
A child mounted through instance.mount() is owned by its parent. Destroy the
parent and the children go with it: including the vUX components attached in
onMount.
Each board attaches a ToolTip in onMount and calls its
destroy() in onDestroy: hover a chip to see it. Before v4.0.0
most vUX components had no destroy() to call, which is why this module waited on
that work. The log records every mount, update and destroy as it happens.
Every button below deliberately misuses the API. The real thrown Error is printed
verbatim: nothing here is a canned string.
The constructor takes an element, not a selector or an id.
The template is resolved by initialize(); nothing works before it.
A binding naming a handler that was never supplied, or a malformed pair.
Asking for a data-v-ref the template does not carry lists the ones it does.
A list needs a key, and the key has to be unique and present.
An instance that has been destroyed refuses to be updated again.