From 9945f605223b5f6455edda9af9dd3a10d0817060 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Wed, 5 Jan 2022 16:17:30 -0500 Subject: [PATCH] Fix use of falsy values in theme config --- CHANGELOG.md | 5 ++++- src/util/pluginUtils.js | 2 +- tests/basic-usage.test.js | 28 ++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75a3edd505d9..a6f63760dc3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Nothing yet! +### Fixed + +- Allow use of falsy values in theme config ([#6917](https://github.com/tailwindlabs/tailwindcss/pull/6917)) + ## [3.0.11] - 2022-01-05 diff --git a/src/util/pluginUtils.js b/src/util/pluginUtils.js index cad52aee148a..f3214df467a0 100644 --- a/src/util/pluginUtils.js +++ b/src/util/pluginUtils.js @@ -185,7 +185,7 @@ export function coerceValue(types, modifier, options, tailwindConfig) { // Find first matching type for (let type of [].concat(types)) { let result = typeMap[type](modifier, options, { tailwindConfig }) - if (result) return [result, type] + if (result !== undefined) return [result, type] } return [] diff --git a/tests/basic-usage.test.js b/tests/basic-usage.test.js index 2058a92cbe6c..9d7db9bf7eaa 100644 --- a/tests/basic-usage.test.js +++ b/tests/basic-usage.test.js @@ -109,3 +109,31 @@ test('per-plugin colors with the same key can differ when using a custom colors `) }) }) + +it('fasly config values still work', () => { + let config = { + content: [{ raw: html`
` }], + theme: { + inset: { + 0: 0, + }, + }, + plugins: [], + corePlugins: { preflight: false }, + } + + let input = css` + @tailwind utilities; + ` + + return run(input, config).then((result) => { + expect(result.css).toMatchFormattedCss(css` + .inset-0 { + top: 0; + right: 0; + bottom: 0; + left: 0; + } + `) + }) +})