Skip to content

Commit

Permalink
Pass undefined instead of an empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmoellerch committed Jun 28, 2020
1 parent 0b07be4 commit b7a153f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/compiler/preprocess/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default async function preprocess(
source = await replace_async(
source,
/<!--[^]*?-->|<script(\s[^]*?)?(?:>([^]*?)<\/script>|\/>)/gi,
async (match, attributes = '', content = '') => {
async (match, attributes = '', content) => {
if (!attributes && !content) {
return match;
}
Expand All @@ -115,7 +115,7 @@ export default async function preprocess(
source = await replace_async(
source,
/<!--[^]*?-->|<style(\s[^]*?)?(?:>([^]*?)<\/style>|\/>)/gi,
async (match, attributes = '', content = '') => {
async (match, attributes = '', content) => {
if (!attributes && !content) {
return match;
}
Expand Down
2 changes: 1 addition & 1 deletion test/preprocess/samples/script-self-closing/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}");`
};
Expand Down
2 changes: 1 addition & 1 deletion test/preprocess/samples/style-self-closing/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}; }`
};
Expand Down

0 comments on commit b7a153f

Please sign in to comment.