1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2025-07-04 21:42:14 +02:00

🐛 removed #23, fixed readonly & ddeStringable

This commit is contained in:
2024-12-11 17:05:03 +01:00
parent 4c2edcf58c
commit 2105776d2a
10 changed files with 184 additions and 172 deletions

View File

@ -123,10 +123,11 @@ export function simulateSlots(element, root, mapper){
}
return root;
}
export function cn(...s){ return s.filter(Boolean).join(" "); }
function simulateSlotReplace(slot, element, mapper){
if(mapper) mapper(slot, element);
try{ slot.replaceWith(assign(element, {
className: [ element.className, slot.className ],
className: cn(element.className, slot.className),
dataset: { ...slot.dataset } })); }
catch(_){ slot.replaceWith(element); }
}
@ -231,10 +232,9 @@ function forEachEntries(s, obj, cb){
});
}
function attrArrToStr(attr){ return Array.isArray(attr) ? attr.filter(Boolean).join(" ") : attr; }
function setRemove(obj, prop, key, val){
return obj[ (isUndef(val) ? "remove" : "set") + prop ](key, attrArrToStr(val)); }
return obj[ (isUndef(val) ? "remove" : "set") + prop ](key, val); }
function setRemoveNS(obj, prop, key, val, ns= null){
return obj[ (isUndef(val) ? "remove" : "set") + prop + "NS" ](ns, key, attrArrToStr(val)); }
return obj[ (isUndef(val) ? "remove" : "set") + prop + "NS" ](ns, key, val); }
function setDelete(obj, key, val){
Reflect.set(obj, key, val); if(!isUndef(val)) return; return Reflect.deleteProperty(obj, key); }