-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
Change to a bound repeat input element is applied to the VM a second time after the element has been deleted. #527
Comments
This is not a question, it's a bug report!!! |
@geleto I'm closing this because it's a duplicate of #444 Please refer to the discussion in that issue for more information. The short answer is this doesn't do anything in pure javascript: for (let item of items) {
item = 'something else'; // note: this does not change the contents of the array
} Similarly, this doesn't do anything in a <input repeat.for="item of items"
value.bind="item"> // note : this does not change the contents of the array |
Please read my description and see the linked gist, this has nothing to do with #444. <template>
<div repeat.for="i of messages.length">
<input type="text" value.bind="$parent.messages[i]" input.delegate="onMessageChanged()">
</div>
</template> |
I have created a simpler test case in this gist: When any value is changed, the first element in the array is deleted from the 'input.delegate' event handler. Notice how the changed value is applied to two different inputs. |
I'm submitting a bug report
1.0.7
Chrome
I have an array of strings bound to a repeat with input text elements. I want to delete an element when the user deletes it's content. Because there is no way to observe changes in array values, I handle the
input
event, check for empty values and remove the corresponding elements from the array.The bug is - the bound value (which was just changed to empty text by the user) is applied to the VM twice, the first time after the input content has been deleted by the user, and once again - after the element is deleted from the array in the event handler, which blanks the next element which has taken it's place. I tried to avoid this bug by using queueTask to postpone deleting the array element, to no avail.
See this gist, to reproduce the bug, just delete the text in one of the first 3 inputs:
https://gist.run/?id=e49828b236d979450ce54f0006d0fa0a
The text was updated successfully, but these errors were encountered: