svelte-native icon indicating copy to clipboard operation
svelte-native copied to clipboard

Two-way Data Binding is not Consistent with Svelte implementation

Open TheBeachMaster opened this issue 3 years ago • 2 comments
trafficstars

Environment

  • Nativescript v8.2.3
  • Node v17.9.0

Background

Reading this piece in Svelte Docs, what's important here is this piece

If you're using bind: directives together with on: directives, the order that they're defined in affects the value of the bound variable when the event handler is called.

Expected Behavior

The expected behavior for 2 way data binding can be seen on this repl

What's happening

This works in reverse with Svelte-Native

Example

Say you have a couple of sliders like so

    <slider
      minValue="0"
      maxValue="255"
      on:valueChange={onValueChangedGreen}
      bind:value={green}
    />
    <slider
      minValue="0"
      maxValue="255"
      bind:value={black}
      on:valueChange={onValueChangedBlack}
    />

The "green" slider will behave as expected and not the "black" slider - expected here means that immediately you slide the slider, the value increments from 0 and not "undefined"

Notice the difference between the order of the directives.

Issue

Is this a bug or expected behavior?

TheBeachMaster avatar Jun 19 '22 17:06 TheBeachMaster

This seems to be a problem possibly caused by https://github.com/halfnelson/svelte-native-preprocessor/blob/master/src/index.ts @farfromrefug I think that package needs improvements.

CatchABus avatar Oct 18 '23 19:10 CatchABus

@CatchABus I see. Never use thé preprocessor. Bût I LL try to fix it. Not durr I can publish that package though

farfromrefug avatar Oct 18 '23 21:10 farfromrefug