mirror of https://github.com/sveltejs/svelte
fix: allow custom element events on slot to bubble inside custom element (#13222)
Fixes #13162 We were going from parentNode to parentNode but if something is a slot of a custom element we should first go to the assignedSlot or else the inside of the custom element will be skipped. --------- Co-authored-by: Oscar Dominguez <dominguez.celada@gmail.com>pull/13230/head
parent
6604e38059
commit
09dff9bde2
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: allow custom element events on slot to bubble inside custom element
|
@ -0,0 +1,21 @@
|
|||||||
|
import { test } from '../../assert';
|
||||||
|
const tick = () => Promise.resolve();
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
async test({ assert, target }) {
|
||||||
|
target.innerHTML = '<custom-element><span></span></custom-element>';
|
||||||
|
|
||||||
|
const custom_element = target.querySelector('custom-element');
|
||||||
|
|
||||||
|
const logs = [];
|
||||||
|
custom_element.callback = () => {
|
||||||
|
logs.push('called');
|
||||||
|
};
|
||||||
|
|
||||||
|
await tick();
|
||||||
|
/** @type {any} */
|
||||||
|
const span = target.querySelector('span');
|
||||||
|
span.click();
|
||||||
|
assert.deepEqual(logs, ['called']);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,7 @@
|
|||||||
|
<svelte:options customElement="custom-element" />
|
||||||
|
|
||||||
|
<button onclick={(e)=>{
|
||||||
|
$host().callback();
|
||||||
|
}}>
|
||||||
|
<slot></slot>
|
||||||
|
</button>
|
Loading…
Reference in new issue