bigskysoftware / idiomorph

A DOM-merging algorithm
BSD 2-Clause "Simplified" License
631 stars 31 forks source link

TypeError: Cannot read properties of undefined (reading 'name') #41

Open cmer opened 4 months ago

cmer commented 4 months ago

I am running into an exception. Not sure what the root cause is. Here's the stack trace and a screenshot of where it crashes. Let me know what else you need to solve this!

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'name')
    at syncNodeFrom (idiomorph.esm.js:294:53)
    at morphOldNodeTo (idiomorph.esm.js:147:21)
    at morphNormalizedContent (idiomorph.esm.js:91:35)
    at Object.morph (idiomorph.esm.js:53:20)
    at event.detail.render [as renderElement] (application.js:24:15)
    at FrameRenderer.loadFrameElement (turbo.es2017-esm.js:1900:10)
    at turbo.es2017-esm.js:1889:12
    at Bardo.preservingPermanentElements (turbo.es2017-esm.js:1721:11)
    at FrameRenderer.preservingPermanentElements (turbo.es2017-esm.js:1814:17)
    at FrameRenderer.render (turbo.es2017-esm.js:1888:10)
syncNodeFrom @ idiomorph.esm.js:294
morphOldNodeTo @ idiomorph.esm.js:147
morphNormalizedContent @ idiomorph.esm.js:91
morph @ idiomorph.esm.js:53
event.detail.render @ application.js:24
loadFrameElement @ turbo.es2017-esm.js:1900
(anonymous) @ turbo.es2017-esm.js:1889
preservingPermanentElements @ turbo.es2017-esm.js:1721
preservingPermanentElements @ turbo.es2017-esm.js:1814
render @ turbo.es2017-esm.js:1888
await in render (async)
render @ turbo.es2017-esm.js:1888
await in render (async)
renderSnapshot @ turbo.es2017-esm.js:1529
render @ turbo.es2017-esm.js:1489
await in render (async)
loadFrameResponse_fn @ turbo.es2017-esm.js:6001
await in loadFrameResponse_fn (async)
loadResponse @ turbo.es2017-esm.js:5824
await in loadResponse (async)
formSubmissionSucceededWithResponse @ turbo.es2017-esm.js:5926
requestSucceededWithResponse @ turbo.es2017-esm.js:1169
receive @ turbo.es2017-esm.js:848
perform @ turbo.es2017-esm.js:825
await in perform (async)
start @ turbo.es2017-esm.js:1109
formSubmitted @ turbo.es2017-esm.js:5876
(anonymous) @ turbo.es2017-esm.js:1390

CleanShot 2024-02-27 at 16 38 40@2x

CleanShot 2024-02-27 at 16 42 15@2x

cmer commented 4 months ago

Adding another bogus attribute (eg foo="bar") to my turbo-frame solves the issue. It doesn't like the fact that there's only 1 attribute.

jameskerr commented 3 months ago

I'm running into this as well in the same way.

matchu commented 6 days ago

For my Turbo Frames, I'm working around this by:

Idiomorph.morph(currentElement, newElement.innerHTML, {
    morphStyle: "innerHTML",
});