mirror of
https://github.com/jaandrle/deka-dom-el
synced 2024-11-21 15:39:36 +01:00
🐛 Small bugs in observables and observable valueOf
- new reactive element content can be empty (or contains DocumentFragment) - better WC observed attributes handling
This commit is contained in:
parent
971b595927
commit
f1983dcd38
@ -118,11 +118,13 @@ observable.el= function(o, map){
|
|||||||
scope.pop();
|
scope.pop();
|
||||||
if(!Array.isArray(els))
|
if(!Array.isArray(els))
|
||||||
els= [ els ];
|
els= [ els ];
|
||||||
|
const el_start_rm= document.createComment("");
|
||||||
|
els.push(el_start_rm);
|
||||||
mark_start.after(...els);
|
mark_start.after(...els);
|
||||||
const el_last_keep= els[els.length-1];
|
|
||||||
let el_r;
|
let el_r;
|
||||||
while(( el_r= el_last_keep.nextSibling ) !== mark_end)
|
while(( el_r= el_start_rm.nextSibling ) && el_r !== mark_end)
|
||||||
el_r.remove();
|
el_r.remove();
|
||||||
|
el_start_rm.remove();
|
||||||
if(mark_start.isConnected)
|
if(mark_start.isConnected)
|
||||||
requestCleanUpReactives(current.host());
|
requestCleanUpReactives(current.host());
|
||||||
};
|
};
|
||||||
@ -146,9 +148,9 @@ const observedAttributeActions= {
|
|||||||
function observedAttribute(store){
|
function observedAttribute(store){
|
||||||
return function(instance, name){
|
return function(instance, name){
|
||||||
const varO= (...args)=> !args.length
|
const varO= (...args)=> !args.length
|
||||||
? instance.getAttribute(name)
|
? read(varO)
|
||||||
: instance.setAttribute(name, ...args);
|
: instance.setAttribute(name, ...args);
|
||||||
const out= toObservable(varO, varO(), observedAttributeActions);
|
const out= toObservable(varO, instance.getAttribute(name), observedAttributeActions);
|
||||||
store[name]= out;
|
store[name]= out;
|
||||||
return out;
|
return out;
|
||||||
};
|
};
|
||||||
@ -247,6 +249,7 @@ function toObservable(o, value, actions, readonly= false){
|
|||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
o.toJSON= ()=> o();
|
o.toJSON= ()=> o();
|
||||||
|
o.valueOf= ()=> o[mark] && o[mark].value;
|
||||||
Object.setPrototypeOf(o[mark], protoSigal);
|
Object.setPrototypeOf(o[mark], protoSigal);
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user