Skip to content

Commit

Permalink
Trigger an event when adding a new node
Browse files Browse the repository at this point in the history
  • Loading branch information
coorasse committed Mar 5, 2024
1 parent f0beef3 commit 8388a21
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/core/drive/morph_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,18 @@ export class MorphRenderer extends PageRenderer {
}

#shouldAddElement = (node) => {
return !(node.id && node.hasAttribute("data-turbo-permanent") && document.getElementById(node.id))
if (node.id && node.hasAttribute("data-turbo-permanent") && document.getElementById(node.id)) {
return false;

Check failure on line 45 in src/core/drive/morph_renderer.js

View workflow job for this annotation

GitHub Actions / build

Extra semicolon
} else {
const event = dispatch("turbo:before-add-element", {
cancelable: true,
target: node,
detail: {
newElement: node
}
});

Check failure on line 53 in src/core/drive/morph_renderer.js

View workflow job for this annotation

GitHub Actions / build

Extra semicolon
return !event.defaultPrevented;

Check failure on line 54 in src/core/drive/morph_renderer.js

View workflow job for this annotation

GitHub Actions / build

Extra semicolon
}
}

#shouldMorphElement = (oldNode, newNode) => {
Expand Down

0 comments on commit 8388a21

Please sign in to comment.