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
lookAheadForMatchingKeyedElementAndMoveItIfFoundI 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 toundefinedbecause:lookAheadForMatchingKeyedElementAndMoveItIfFoundfunction spouse to find an element in the end butwhileloop fails to return becausetmpNextElin the end becomes false and it returns nothing. SonextElbecomes undefined.Just for testing, i return back the
nextElat very end of the function like so:and
AppendandPrependworked normal.So i guess it might be a logic issue?
@HugoDF I won’t have much time today. Feel free to fix it.