mirror of
https://github.com/jaandrle/deka-dom-el
synced 2024-11-22 16:55:23 +01:00
🐛 🔨 O.el
This commit is contained in:
parent
277ad6a7f5
commit
7e4c804184
@ -96,7 +96,7 @@ observable.el= function(o, map){
|
|||||||
out.append(mark_start, mark_end);
|
out.append(mark_start, mark_end);
|
||||||
const { current }= scope;
|
const { current }= scope;
|
||||||
const reRenderReactiveElement= v=> {
|
const reRenderReactiveElement= v=> {
|
||||||
if(!mark_start.parentNode || !mark_end.parentNode)
|
if(!mark_start.parentNode || !mark_end.parentNode) // isConnected or wasn’t yet rendered
|
||||||
return removeObservableListener(o, reRenderReactiveElement);
|
return removeObservableListener(o, reRenderReactiveElement);
|
||||||
scope.push(current);
|
scope.push(current);
|
||||||
let els= map(v);
|
let els= map(v);
|
||||||
@ -107,12 +107,21 @@ observable.el= function(o, map){
|
|||||||
while(( el_r= mark_start.nextSibling ) !== mark_end)
|
while(( el_r= mark_start.nextSibling ) !== mark_end)
|
||||||
el_r.remove();
|
el_r.remove();
|
||||||
mark_start.after(...els);
|
mark_start.after(...els);
|
||||||
|
if(mark_start.isConnected)
|
||||||
|
requestCleanUpReactives(current.host());
|
||||||
};
|
};
|
||||||
addObservableListener(o, reRenderReactiveElement);
|
addObservableListener(o, reRenderReactiveElement);
|
||||||
removeObservablesFromElements(o, reRenderReactiveElement, mark_start, map);
|
removeObservablesFromElements(o, reRenderReactiveElement, mark_start, map);
|
||||||
reRenderReactiveElement(o());
|
reRenderReactiveElement(o());
|
||||||
return out;
|
return out;
|
||||||
};
|
};
|
||||||
|
function requestCleanUpReactives(host){
|
||||||
|
if(!host || !host[key_reactive]) return;
|
||||||
|
(requestIdleCallback || setTimeout)(function(){
|
||||||
|
host[key_reactive]= host[key_reactive]
|
||||||
|
.filter(([ o, el ])=> el.isConnected ? true : (removeObservableListener(...o), false));
|
||||||
|
});
|
||||||
|
}
|
||||||
import { on } from "./events.js";
|
import { on } from "./events.js";
|
||||||
import { observedAttributes } from "./helpers.js";
|
import { observedAttributes } from "./helpers.js";
|
||||||
const observedAttributeActions= {
|
const observedAttributeActions= {
|
||||||
|
Loading…
Reference in New Issue
Block a user