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

:tap: removed on.attributeChanged and static observedAttributes

This commit is contained in:
2025-03-10 10:49:26 +01:00
parent e1f321004d
commit 15dc342ae8
27 changed files with 33 additions and 210 deletions

View File

@ -214,7 +214,6 @@ export const scope: {
export function customElementRender<EL extends HTMLElement, P extends any = Record<string, string | Signal<string, {}>>>(target: ShadowRoot | EL, render: (props: P) => SupportedElement | DocumentFragment, props?: P | ((el: EL) => P)): EL;
export function customElementWithDDE<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function lifecyclesToEvents<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function observedAttributes(custom_element: HTMLElement): Record<string, string>;
/**
* This is used primarly for server side rendering. To be sure that all async operations
* are finished before the page is sent to the client.

View File

@ -32,8 +32,8 @@ function onAbort(signal2, listener) {
};
}
function observedAttributes(instance, observedAttribute2) {
const { observedAttributes: observedAttributes3 = [] } = instance.constructor;
return observedAttributes3.reduce(function(out, name) {
const { observedAttributes: observedAttributes2 = [] } = instance.constructor;
return observedAttributes2.reduce(function(out, name) {
out[kebabToCamel(name)] = observedAttribute2(instance, name);
return out;
}, {});
@ -545,7 +545,7 @@ function connectionsChangesObserverConstructor() {
}
// src/customElement.js
function customElementRender(target, render, props = observedAttributes2) {
function customElementRender(target, render, props = {}) {
const custom_element = target.host || target;
scope.push({
scope: custom_element,
@ -586,9 +586,6 @@ function wrapMethod(obj, method, apply) {
obj[method] = new Proxy(obj[method] || (() => {
}), { apply });
}
function observedAttributes2(instance) {
return observedAttributes(instance, (i, n) => i.getAttribute(n));
}
// src/events.js
function dispatchEvent(name, options, host) {
@ -642,26 +639,6 @@ on.disconnectedAsAbort = function(host) {
host(on.disconnected(() => a.abort()));
return a.signal;
};
var els_attribute_store = /* @__PURE__ */ new WeakSet();
on.attributeChanged = function(listener, options) {
if (typeof options !== "object")
options = {};
return function registerElement(element) {
element.addEventListener(eva, listener, options);
if (element[keyLTE] || els_attribute_store.has(element))
return element;
if (!enviroment.M) return element;
const observer = new enviroment.M(function(mutations) {
for (const { attributeName, target } of mutations)
target.dispatchEvent(
new CustomEvent(eva, { detail: [attributeName, target.getAttribute(attributeName)] })
);
});
const c = onAbort(options.signal, () => observer.disconnect());
if (c) observer.observe(element, { attributes: true });
return element;
};
};
// src/signals-lib/helpers.js
var mark = "__dde_signal";
@ -846,7 +823,7 @@ var key_attributes = "__dde_attributes";
signal.observedAttributes = function(element) {
const store = element[key_attributes] = {};
const attrs = observedAttributes(element, observedAttribute(store));
on.attributeChanged(function attributeChangeToSignal({ detail }) {
on(eva, function attributeChangeToSignal({ detail }) {
/*! This maps attributes to signals (`S.observedAttributes`).
Investigate `__dde_attributes` key of the element. */
const [name, value] = detail;
@ -997,7 +974,6 @@ export {
elementAttribute,
isSignal,
lifecyclesToEvents,
observedAttributes2 as observedAttributes,
on,
queue,
registerReactivity,

View File

@ -214,7 +214,6 @@ export const scope: {
export function customElementRender<EL extends HTMLElement, P extends any = Record<string, string | Signal<string, {}>>>(target: ShadowRoot | EL, render: (props: P) => SupportedElement | DocumentFragment, props?: P | ((el: EL) => P)): EL;
export function customElementWithDDE<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function lifecyclesToEvents<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function observedAttributes(custom_element: HTMLElement): Record<string, string>;
/**
* This is used primarly for server side rendering. To be sure that all async operations
* are finished before the page is sent to the client.

File diff suppressed because one or more lines are too long

1
dist/esm.d.ts vendored
View File

@ -213,7 +213,6 @@ export const scope: {
export function customElementRender<EL extends HTMLElement, P extends any = Record<string, string | Signal<string, {}>>>(target: ShadowRoot | EL, render: (props: P) => SupportedElement | DocumentFragment, props?: P | ((el: EL) => P)): EL;
export function customElementWithDDE<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function lifecyclesToEvents<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function observedAttributes(custom_element: HTMLElement): Record<string, string>;
/**
* This is used primarly for server side rendering. To be sure that all async operations
* are finished before the page is sent to the client.

36
dist/esm.js vendored
View File

@ -21,16 +21,6 @@ function onAbort(signal, listener) {
signal.removeEventListener("abort", listener);
};
}
function observedAttributes(instance, observedAttribute) {
const { observedAttributes: observedAttributes3 = [] } = instance.constructor;
return observedAttributes3.reduce(function(out, name) {
out[kebabToCamel(name)] = observedAttribute(instance, name);
return out;
}, {});
}
function kebabToCamel(name) {
return name.replace(/-./g, (x) => x[1].toUpperCase());
}
// src/signals-lib/common.js
var signals_global = {
@ -522,7 +512,7 @@ function connectionsChangesObserverConstructor() {
}
// src/customElement.js
function customElementRender(target, render, props = observedAttributes2) {
function customElementRender(target, render, props = {}) {
const custom_element = target.host || target;
scope.push({
scope: custom_element,
@ -563,9 +553,6 @@ function wrapMethod(obj, method, apply) {
obj[method] = new Proxy(obj[method] || (() => {
}), { apply });
}
function observedAttributes2(instance) {
return observedAttributes(instance, (i, n) => i.getAttribute(n));
}
// src/events.js
function dispatchEvent(name, options, host) {
@ -619,26 +606,6 @@ on.disconnectedAsAbort = function(host) {
host(on.disconnected(() => a.abort()));
return a.signal;
};
var els_attribute_store = /* @__PURE__ */ new WeakSet();
on.attributeChanged = function(listener, options) {
if (typeof options !== "object")
options = {};
return function registerElement(element) {
element.addEventListener(eva, listener, options);
if (element[keyLTE] || els_attribute_store.has(element))
return element;
if (!enviroment.M) return element;
const observer = new enviroment.M(function(mutations) {
for (const { attributeName, target } of mutations)
target.dispatchEvent(
new CustomEvent(eva, { detail: [attributeName, target.getAttribute(attributeName)] })
);
});
const c = onAbort(options.signal, () => observer.disconnect());
if (c) observer.observe(element, { attributes: true });
return element;
};
};
export {
assign,
assignAttribute,
@ -653,7 +620,6 @@ export {
createElementNS as elNS,
elementAttribute,
lifecyclesToEvents,
observedAttributes2 as observedAttributes,
on,
queue,
registerReactivity,

1
dist/esm.min.d.ts vendored
View File

@ -213,7 +213,6 @@ export const scope: {
export function customElementRender<EL extends HTMLElement, P extends any = Record<string, string | Signal<string, {}>>>(target: ShadowRoot | EL, render: (props: P) => SupportedElement | DocumentFragment, props?: P | ((el: EL) => P)): EL;
export function customElementWithDDE<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function lifecyclesToEvents<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function observedAttributes(custom_element: HTMLElement): Record<string, string>;
/**
* This is used primarly for server side rendering. To be sure that all async operations
* are finished before the page is sent to the client.

2
dist/esm.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -214,7 +214,6 @@ export const scope: {
export function customElementRender<EL extends HTMLElement, P extends any = Record<string, string | Signal<string, {}>>>(target: ShadowRoot | EL, render: (props: P) => SupportedElement | DocumentFragment, props?: P | ((el: EL) => P)): EL;
export function customElementWithDDE<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function lifecyclesToEvents<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function observedAttributes(custom_element: HTMLElement): Record<string, string>;
/**
* This is used primarly for server side rendering. To be sure that all async operations
* are finished before the page is sent to the client.

View File

@ -35,7 +35,6 @@ var DDE = (() => {
elementAttribute: () => elementAttribute,
isSignal: () => isSignal,
lifecyclesToEvents: () => lifecyclesToEvents,
observedAttributes: () => observedAttributes2,
on: () => on,
queue: () => queue,
registerReactivity: () => registerReactivity,
@ -78,8 +77,8 @@ var DDE = (() => {
};
}
function observedAttributes(instance, observedAttribute2) {
const { observedAttributes: observedAttributes3 = [] } = instance.constructor;
return observedAttributes3.reduce(function(out, name) {
const { observedAttributes: observedAttributes2 = [] } = instance.constructor;
return observedAttributes2.reduce(function(out, name) {
out[kebabToCamel(name)] = observedAttribute2(instance, name);
return out;
}, {});
@ -591,7 +590,7 @@ var DDE = (() => {
}
// src/customElement.js
function customElementRender(target, render, props = observedAttributes2) {
function customElementRender(target, render, props = {}) {
const custom_element = target.host || target;
scope.push({
scope: custom_element,
@ -632,9 +631,6 @@ var DDE = (() => {
obj[method] = new Proxy(obj[method] || (() => {
}), { apply });
}
function observedAttributes2(instance) {
return observedAttributes(instance, (i, n) => i.getAttribute(n));
}
// src/events.js
function dispatchEvent(name, options, host) {
@ -688,26 +684,6 @@ var DDE = (() => {
host(on.disconnected(() => a.abort()));
return a.signal;
};
var els_attribute_store = /* @__PURE__ */ new WeakSet();
on.attributeChanged = function(listener, options) {
if (typeof options !== "object")
options = {};
return function registerElement(element) {
element.addEventListener(eva, listener, options);
if (element[keyLTE] || els_attribute_store.has(element))
return element;
if (!enviroment.M) return element;
const observer = new enviroment.M(function(mutations) {
for (const { attributeName, target } of mutations)
target.dispatchEvent(
new CustomEvent(eva, { detail: [attributeName, target.getAttribute(attributeName)] })
);
});
const c = onAbort(options.signal, () => observer.disconnect());
if (c) observer.observe(element, { attributes: true });
return element;
};
};
// src/signals-lib/helpers.js
var mark = "__dde_signal";
@ -892,7 +868,7 @@ var DDE = (() => {
signal.observedAttributes = function(element) {
const store = element[key_attributes] = {};
const attrs = observedAttributes(element, observedAttribute(store));
on.attributeChanged(function attributeChangeToSignal({ detail }) {
on(eva, function attributeChangeToSignal({ detail }) {
/*! This maps attributes to signals (`S.observedAttributes`).
Investigate `__dde_attributes` key of the element. */
const [name, value] = detail;

View File

@ -214,7 +214,6 @@ export const scope: {
export function customElementRender<EL extends HTMLElement, P extends any = Record<string, string | Signal<string, {}>>>(target: ShadowRoot | EL, render: (props: P) => SupportedElement | DocumentFragment, props?: P | ((el: EL) => P)): EL;
export function customElementWithDDE<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function lifecyclesToEvents<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function observedAttributes(custom_element: HTMLElement): Record<string, string>;
/**
* This is used primarly for server side rendering. To be sure that all async operations
* are finished before the page is sent to the client.

File diff suppressed because one or more lines are too long

1
dist/iife.d.ts vendored
View File

@ -213,7 +213,6 @@ export const scope: {
export function customElementRender<EL extends HTMLElement, P extends any = Record<string, string | Signal<string, {}>>>(target: ShadowRoot | EL, render: (props: P) => SupportedElement | DocumentFragment, props?: P | ((el: EL) => P)): EL;
export function customElementWithDDE<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function lifecyclesToEvents<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function observedAttributes(custom_element: HTMLElement): Record<string, string>;
/**
* This is used primarly for server side rendering. To be sure that all async operations
* are finished before the page is sent to the client.

36
dist/iife.js vendored
View File

@ -33,7 +33,6 @@ var DDE = (() => {
elNS: () => createElementNS,
elementAttribute: () => elementAttribute,
lifecyclesToEvents: () => lifecyclesToEvents,
observedAttributes: () => observedAttributes2,
on: () => on,
queue: () => queue,
registerReactivity: () => registerReactivity,
@ -64,16 +63,6 @@ var DDE = (() => {
signal.removeEventListener("abort", listener);
};
}
function observedAttributes(instance, observedAttribute) {
const { observedAttributes: observedAttributes3 = [] } = instance.constructor;
return observedAttributes3.reduce(function(out, name) {
out[kebabToCamel(name)] = observedAttribute(instance, name);
return out;
}, {});
}
function kebabToCamel(name) {
return name.replace(/-./g, (x) => x[1].toUpperCase());
}
// src/signals-lib/common.js
var signals_global = {
@ -565,7 +554,7 @@ var DDE = (() => {
}
// src/customElement.js
function customElementRender(target, render, props = observedAttributes2) {
function customElementRender(target, render, props = {}) {
const custom_element = target.host || target;
scope.push({
scope: custom_element,
@ -606,9 +595,6 @@ var DDE = (() => {
obj[method] = new Proxy(obj[method] || (() => {
}), { apply });
}
function observedAttributes2(instance) {
return observedAttributes(instance, (i, n) => i.getAttribute(n));
}
// src/events.js
function dispatchEvent(name, options, host) {
@ -662,25 +648,5 @@ var DDE = (() => {
host(on.disconnected(() => a.abort()));
return a.signal;
};
var els_attribute_store = /* @__PURE__ */ new WeakSet();
on.attributeChanged = function(listener, options) {
if (typeof options !== "object")
options = {};
return function registerElement(element) {
element.addEventListener(eva, listener, options);
if (element[keyLTE] || els_attribute_store.has(element))
return element;
if (!enviroment.M) return element;
const observer = new enviroment.M(function(mutations) {
for (const { attributeName, target } of mutations)
target.dispatchEvent(
new CustomEvent(eva, { detail: [attributeName, target.getAttribute(attributeName)] })
);
});
const c = onAbort(options.signal, () => observer.disconnect());
if (c) observer.observe(element, { attributes: true });
return element;
};
};
return __toCommonJS(index_exports);
})();

1
dist/iife.min.d.ts vendored
View File

@ -213,7 +213,6 @@ export const scope: {
export function customElementRender<EL extends HTMLElement, P extends any = Record<string, string | Signal<string, {}>>>(target: ShadowRoot | EL, render: (props: P) => SupportedElement | DocumentFragment, props?: P | ((el: EL) => P)): EL;
export function customElementWithDDE<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function lifecyclesToEvents<EL extends (new () => HTMLElement)>(custom_element: EL): EL;
export function observedAttributes(custom_element: HTMLElement): Record<string, string>;
/**
* This is used primarly for server side rendering. To be sure that all async operations
* are finished before the page is sent to the client.

2
dist/iife.min.js vendored

File diff suppressed because one or more lines are too long