Skip to content
This repository was archived by the owner on Sep 26, 2022. It is now read-only.

Commit 503db1d

Browse files
authored
fix: sliderUi library imported incorrectly for SPA and SSR #171 (#194)
* Move noUiSlider library import into onMount * Fix slider might be undefined on after update
1 parent 0c8368b commit 503db1d

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

packages/svelte-materialify/src/components/Slider/Slider.svelte

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
<script context="module">
2-
import noUiSlider from './nouislider.min';
3-
</script>
4-
51
<script>
62
import Input from '../Input';
73
import { onMount, afterUpdate, createEventDispatcher } from 'svelte';
@@ -51,7 +47,9 @@
5147
return thumb;
5248
}
5349
54-
onMount(() => {
50+
onMount(async () => {
51+
const { default: noUiSlider } = await import('./nouislider.min');
52+
5553
noUiSlider.cssClasses.tooltip = `tooltip ${thumbClass}`;
5654
noUiSlider.create(sliderElement, {
5755
cssPrefix: 's-slider__',
@@ -98,7 +96,7 @@
9896
}
9997
10098
afterUpdate(() => {
101-
if (value !== localValue) slider.set(value, false);
99+
if (slider && value !== localValue) slider.set(value, false);
102100
});
103101
</script>
104102

0 commit comments

Comments
 (0)