diff --git a/src/preprocess/index.ts b/src/preprocess/index.ts index 8538a65acc..2666e5fb7f 100644 --- a/src/preprocess/index.ts +++ b/src/preprocess/index.ts @@ -95,8 +95,8 @@ export default async function preprocess( for (const fn of script) { source = await replace_async( source, - /([^]*?)<\/script>/gi, - async (match, attributes, content) => { + /([^]*?)<\/script>/gi, + async (match, attributes = '', content) => { const processed: Processed = await fn({ content, attributes: parse_attributes(attributes), @@ -111,8 +111,8 @@ export default async function preprocess( for (const fn of style) { source = await replace_async( source, - /([^]*?)<\/style>/gi, - async (match, attributes, content) => { + /([^]*?)<\/style>/gi, + async (match, attributes = '', content) => { const processed: Processed = await fn({ content, attributes: parse_attributes(attributes), diff --git a/test/preprocess/samples/partial-names/_config.js b/test/preprocess/samples/partial-names/_config.js new file mode 100644 index 0000000000..dadf801581 --- /dev/null +++ b/test/preprocess/samples/partial-names/_config.js @@ -0,0 +1,6 @@ +export default { + preprocess: { + script: () => ({ code: '' }), + style: () => ({ code: '' }) + } +}; diff --git a/test/preprocess/samples/partial-names/input.svelte b/test/preprocess/samples/partial-names/input.svelte new file mode 100644 index 0000000000..6875a491a0 --- /dev/null +++ b/test/preprocess/samples/partial-names/input.svelte @@ -0,0 +1,12 @@ + + foo + + + + foo + + diff --git a/test/preprocess/samples/partial-names/output.svelte b/test/preprocess/samples/partial-names/output.svelte new file mode 100644 index 0000000000..34c789a826 --- /dev/null +++ b/test/preprocess/samples/partial-names/output.svelte @@ -0,0 +1,8 @@ + + foo + + + + foo + +