Browser experiments & working notes
Renderer examples / Vue
Vue components.
Native targets.
Custom elements built with Vue’s reactive rendering and defineCustomElement API.
for="host"#controlWaiting for Vue to render…
Browser details
- Current path
- Checking browser support…
- Native API surface
- Checking…
- Active adapters
- Waiting for setup…
Automatic checks for the native property. Force fallback loads the selected adapters. Browser alone leaves them out.
Labels & rendering
A new control. The same reference.
The outside label references the component. Vue renders the checkbox inside its shadow root.
Try: Click the label, replace the checkbox, then click the label again. Each replacement starts unchecked.
Popover targeting
An outside button. A rendered panel.
Vue creates a native popover inside another component. The outside buttons reference its host.
Try: Open the popover, then dismiss it with its close button or Escape.
Open an internal popover
How the examples are connected
Each component sets its shadow root’s referenceTarget to the internal target ID. The fallback loads before the component definitions, so it can capture the roots when the renderer creates them and observe later DOM changes.
The page waits for the renderer’s first update before enabling its buttons. Replacing the checkbox changes the component’s revision attribute; the renderer creates a new input with the same ID.
<label for="renderer-checkbox">Send me release notes</label>
<rt-vue-checkbox id="renderer-checkbox" revision="0"></rt-vue-checkbox>
<button type="button" popovertarget="renderer-popover">Open popover</button>
<rt-vue-popover id="renderer-popover"></rt-vue-popover>
The selected setup uses labels({ activation: "focus-and-click", naming: true }) and popoverTargets(). The page’s event listeners only display state; they do not forward label or popover actions.
Component source
components.js
import {
defineCustomElement,
h,
nextTick,
onMounted,
useHost,
useShadowRoot,
} from "vue/dist/vue.runtime.esm-bundler.js";
import componentStyles from "../shared/components.css";
import { withRendererTimeout } from "../shared/renderer-readiness.js";
const firstRenders = new WeakMap();
function firstRender(host) {
let ready = firstRenders.get(host);
if (!ready) {
let resolve;
const promise = new Promise(done => { resolve = done; });
ready = { promise, resolve };
firstRenders.set(host, ready);
}
return ready;
}
function useReferenceTarget(target) {
useShadowRoot().referenceTarget = target;
onMounted(firstRender(useHost()).resolve);
}
const VueCheckbox = defineCustomElement({
name: "ReferenceTargetVueCheckbox",
inheritAttrs: false,
styles: [componentStyles],
props: { revision: { type: Number, default: 0 } },
setup(props) {
useReferenceTarget("control");
return () => [
h("div", { class: "component-preview" }, [
h("input", {
key: props.revision,
id: "control",
type: "checkbox",
"data-revision": props.revision,
}),
h("span", { "aria-hidden": "true" }, "Native checkbox"),
]),
h("p", { class: "hint" }, `Render revision ${props.revision}`),
];
},
});
const VuePopover = defineCustomElement({
name: "ReferenceTargetVuePopover",
inheritAttrs: false,
styles: [componentStyles],
setup() {
useReferenceTarget("panel");
return () => h("div", { id: "panel", popover: "auto", role: "dialog", "aria-labelledby": "panel-title" }, [
h("p", { class: "eyebrow" }, "Vue · shadow DOM"),
h("h2", { id: "panel-title" }, "Rendered with Vue"),
h("p", null, "This native popover lives inside a Vue custom element's shadow root."),
h("button", {
type: "button",
popovertarget: "panel",
popovertargetaction: "hide",
autofocus: true,
}, "Close popover"),
]);
},
});
customElements.define("rt-vue-checkbox", VueCheckbox);
customElements.define("rt-vue-popover", VuePopover);
export async function whenReady() {
await withRendererTimeout((async () => {
await Promise.all([
firstRender(document.getElementById("renderer-checkbox")).promise,
firstRender(document.getElementById("renderer-popover")).promise,
]);
await nextTick();
})(), "Vue");
}
Functional JavaScript sizes
Functional page JavaScript
70.788 KB 27.503 KB gzipAlways loaded.
Fallback additional
23.929 KB 8.430 KB gzipCore + selected adapters.
Fallback route total
94.717 KB 35.933 KB gzipAlways-loaded and fallback files; shared files counted once.
Native-surface route total
71.777 KB 28.041 KB gzipIncludes 0.989 KB (0.538 KB gzip) of behavioral probes requested only after the property surface is present.
Minified / gzip. 1 KB = 1,000 bytes. Demo-only syntax highlighting is excluded from the functional totals and reported separately below.
Whole-page delivery context
HTML document
19.081 KB 1 requestGenerated markup, including these measurements.
Initial supporting assets
18.520 KB raw 17.897 KB local transfer · 3 requestsStyles, icon, and the highlighting scheduler; functional JS is separate above.
Initial page with fallback
132.318 KB raw 72.911 KB local transfer · 9 requestsDocument + functional fallback path + initial supporting assets, with unique files counted once.
Deferred highlighting
16.700 KB raw 7.831 KB local transfer · 8 requestsEngine, theme, and this page’s grammar closure, requested after a source disclosure opens or during idle time.
“Local transfer” matches the included development server: gzip JavaScript sidecars, but uncompressed HTML, CSS, and SVG. GitHub Pages, browser caching, HTTP headers, and production compression can change transferred bytes and request scheduling. Module preloads fetch functional modules early without evaluating the app and do not add duplicate transfers.
Inspect the 6 generated JavaScript files
Selected adapters: labels, popover-targets.
Gzip totals sum each compressed file. The fallback and native-probe routes are mutually exclusive. Separate CSS files, HTML, JSON, source maps, HTTP headers, and Microlighter assets are excluded. Component styles embedded in JavaScript are included. Transfer sizes depend on compression and caching. Microlighter MIT license.
| File | Delivery | Minified | Gzip |
|---|---|---|---|
shared/chunks/app-RVAFZE4Y.js |
Page | 67.389 KB | 26.013 KB |
shared/chunks/chunk-CLCOZ6O7.js |
Fallback / native probe shared | 0.849 KB | 0.422 KB |
shared/chunks/chunk-S2QLMWTP.js |
Page | 0.142 KB | 0.138 KB |
shared/chunks/detect-X6QVIAY4.js |
Native-surface probe | 0.140 KB | 0.116 KB |
shared/chunks/reference-target.setup-F3BB382F.js |
Fallback additional | 23.080 KB | 8.008 KB |
vue/main.js |
Page | 3.257 KB | 1.352 KB |
Renderer integration & limitations
Vue and Reference Target
Vue creates each shadow root with defineCustomElement. A numeric revision prop keys the rendered checkbox, and onMounted signals that the initial targets exist. The page uses Vue’s runtime-only entry point; no template compiler is sent to the browser.
Vue 3.5.42 renders again after a full disconnection and reconnection, but stops observing subsequent attribute changes on that instance. These cases update mounted components; create a fresh element after a full teardown.
The library and its component code are included in Page JavaScript above. Each renderer is built as an independent page with only the labels and popover-targets adapters in its optional fallback bundle.
These examples use open, client-rendered roots. They do not test server rendering or hydration. The label fallback does not recreate native label.control or input.labels relationships. Readouts describe DOM state; computed names and assistive technology need separate validation.