-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
fix(view-slot): add null check to removeAt #624
base: master
Are you sure you want to change the base?
Conversation
This will help only in the cases where the return value is not used. Else you will just get something like |
I address this in a comment here: #574 There's a fundamental issue with the async nature of Aurelia's templating/binding system and having one template controller directly inside another. For example, <template>
<table if.bind="array.length > 0">
<tr repeat.for="item of arrray">
<td>${item}</td>
<td><button click.delegate="removeItem(item)">Delete Item</button></td>
</tr>
</table>
</template> If the delete item button is clicked on the last item in the array, then the repeater needs to remove that In any case, if this requires a major version bump of the templating library, then so be it. This has been a pain point for developers pretty much since Aurelia existed, as evidenced by the large number of issues reported for it. |
src/view-slot.js
Outdated
@@ -209,7 +209,7 @@ export class ViewSlot { | |||
* @param skipAnimation Should the removal animation be skipped? | |||
* @return May return a promise if the view removal triggered an animation. | |||
*/ | |||
remove(view: View, returnToCache?: boolean, skipAnimation?: boolean): void | Promise<View> { | |||
remove(view: View, returnToCache?: boolean, skipAnimation?: boolean): void | Promise<View> | void{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this PR is getting merged, lets fix the return type of .remove
, it should be the same as of .removeAt
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Another approach, either make |
@EisenbergEffect or @jdanyow do you have any opinions on this? |
@AshleyGrant Do you have a gist that demonstrates the error? Will the exact code above produce the error? |
I can't seem to get a simple example to produce the error. It ends up needing a couple of |
I didn't think the sample above would cause the error. I need something where we can see this in isolation. |
Trying to cook that up. |
I have a similar issue. I have a div that repeats for some items. An element of the repeating div is a input[radio]. Its When a user selects the radio button and clicks the "Delete" button at the bottom of the page, I simply:
If I select the first element of the array (first of the repeater), and click "Delete", it calls -> KABOOM The array is correct and intact with the 1 element sliding into the 0 position... but the repeat fails to render. If I leave the view and come back to it, it redraws correctly. If I select ANY OTHER element and call the splice, I get this stack trace - the element appears to go away properly, but the console shows:
Just another data point. |
So far, all errors come from |
Per @jods4 this can be considered a breaking change.