Skip to content

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

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

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

Conversation

@imorland
Copy link
Member

@imorland imorland commented Mar 6, 2026

Fixes #4383.

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:47
@imorland imorland added this to the 1.8.14 milestone Mar 6, 2026
@imorland imorland linked an issue Mar 6, 2026 that may be closed by this pull request
@imorland imorland merged commit 77e01f5 into 1.x Mar 6, 2026
409 checks passed
@imorland imorland deleted the im/fix-less-bool-keyword branch March 6, 2026 17:57
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