binding icon indicating copy to clipboard operation
binding copied to clipboard

fix(name-binding): add extra props to update one time mode

Open bigopon opened this issue 6 years ago • 4 comments

Thanks to @edwrd01 on Discourse at https://discourse.aurelia.io/t/issue-using-ref-in-a-repeat-for-with-a-value-converter/2328/5 , we uncover an issue related the combination of ref binding, repeat and value-converter/binding-behavior. The issue is due to repeat custom attribute unable to update ref binding, in case of a mutation in source collection, piped through value converter / binding behavior. i.e:

  <div repeat.for="item of items | vc & bb">

As it uses this https://github.com/aurelia/templating-resources/blob/0896552d553af0d69399b9b227317a26bdc14005/src/repeat-utilities.js#L109-L115 under the hood to update the bindings that do not employ observation, NameBinder is one of those binding types. There are two ways to fix it:

  1. add method updateOneTimeBindings to reassign target
  2. add binding mode oneTime, and add method call to reassign target

I went with (2) since it seems to align better with other bindings, also the location of this class (binding module).

cc @EisenbergEffect @fkleuver

bigopon avatar Mar 02 '19 00:03 bigopon

This works for me. Let's make sure @fkleuver has a look and also considers this for vNext so we don't get a regression there after this is addressed in vCurrent.

EisenbergEffect avatar Mar 02 '19 00:03 EisenbergEffect

This makes good sense to me. This would translate to implementing handleChange in ref.ts.

Just a friendly reminder, you could use this repo for e2e / integration tests: https://github.com/aurelia/e2e-tests If you want to integration test this with real repeater / aurelia app, just add some tests there and make another push here, then CircleCI will run those tests against the binding version of this PR (and the npm@latest of all the other repos)

fkleuver avatar Mar 05 '19 06:03 fkleuver

@bigopon do we have a matching issue for this in vNext so I/we don't forget?

fkleuver avatar Apr 09 '19 23:04 fkleuver

Oh, we don't. Will add

bigopon avatar Aug 31 '19 16:08 bigopon