Hey everyone! I'm getting very unexpected behavior...
# javascript
m
Hey everyone! I'm getting very unexpected behavior from Kotlin/JS and I have no idea what is happening and why it is happening. Basically, I have code that gets me a
List
of `HTMLDivElement`s:
Copy code
val questionDivs = document.querySelectorAll("div[id^='question']").asList().map { it as HTMLDivElement }
Then, if I print it out to the console, by using
console.log(questionDivs)
, it prints out just fine. If I print out the size of this
List
, by using
console.log(questionDivs.size)
, it prints out the size of the
List
(in my case 11). But if I try to loop over the
List
by using either a foreach loop or by using the
.forEach { }
method, it isn't being run not even once. This is what gets printed out when doing `console.log(questionDivs)`: https://paste.pics/GR0JS
blob shrug 2
m
Yeah looks like the same issue.
How would I iterate over a
NodeList
then?