close
Skip to content

[2.x] fix(theme): return Less_Tree_Keyword for boolean custom Less functions#4406

Merged
imorland merged 1 commit into2.xfrom
im/fix-less-bool-keyword-2x
Mar 6, 2026
Merged

[2.x] fix(theme): return Less_Tree_Keyword for boolean custom Less functions#4406
imorland merged 1 commit into2.xfrom
im/fix-less-bool-keyword-2x

Conversation

@imorland
Copy link
Copy Markdown
Member

@imorland imorland commented Mar 6, 2026

Fixes #4383.

Same bug as the 1.x fix in #4405.

Problem

addCustomLessFunction wrapped boolean return values in Less_Tree_Quoted('', 'true'/'false'), producing a quoted string in Less. Less's built-in boolean keywords (true/false) are Less_Tree_Keyword, not quoted strings. This meant boolean-returning custom functions could not be used in mixin guards:

// This never matched — value was the string 'false', not the keyword false
.define-header(false) { ... }

Fix

Use Less_Tree_Keyword instead of Less_Tree_Quoted for boolean return values. CSS custom property output is unchanged (false renders as false in both cases); only mixin guard matching is fixed.

Test

Extended the existing theme_extender_can_add_custom_function test with a mixin guard that must match false — asserting that .dummy_func_test3{color:red} appears in the compiled CSS.

Boolean return values from `addCustomLessFunction` were wrapped in
`Less_Tree_Quoted`, producing a quoted string ('true'/'false') instead
of a Less keyword (true/false). Quoted strings do not match in mixin
guards, making it impossible to use boolean-returning functions with
`.mixin(false) {}` patterns.

Switch to `Less_Tree_Keyword` so booleans behave as proper Less keywords.
CSS custom property output is unchanged; only mixin guard matching is fixed.

Fixes #4383

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@imorland imorland requested a review from a team as a code owner March 6, 2026 17:51
@imorland imorland added this to the 2.0.0-beta.8 milestone Mar 6, 2026
@imorland imorland merged commit 10c1e1c into 2.x Mar 6, 2026
34 checks passed
@imorland imorland deleted the im/fix-less-bool-keyword-2x branch March 6, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

addCustomLessFunction seemly parse returned value improperly

1 participant