SHA256
fix: edit and delete buttons now actually fire their handlers
The shared el() helper passed every attr through setAttribute(); for event handlers like onclick a function value gets stringified into an attribute the DOM compiles as an expression that is evaluated but never called - so Bearbeiten/Löschen (wired through el()) were silent no-ops, while addEventListener-wired buttons (Neuer Datensatz, Sperren) worked. el() now assigns on*-function attrs as properties (node[k] = v), preserving the real handler. Verified with a DOM-semantics shim: fixed path fires, legacy setAttribute path provably compiles but never calls. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
@@ -37,6 +37,12 @@ function el(tag, attrs = {}, children = []) {
|
||||
for (const [k, v] of Object.entries(attrs)) {
|
||||
if (k === "class") node.className = v;
|
||||
else if (k === "text") node.textContent = v;
|
||||
else if (k.startsWith("on") && typeof v === "function") {
|
||||
// Event handlers MUST be assigned as properties: setAttribute(k, fn)
|
||||
// stringifies the function ("... => ...") and never binds a listener,
|
||||
// which silently killed the Bearbeiten/Löschen buttons.
|
||||
node[k] = v;
|
||||
}
|
||||
else node.setAttribute(k, v);
|
||||
}
|
||||
for (const child of children) node.appendChild(child);
|
||||
|
||||
Reference in New Issue
Block a user