From b7a153f88c629e2df513755798dc8222450aebc8 Mon Sep 17 00:00:00 2001 From: lukasmoellerch Date: Sun, 28 Jun 2020 13:38:40 +0200 Subject: [PATCH] Pass undefined instead of an empty string --- src/compiler/preprocess/index.ts | 4 ++-- test/preprocess/samples/script-self-closing/_config.js | 2 +- test/preprocess/samples/style-self-closing/_config.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/preprocess/index.ts b/src/compiler/preprocess/index.ts index d90d4814d787..a9ba331e6d28 100644 --- a/src/compiler/preprocess/index.ts +++ b/src/compiler/preprocess/index.ts @@ -95,7 +95,7 @@ export default async function preprocess( source = await replace_async( source, /|([^]*?)<\/script>|\/>)/gi, - async (match, attributes = '', content = '') => { + async (match, attributes = '', content) => { if (!attributes && !content) { return match; } @@ -115,7 +115,7 @@ export default async function preprocess( source = await replace_async( source, /|([^]*?)<\/style>|\/>)/gi, - async (match, attributes = '', content = '') => { + async (match, attributes = '', content) => { if (!attributes && !content) { return match; } diff --git a/test/preprocess/samples/script-self-closing/_config.js b/test/preprocess/samples/script-self-closing/_config.js index 4baab9730e12..15d43ac43202 100644 --- a/test/preprocess/samples/script-self-closing/_config.js +++ b/test/preprocess/samples/script-self-closing/_config.js @@ -3,7 +3,7 @@ import * as assert from "assert"; export default { preprocess: { script: ({ content, attributes }) => { - assert.equal(content, ""); + assert.equal(content, undefined); return { code: `console.log("${attributes["the-answer"]}");` }; diff --git a/test/preprocess/samples/style-self-closing/_config.js b/test/preprocess/samples/style-self-closing/_config.js index 0a05cd3d641e..3c3ffabc2655 100644 --- a/test/preprocess/samples/style-self-closing/_config.js +++ b/test/preprocess/samples/style-self-closing/_config.js @@ -3,7 +3,7 @@ import * as assert from "assert"; export default { preprocess: { style: ({ content, attributes: { color } }) => { - assert.equal(content, ""); + assert.equal(content, undefined); return { code: `div { color: ${color}; }` };