Forking off from #65; context doesn't work when creating elements without { shadow: true }.
The cause is that the event listener is attached to a slot in shadow mode, and to a Fragment in light DOM mode. Fragments don't handle the events.
I've confirmed that replacing the Fragment with a real element fixes the issue, by applying the change below. I'm opening this issue instead of creating a pull-request, as wrapping elements in another custom element, might be undesired.
Potential fix, replace these lines:
|
const { useFragment, ...rest } = props; |
|
return h(useFragment ? Fragment : 'slot', { ...rest, ref }); |
With:
const { useFragment, ...rest } = props;
let tag = 'slot';
if (useFragment) {
tag = 'preact-context-bridge';
rest.style = 'display: contents;';
}
return h(tag, { ...rest, ref });
Forking off from #65;
contextdoesn't work when creating elements without{ shadow: true }.The cause is that the event listener is attached to a
slotin shadow mode, and to aFragmentin light DOM mode. Fragments don't handle the events.I've confirmed that replacing the
Fragmentwith a real element fixes the issue, by applying the change below. I'm opening this issue instead of creating a pull-request, as wrapping elements in another custom element, might be undesired.Potential fix, replace these lines:
preact-custom-element/src/index.js
Lines 180 to 181 in 0a8ccf7
With: