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 @@ +
+ + + + +
diff --git a/test/runtime/samples/slot-names/_config.js b/test/runtime/samples/slot-names/_config.js new file mode 100644 index 0000000000..c94d09edef --- /dev/null +++ b/test/runtime/samples/slot-names/_config.js @@ -0,0 +1,10 @@ +export default { + html: ` +
+

Header 1

+

Header 2

+

Header 3

+

Header 4

+
+ ` +}; diff --git a/test/runtime/samples/slot-names/main.svelte b/test/runtime/samples/slot-names/main.svelte new file mode 100644 index 0000000000..3538bc49e3 --- /dev/null +++ b/test/runtime/samples/slot-names/main.svelte @@ -0,0 +1,10 @@ + + + +

Header 1

+

Header 2

+

Header 3

+

Header 4

+