Closed krisdages closed 5 years ago
I'm quite confused what codesandbox does to the bundle that makes <let/>
not working. I tried to reproduce it using normal bundle here https://codesandbox.io/s/2p444yxrwj and it's working fine.
Can you have a check?
Interesting. Let is working as expected with that bundle (and I don't see the bug that I see in my project with the dependencies installed individually). I'll have to compare and see what's different.
So I figured out the source of the problem. I have an HTML minifier on my source files that removes the line breaks between the elements. The bug appears when there are no newlines/indentation in the template.
https://codesandbox.io/s/qv6p79wjxq
Click "Toggle Items", and "Item 3 A" on the left side will not be removed. Toggle a few times, and "Item 3 A" will begin being repeated mutliple times.
Had to turn off "prettify on save" in code sandbox btw :P But thanks for giving me a starting point with the scripts fully functional!
And I suppose this issue might be posted under the wrong repo, sorry :)
@krisdages Thanks for the details. This is an issue with repeat
unable to stabilize the range where it starts and ends, when used on template and nested template controller, not really an issue with <let/>
. As long as there is a space introduced anywhere between template and its first repeat, it works fine.
I should say generally it's an issue with nested template controllers with containerless / containerless-like behaviors
Ah, that's great. Even with the minifier taking out the whitespace, adding a comment before made it start working. Not sure if that is what you meant by "there is a introduced", was there something there you typed that github pulled out?
Working:
<template repeat.for="item of items">
<!---->
<let letter-matches.bind="item.letter === letter"></let>
I meant as long as there is a space introduced ...
. I edited that. And that's a nice work around.
Closing since we've got a solution here.
I'm submitting a bug report
Please tell us about your environment:
Operating System: Linux (Ubuntu Bionic)
Node Version: Electron 3.0
NPM Version: 6.4.1
JSPM OR Webpack AND Version JSPM 0.17.0-beta.48
Browser: Electron 3.0 (Chrome 66)
Language: Typescript 3.0
Current behavior: Simplified case:
There is a bug when items is set to a different array (in this case, a filtered one). Some of the items that are not present in the filtered array are not removed from the DOM.
This happens only with both let and if/else.
Expected/desired behavior: The DOM items should match the model items, as with the following cases.
https://codesandbox.io/s/738l45xyq6
(For some reason, the let bindings are not working in the sandbox even though the versions appear to be the latest, and the bundle on gistrun is not updated to the latest versions either. But it's easy to reproduce in a skeleton with let bindings supported).