Skip to content

fix: pre-existing bug fixes in tree nodes#4414

Merged
matthew-dean merged 5 commits intoless:masterfrom
matthew-dean:fix/custom-prop-deprecation-warnings
Mar 10, 2026
Merged

fix: pre-existing bug fixes in tree nodes#4414
matthew-dean merged 5 commits intoless:masterfrom
matthew-dean:fix/custom-prop-deprecation-warnings

Conversation

@matthew-dean
Copy link
Copy Markdown
Member

Summary

  • Alpha 0 bug: #0000 and #00000000 parsed alpha as 0, treated as falsy by ||, falling back to 1 (opaque). Fixed with typeof check.
  • Selector this binding: getElements() callback used plain function() accessing this._fileInfo and this.parse.imports, but this is undefined in strict mode (ES modules). Captured into locals.
  • forEach lint: rules.forEach(rule => rule.merge = false) implicitly returned assignment value. Wrapped in block.
  • Mixin call error flattening: MixinCall.eval() catch block only copied message/stack, dropping type, extract, and other LessError fields. Now uses spread to preserve all error context.
  • functionRegistry guard: Container.eval() and Media.eval() called .inherit() unconditionally on functionRegistry. Added guard to match mixin-definition.js pattern.
  • AtRule parenting: Constructor called setParent() on orphaned local selectors variable (dead code). Fixed to parent this.declarations and this.rules instead.

Test plan

  • Alpha 0: added #0000 and #00000000 test cases to alpha.less/alpha.css
  • Mixin call error: updated detached-ruleset-5.txt expectation from SyntaxError to NameError
  • All 139 existing tests pass
  • Browser tests pass

#0000 and #00000000 parsed alpha as 0 which was treated as falsy by
the || operator, causing it to fall back to 1 (opaque). Use typeof
check instead so alpha 0 is preserved.
- Capture `this._fileInfo` and `this.parse.imports` into locals before
  the plain function callback in Selector.getElements(), where `this`
  is undefined in strict mode (ES modules)
- Use explicit block in forEach to avoid implicit return of assignment
The catch block in MixinCall.eval() only copied message and stack,
dropping type, extract, callLine, and other LessError fields. This
caused all mixin call errors to be reported as SyntaxError regardless
of their actual type (e.g. NameError). Use spread to preserve all
fields while still overriding index/filename to the call site.
- Container and Media eval() now guard functionRegistry before calling
  .inherit(), matching mixin-definition.js defensive pattern
- AtRule constructor: remove dead setParent(selectors) on orphaned local,
  parent this.declarations and this.rules with null checks
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 10, 2026
@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Mar 10, 2026
@matthew-dean matthew-dean merged commit e6a8efb into less:master Mar 10, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant