Repository navigation
Description
Summary
Octane's event delegation stores handlers on DOM nodes under $$<type> keys ($$click, $$capture:click). Solid's event delegation uses the same node.$$click property. When a Solid-built widget is mounted inside an Octane root, each dispatcher calls the other's handlers. One native click then runs a handler twice.
This affects every Solid-based tool rendered inside an Octane tree, including @tanstack/query-devtools (via @octanejs/tanstack-query-devtools, #1881) and @tanstack/devtools (via @octanejs/tanstack-devtools).
Observed
In examples/hacker-news with <ReactQueryDevtools /> mounted inside QueryClientProvider:
- Devtools handlers fire twice. Clicking a query row in the docked panel never opens the details view. The row handler is the toggle
setSelectedQueryHash(same ? null : hash), and it runs twice per click, so it selects and then immediately deselects. Picture-in-picture mode works because the panel is in a separate window whose document has no Octane root. - Octane handlers fire twice. Once Solid has registered its
documentclick listener, Octane's ownonClickhandlers also fire twice. Solid's handler walks up from the target and calls any function it finds atnode.$$click, and that includes Octane's raw-function slots. Measured on the header<a>new</a>link: 2 calls per click. - Octane's compiled handler bundles can throw in Solid's walk.
$$clickcan also hold aHandlerBundleobject ({ fn, args, … }). Solid callshandler.call(node, e)on whatever it finds there, which fails on an object.
Minimal probe, run in the page with any Solid widget mounted inside the Octane root #app:
const mk = (parent) => {
const d = document.createElement('div');
let n = 0;
d.$$click = () => n++;
parent.appendChild(d);
d.click();
d.remove();
return n;
};
mk(document.body); // 1: only Solid's document listener
mk(document.querySelector('#app').firstElementChild); // 2: Solid + Octane root listenerRoot cause
- Runtime:
eventSlot()buildskey: '$$' + type(packages/octane/src/runtime.ts), and the dispatch walk readsnode[type.bubbleKey]withbubbleKey: '$$' + name. - Compiler:
compile.jsemits the same'$$<event>'/'$$capture:<event>'slot keys. - Solid (
solid-js/webdelegateEvents/eventHandler) readsnode['$$' + e.type]from adocumentlistener.
The two namespaces are identical, so each library treats the other's stamps as its own.
Expected
A foreign library's $$click property must not run through Octane's dispatcher, and Octane's handler slots must not be visible to another library's delegation. One native click runs each handler once.
Proposed fix
Move Octane's delegated-handler slot keys to a namespace that no other framework uses (currently $$<type>; Solid uses $$, Svelte 5 __, Inferno $EV). The change goes in both the runtime and the compiler, with a regression test that mounts a foreign $$click stamp inside an Octane root and asserts that each handler fires exactly once.
Activity
fix(octane): move delegated event slots off Solid's `$$<type>` expando (