From 532e40d61d9ee4595cc6aaa2bd4346eccba44457 Mon Sep 17 00:00:00 2001 From: Cosmin Popovici Date: Thu, 29 Feb 2024 19:59:36 +0200 Subject: [PATCH] revert: render original reference when a variable is undefined caused issues with how variables inside components were rendered, since as far as expressions are concerned, they are undefined - they ended up output as-is too... needs more testing to get right --- src/generators/posthtml/index.js | 1 - test/test-tostring.js | 4 ++-- types/expressions.d.ts | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/generators/posthtml/index.js b/src/generators/posthtml/index.js index 4ce4b489..62e2c2a8 100644 --- a/src/generators/posthtml/index.js +++ b/src/generators/posthtml/index.js @@ -16,7 +16,6 @@ module.exports = async (html, config) => { const expressionsOptions = merge( { loopTags: ['each', 'for'], - missingLocal: '{local}', strictMode: false }, get(componentsUserOptions, 'expressions', {}), diff --git a/test/test-tostring.js b/test/test-tostring.js index cb529096..7fa7ef57 100644 --- a/test/test-tostring.js +++ b/test/test-tostring.js @@ -85,7 +85,7 @@ test('locals work when defined in all supported places', async t => { } }) - t.is(result, `1, 2, 3, {{ inline }}`) + t.is(result, `1, 2, 3, undefined`) }) test.serial('prevents overwriting page object', async t => { @@ -111,7 +111,7 @@ test.serial('prevents overwriting page object', async t => { } }) - t.is(result, `1, 2, 3, {{ inline }}`) + t.is(result, `1, 2, 3, undefined`) }) test('preserves css in marked style tags (tailwindcss)', async t => { diff --git a/types/expressions.d.ts b/types/expressions.d.ts index d0aa97fa..036f02c2 100644 --- a/types/expressions.d.ts +++ b/types/expressions.d.ts @@ -79,9 +79,9 @@ export default interface ExpressionsConfig { /** What to render when referencing a value that is not defined in `locals`. - By default the original expression reference will be output, i.e. `{{ foo }}`. + By default, the string 'undefined' will be output. - @default '{local}' + @default undefined @example