pstanoev / simple-svelte-autocomplete

Simple Autocomplete / typeahead component for Svelte
http://simple-svelte-autocomplete.surge.sh/
MIT License
464 stars 78 forks source link

Svelte 4 and A11y warnings #206

Open rallets opened 1 year ago

rallets commented 1 year ago

Hi, using Svelte 4 the build emits some warnings due to new A11y roles introduced. node_modules/simple-svelte-autocomplete/src/SimpleAutocomplete.svelte

(!) Plugin svelte: A11y: with click, keypress handlers must have an ARIA role 1149: <span 1186: <span

(!) Plugin svelte: A11y:

with dragstart, dragover, dragleave, drop handlers must have an ARIA role 1136: <div

(!) Plugin svelte: A11y:

with click, keypress handlers must have an ARIA role 1203: <div 1243: <div

rallets commented 2 weeks ago

I forgot to mention that at the time I found a way to silent these warnings: in the rollup configuration file:

import path from 'path';
[...]
plugins: [
    svelte({
        // other stuff

        // Warnings are normally passed straight to Rollup. You can optionally handle them here, for example to squelch warnings with a particular code
        onwarn: (warning, handler) => {
            // do not emit warnings for 3rd-party package `simple-svelte-autocomplete`
            // looking to a file that ends with /SimpleAutocomplete.svelte (using unix & windows path separator)
            if (warning.filename?.endsWith(`${path.sep}SimpleAutocomplete.svelte`)) {
                return;
            }

            // let Rollup handle all other warnings normally
            handler && handler(warning);
        },
    })
],

PS. if you are using Vite the separator it looks like could be hardcoded to *nix "/"