-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: webc:for
does not work with any Iterable
#179
Comments
(Thinking on this a bit more this morning) I’m not technical enough to understand the nuances of an AST, so maybe there is a reason that the line of code mentioned above ( (…aaand this is where my ignorance of how of parsers and ASTs work may show…) Wouldn’t it be better to just use the Iterator Protocol on whatever is being looped over? That way, users of WebC can expect iteration on their data to work just as it does anywhere else. (I can see this is also connected with the Virtual Machine evaluating the code inline, but I don’t fully understand how.) |
(How could I forget?! 🤭) The WebC documentation says:
|
Issue 179: > bug: “`loopContent.map is not a function (via TypeError)`” 11ty#179
Started a test case for this bug in #180. |
(Renamed this issue from:
To:
|
loopContent.map is not a function (via TypeError)
”webc:for
does not work with any Iterable
I’m trying to loop over some data in a WebC component. After struggling on and off for a few weeks, I remembered that I could set breakpoints in VSCode and use the debugger to hone in on the problem.
I discovered this line of the ast, where
loopContent
is a JavaScriptMap
object, but (inside of asyncgetLoopContent()
), the AST call toLooping.parse()
has reported its type asArray
.Since the AST is expecting an array, it when it tries to call
.map()
onloopContent
, it throws.(I tried using both
webc:for="(key, val) of this.$data
andwebc:for="(key, val) of this.$data.entries()
. The same error happens, because neither are actually anArray
object, butMap
andMapIterator
.)The text was updated successfully, but these errors were encountered: