mirror of
https://github.com/jaandrle/deka-dom-el
synced 2024-11-21 23:39:37 +01:00
✨ href
/src
see #5 ♻️ renaming
This commit is contained in:
parent
eb8aa93f06
commit
f632be61cf
@ -50,7 +50,7 @@ export function assign(element, ...attributes){
|
||||
case "style": return forEachEntries(attr, setRemove.bind(null, element.style, "Property"));
|
||||
case "dataset": return forEachEntries(attr, setDelete.bind(null, element.dataset));
|
||||
case "ariaset": return forEachEntries(attr, (key, val)=> setRemoveAttr("aria-"+key, val));
|
||||
case "classList": return classListDeclartive(element, attr);
|
||||
case "classList": return classListDeclarative(element, attr);
|
||||
default: return Reflect.set(element, key, attr);
|
||||
}
|
||||
}
|
||||
@ -59,6 +59,8 @@ export function assign(element, ...attributes){
|
||||
return setRemoveAttr(key, attr);
|
||||
}
|
||||
switch(key){
|
||||
case "href" || "src":
|
||||
return setRemoveAttr(key, attr);
|
||||
case "xlink:href":
|
||||
return setRemoveAttr(key, attr, "http://www.w3.org/1999/xlink");
|
||||
case "textContent" || "innerText":
|
||||
@ -69,7 +71,7 @@ export function assign(element, ...attributes){
|
||||
});
|
||||
return element;
|
||||
}
|
||||
export function classListDeclartive(element, toggle){
|
||||
export function classListDeclarative(element, toggle){
|
||||
if(typeof toggle !== "object") return element;
|
||||
|
||||
forEachEntries(toggle,
|
||||
@ -101,6 +103,7 @@ function getPropDescriptor(p, key, level= 0){
|
||||
return [ des, level, p ];
|
||||
}
|
||||
|
||||
/** @template {Record<any, any>} T @param {T} obj @param {(param: [ keyof T, T[keyof T] ])=> void} cb */
|
||||
function forEachEntries(obj, cb){ return Object.entries(obj).forEach(([ key, val ])=> cb(key, val)); }
|
||||
function isUndef(value){ return typeof value==="undefined"; }
|
||||
|
||||
|
@ -7,19 +7,19 @@ export function on(event, listener, options){
|
||||
};
|
||||
}
|
||||
|
||||
const connections_changes= connectionsChangesObserverConstructor();
|
||||
const c_ch_o= connectionsChangesObserverConstructor();
|
||||
on.connected= function(listener, options){
|
||||
return function registerElement(element){
|
||||
connections_changes.onConnected(element, listener);
|
||||
c_ch_o.onConnected(element, listener);
|
||||
if(options && options.signal)
|
||||
options.signal.addEventListener("abort", ()=> connections_changes.offConnected(element, listener));
|
||||
options.signal.addEventListener("abort", ()=> c_ch_o.offConnected(element, listener));
|
||||
};
|
||||
};
|
||||
on.disconnected= function(listener, options){
|
||||
return function registerElement(element){
|
||||
connections_changes.onDisconnected(element, listener);
|
||||
c_ch_o.onDisconnected(element, listener);
|
||||
if(options && options.signal)
|
||||
options.signal.addEventListener("abort", ()=> connections_changes.offDisconnected(element, listener));
|
||||
options.signal.addEventListener("abort", ()=> c_ch_o.offDisconnected(element, listener));
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user