Skip to content

Commit

Permalink
Trigger added callback
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldrapper committed Feb 29, 2024
1 parent af23aae commit 0b4c876
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/morphlex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ class Morph {
else if (isTextArea(element) && isTextArea(ref)) {
this.#updateProperty(element, "value", ref.value);

// TODO: Do we need this? If so, how do we integrate with the callback?
const text = element.firstChild;
if (text && isText(text)) this.#updateProperty(text, "textContent", ref.value);
}
Expand Down Expand Up @@ -298,8 +297,11 @@ class Morph {
this.#insertBefore(parent, nextMatchByTagName, child);
this.#morphNode(nextMatchByTagName, ref);
} else {
// TODO: this is missing an added callback
this.#insertBefore(parent, ref.cloneNode(true), child);
const newNode = ref.cloneNode(true);
if (this.#options.beforeNodeAdded?.({ newNode, parentNode: parent }) ?? true) {
this.#insertBefore(parent, newNode, child);
this.#options.afterNodeAdded?.({ newNode });
}
}
}

Expand Down

0 comments on commit 0b4c876

Please sign in to comment.