1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2025-07-01 20:32:13 +02:00
This commit is contained in:
2024-02-03 14:36:17 +01:00
parent b740b8e020
commit 971b595927
12 changed files with 19 additions and 19 deletions

View File

@ -8,7 +8,7 @@ export function customElementRender(custom_element, target, render, props= obser
});
if(typeof props==="function") props= props.call(custom_element, custom_element);
const is_lte= custom_element[keyLTE];
if(!is_lte) lifecycleToEvents(custom_element);
if(!is_lte) lifecyclesToEvents(custom_element);
const out= render.call(custom_element, props);
if(!is_lte) custom_element.dispatchEvent(new Event(evc));
if(target.nodeType===11 && typeof target.mode==="string") // is ShadowRoot
@ -16,7 +16,7 @@ export function customElementRender(custom_element, target, render, props= obser
scope.pop();
return target.append(out);
}
export function lifecycleToEvents(class_declaration){
export function lifecyclesToEvents(class_declaration){
wrapMethod(class_declaration.prototype, "connectedCallback", function(target, thisArg, detail){
target.apply(thisArg, detail);
thisArg.dispatchEvent(new Event(evc));
@ -37,7 +37,7 @@ export function lifecycleToEvents(class_declaration){
class_declaration.prototype[keyLTE]= true;
return class_declaration;
}
export { lifecycleToEvents as customElementWithDDE };
export { lifecyclesToEvents as customElementWithDDE };
function wrapMethod(obj, method, apply){
obj[method]= new Proxy(obj[method] || (()=> {}), { apply });
}

View File

@ -26,7 +26,7 @@ function setDeleteAttr(obj, prop, val){
if(Reflect.get(obj, prop)==="undefined")
return Reflect.set(obj, prop, "");
}
export const keyLTE= "__dde_lifecycleToEvents"; //boolean
export const keyLTE= "__dde_lifecyclesToEvents"; //boolean
export const evc= "dde:connected";
export const evd= "dde:disconnected";
export const eva= "dde:attributeChanged";