-
Notifications
You must be signed in to change notification settings - Fork 145
Open
Description
I'm trying to leverage Morphdom while using Hotwire/Turbo → Similar to this documentation/example here: Turbo Handbook: Custom Rendering
This is to attempt to have a little more control over what gets replaced by Turbo.
Here's my code:
handleTurboFrameRender(event) {
const focusedElement = document.activeElement;
event.detail.render = (currentElement, newElement) => {
morphdom(currentElement, newElement, {
childrenOnly: false,
onBeforeElUpdated: (fromEl, toEl) => {
// Skip updating data-turbo-permanent items
if (fromEl.hasAttribute("data-turbo-permanent")) {
return false;
}
// Skip updating focused elements, so that we don't lose where we're typing
if (fromEl === focusedElement) {
return false;
}
return true;
},
});
};
}However, I'm getting this error - specifically after setting childrenOnly: false
Morphdom error: TypeError: Cannot read properties of undefined (reading 'name')
Coming from [this line of code, where Morphdom is striving to get the attribute name](
Line 48 in a87fc2b
| attrName = attr.name; |
In the instance above though, there's no attribute 🤔
Is there something, re: how Morphdom works, that I'm missing?
Thanks so much for your help!
Metadata
Metadata
Assignees
Labels
No labels