spectrum-web-components
spectrum-web-components copied to clipboard
Review use of abortSignal in events listener patterns.
Code of conduct
- [X] I agree to follow this project's code of conduct.
Description of issue
Can https://github.com/whatwg/dom/issues/911 be leveraged along the lines of:
const ac = new AbortController();
let { signal } = ac;
parentElement.addEventListener(
'pointerenter',
this.openOverlay,
{ signal }
);
parentElement.addEventListener('focusin', this.openOverlay, { signal });
parentElement.addEventListener(
'pointerleave',
this.closeOverlay,
{ signal }
);
parentElement.addEventListener('focusout', this.closeOverlay, { signal });
ac.abort();
To simplify events being added/removed from elements imperatively.
Things to confirm:
- does the abortController really work across multiple listeners?
- does Safari support it broadly enough to allow in the library?
- does it have undesired perf costs?
- others?