diff --git a/src/utils/names.ts b/src/utils/names.ts index 5047fe850c..1f0a9cc29e 100644 --- a/src/utils/names.ts +++ b/src/utils/names.ts @@ -111,5 +111,9 @@ export function quote_prop_if_necessary(name: string) { } export function sanitize(name: string) { - return name.replace(/[^a-zA-Z]+/g, '_').replace(/^_/, '').replace(/_$/, ''); -} \ No newline at end of file + return name + .replace(/[^a-zA-Z0-9_]+/g, '_') + .replace(/^_/, '') + .replace(/_$/, '') + .replace(/^[0-9]/, '_$&'); +} diff --git a/test/runtime/samples/slot-names/Nested.svelte b/test/runtime/samples/slot-names/Nested.svelte new file mode 100644 index 0000000000..70037db27e --- /dev/null +++ b/test/runtime/samples/slot-names/Nested.svelte @@ -0,0 +1,6 @@ +