bestguy / sveltestrap

Bootstrap 4 & 5 components for Svelte
https://sveltestrap.js.org
MIT License
1.3k stars 183 forks source link

Button text not updating #146

Open jamgold opened 4 years ago

jamgold commented 4 years ago

I am at a loss why this isn't working. The on:click clearly fires, but the button text does not update

<script>
  import {
    Button,
 } from 'sveltestrap';

let counter = 0;

function counterClick(){
 counter++
}
<script>

<Button on:click={counterClick}>{counter}</Button> counter={counter}

I recreated the Button.svelte component to look like this and it works. Why isn't the sveltestrap Button working

<button class="btn btn-info" on:click>
 <slot>
  <slot/>
 </slot>
</button>
johnr1 commented 4 years ago

It seems like you forgot to terminate the script tag. You are currently writing <script> instead of </script>.

jamgold commented 4 years ago

That was just a typo in my example. I just tried again and the Button component still does not update the text

johnr1 commented 4 years ago

Hmm. I tried copy pasting your example, fixing the script tag and running it and it seems to update it normally.

Do the rest of the components work as they should?

jamgold commented 4 years ago

That is indeed odd. I am using sveltestrap in a Meteor project, maybe that's where this behavior is introduced. If this works with "naked" svelte I believe the issue should be closed.

bestguy commented 4 years ago

Hi @jamgold , this works fine for me, however I wonder if there is any trouble from Meteor due to the way the code is here: https://github.com/bestguy/sveltestrap/blob/master/src/Button.svelte#L66

The {children} stuff is just to allow for easier unit testing, but wondering if there may be some incompatibility with Meteor?

jamgold commented 4 years ago

Hello @bestguy, this might need to be investigated by the guy who created the svelte integration with Meteor, I believe.