framework: @transient does not appear to work for custom elements

I’m submitting a bug report

  • Library Version: 1.0.0

Please tell us about your environment:

  • Operating System: OSX 10.11.2
  • Node Version: 0.4.0
  • NPM Version: 3.8.9
  • JSPM OR Webpack AND Version JSPM 0.16.38
  • Browser: all
  • Language: ESNext

Current behavior: @transient on a custom element doesn’t cause it to be created/destroyed using if.bind

Expected/desired behavior: @transient decorator should cause the custom element to be completely destroyed/recreated https://gist.run/?id=b4c451b5a1940afa3fc321a434377e2e

  • What is the motivation / use case for changing the behavior? theif.bind example is the simplest I could think of to test the expected behavior of @transient as shown here in the Aurelia Hub
import {transient, inject} from 'aurelia-framework';
import {HttpClient} from 'aurelia-fetch-client';

@transient()
@inject(HttpClient)
export class CustomerDetail {
  constructor(http) {
    this.http = http;
  }
}

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 24 (11 by maintainers)

Most upvoted comments

+1

It’s very counterintuitive that custom element removed and re-added from the view with if.bind does not resets its state. Only show.bind should behave like this.

We can’t do this at the application level because if you are using a 3rd party component that internally uses an if binding, then changing it at the app level would effect the internal implementation of the component, possibly causing it to malfunction. We can do it on a per-case basis though. It can be done using some new templating features. So you could have:

Normal Behavior

if.bind="someValue"

No Cache

if="value.bind: someValue; cache: none"

@EisenbergEffect Maybe something like this should be configurable at both application level in FrameworkConfiguration and per If via bindable property ?