alpine: Regression in x-for
This error came after 9e91c4704638ee5c3472eb8a19d54fcd0b5caa59
I don’t have a codepen for this, but the component that fails has 3 nested x-for loops.
alpine.js:418 Uncaught TypeError: Cannot convert undefined or null to object
at alpine.js:418
at Proxy.forEach (<anonymous>)
at handleForDirective (alpine.js:404)
at alpine.js:1495
at Array.forEach (<anonymous>)
at Component.resolveBoundAttributes (alpine.js:1450)
at Component.updateElement (alpine.js:1426)
at alpine.js:1394
at alpine.js:1358
at walk (alpine.js:85)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (9 by maintainers)
Feel free to review ^
With such a deliberate function name as
lookAheadForMatchingKeyedElementAndMoveItIfFound
I would assume that the logical flaw is the handling of the (non) return value. That also matches the functional behaviour (it works, but it throws).i went through and collect some information that might help you to figure out faster.
nextEl = lookAheadForMatchingKeyedElementAndMoveItIfFound(nextEl, currentKey)
at this line it’s assigned toundefined
because:lookAheadForMatchingKeyedElementAndMoveItIfFound
function spouse to find an element in the end butwhile
loop fails to return becausetmpNextEl
in the end becomes false and it returns nothing. SonextEl
becomes undefined.Just for testing, i return back the
nextEl
at very end of the function like so:and
Append
andPrepend
worked normal.So i guess it might be a logic issue?
@HugoDF I won’t have much time today. Feel free to fix it.