diff --git a/components/src/maplibre/Geocoder/Geocoder.svelte b/components/src/maplibre/Geocoder/Geocoder.svelte index 40514a94..ae836242 100644 --- a/components/src/maplibre/Geocoder/Geocoder.svelte +++ b/components/src/maplibre/Geocoder/Geocoder.svelte @@ -1,9 +1,11 @@ diff --git a/mock-sveltekit/src/routes/450-repro/+page.svelte b/mock-sveltekit/src/routes/450-repro/+page.svelte new file mode 100644 index 00000000..cfcd981c --- /dev/null +++ b/mock-sveltekit/src/routes/450-repro/+page.svelte @@ -0,0 +1,11 @@ + + +{#if dev} + +{:else} + +{/if} diff --git a/mock-sveltekit/src/routes/450-repro/Component.svelte b/mock-sveltekit/src/routes/450-repro/Component.svelte new file mode 100644 index 00000000..e7224af1 --- /dev/null +++ b/mock-sveltekit/src/routes/450-repro/Component.svelte @@ -0,0 +1,75 @@ + + + + + +
+
+ {#if mapContext?.map} + + {/if} +
+
+ + + + + +

{status}

+
+
+
+ + diff --git a/mock-sveltekit/tests/maplibre.spec.ts b/mock-sveltekit/tests/maplibre.spec.ts index d8ebe111..c21893a3 100644 --- a/mock-sveltekit/tests/maplibre.spec.ts +++ b/mock-sveltekit/tests/maplibre.spec.ts @@ -17,3 +17,22 @@ test('VectorTileSource works in production builds (#348)', async ({ page }) => { expect(logs.filter((l) => l.type === 'error')).toStrictEqual([]); }); + +test('Geocoder works in a custom element context (#446)', async ({ page }) => { + let logs: ConsoleMsg[] = []; + page.on('console', (msg) => logs.push({ msg: msg.text(), type: msg.type() } as ConsoleMsg)); + + await page.goto('/450-repro'); + await page.getByText('loaded').waitFor({ state: 'attached', timeout: 3000 }); + + await expect(page.getByPlaceholder('placeholder goes here')).toBeVisible(); + expect(logs.filter((l) => l.type === 'error')).toStrictEqual([]); +}); + +test('Geocoder supports the id prop (#446)', async ({ page }) => { + await page.goto('/450-repro'); + await page.getByText('loaded').waitFor({ state: 'attached', timeout: 3000 }); + const inputEl = page.getByPlaceholder('placeholder goes here'); + await expect(inputEl).toBeVisible(); + await expect(inputEl).toHaveId('input-id'); +});