1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2025-04-02 04:05:52 +02:00

🐛 ensures only one disconncetd listener

…for cleanup
This commit is contained in:
Jan Andrle 2025-03-19 11:39:45 +01:00
parent 74ed180919
commit ad255e3e19
Signed by: jaandrle
GPG Key ID: B3A25AED155AFFAB
5 changed files with 19 additions and 12 deletions

View File

@ -886,9 +886,10 @@ var signals_config = {
function removeSignalsFromElements(s, listener, ...notes) { function removeSignalsFromElements(s, listener, ...notes) {
const { current } = scope; const { current } = scope;
current.host(function(element) { current.host(function(element) {
if (!element[key_reactive]) element[key_reactive] = []; const is_first = !element[key_reactive];
if (is_first) element[key_reactive] = [];
element[key_reactive].push([[s, listener], ...notes]); element[key_reactive].push([[s, listener], ...notes]);
if (current.prevent) return; if (!is_first || current.prevent) return;
on.disconnected( on.disconnected(
() => ( () => (
/*! Clears all Signals listeners added in the current scope/host (`S.el`, `assign`, ?). /*! Clears all Signals listeners added in the current scope/host (`S.el`, `assign`, ?).

File diff suppressed because one or more lines are too long

View File

@ -931,9 +931,10 @@ var DDE = (() => {
function removeSignalsFromElements(s, listener, ...notes) { function removeSignalsFromElements(s, listener, ...notes) {
const { current } = scope; const { current } = scope;
current.host(function(element) { current.host(function(element) {
if (!element[key_reactive]) element[key_reactive] = []; const is_first = !element[key_reactive];
if (is_first) element[key_reactive] = [];
element[key_reactive].push([[s, listener], ...notes]); element[key_reactive].push([[s, listener], ...notes]);
if (current.prevent) return; if (!is_first || current.prevent) return;
on.disconnected( on.disconnected(
() => ( () => (
/*! Clears all Signals listeners added in the current scope/host (`S.el`, `assign`, ?). /*! Clears all Signals listeners added in the current scope/host (`S.el`, `assign`, ?).

File diff suppressed because one or more lines are too long

View File

@ -313,9 +313,14 @@ export const signals_config= {
function removeSignalsFromElements(s, listener, ...notes){ function removeSignalsFromElements(s, listener, ...notes){
const { current }= scope; const { current }= scope;
current.host(function(element){ current.host(function(element){
if(!element[key_reactive]) element[key_reactive]= []; const is_first= !element[key_reactive];
if(is_first) element[key_reactive]= [];
element[key_reactive].push([ [ s, listener ], ...notes ]); element[key_reactive].push([ [ s, listener ], ...notes ]);
if(current.prevent) return; // typically document.body, doenst need auto-remove as it should happen on page leave if(
!is_first
// typically document.body, doenst need auto-remove as it should happen on page leave
|| current.prevent
) return;
on.disconnected(()=> on.disconnected(()=>
/*! Clears all Signals listeners added in the current scope/host (`S.el`, `assign`, ?). /*! Clears all Signals listeners added in the current scope/host (`S.el`, `assign`, ?).
You can investigate the `__dde_reactive` key of the element. */ You can investigate the `__dde_reactive` key of the element. */