Ticket #2531689 (closed enhancement)
Reporter Evan Culver |
Opened: 01/23/12 Last modified: 05/10/12 Status: closed Type: enhancement Resolution: fixed |
Owner Ryan Grove |
Target Release: 3.5.0 Priority: P3 (normal) |
|---|---|---|---|
| Summary: | Y.View should not remove container when destroyed | ||
| Description: | Currently, Y.View removes its container by default when calling `destroy`. This is a little counter-intuitive considering it assumes that the view would have created the node in the first place. For For me, my use case is a dumb view, whose container has a non-trivial subtree that I want to bind events within when the view is instantiated. If I ever destroy this view, I can never rebind without This really becomes a pain when writing tests and calling `destroy` via `tearDown`. As discussed in IRC, it seems that the destroy should behave like Y.Model's destroy. Something like destroy({delete: true}) which would optionally remove the container if told to explicitly. |
||
| Type: | enhancement | Observed in Version: | development master |
| Component: | App Framework | Severity: | S3 (normal) |
| Assigned To: | Ryan Grove | Target Release: | 3.5.0 |
| Location: | Priority: | P3 (normal) | |
| Tags: | view, destroy, container | Relates To: | |
| Browsers: | All | ||
| URL: | https://gist.github.com/1664905 | ||
| Test Information: | |||
Change History
|
Posted: 01/23/12
|
|
Posted: 01/23/12
|
|
Posted: 01/23/12
This idea sounds good. But I do not like `{delete: true}` because `delete` is a reserved word and you have to remember to quote it, therefore it is highly error prone. I'd prefer `destroy({remove: true})` or `destroy(true)`. |
|
Posted: 01/23/12
It was mentioned in IRC that `destroy(true)` could be confusing since it would behave differently from Y.Node's `destroy(true)` (it's also an unlabeled boolean arg, of which I'm not a fan). I proposed `{delete: true}` because that would provide consistency with Model, but I'd also be okay with `{remove: true}`. |
|
Posted: 01/24/12
I too do not like unlabeled boolean args, and using an object makes it easier to add features while maintaining back-compat, so let's stick with that. I just feel strongly that `{delete: true}` shouldn't be used, because it is too easy to forget to actually write: `{'delete': true}`, and not doing so causes an error in IE. |
|
Posted: 01/24/12
Fair enough. I'll go with `{remove: true}`. |
|
Posted: 02/7/12
Implemented in commit da3fe82a. |
|
Posted: 05/10/12
checkedin -> closed |
|
Posted: 05/10/12
checkedin -> closed |
Unless someone objects (Eric?) I'll plan to have View not remove containers by default, and remove them if {delete: true} is passed to destroy().