`get-unit` returns wrong value type (causing unintended behavior in certain cases).
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 17k
- Forks
- 3.4k
- Avg merge
- 7h 42m
- Merged PRs (30d)
- 26
Description
In Less 2.6.1 the genCSS method of Anonymous tree nodes does not take care to properly stringify its value when sent to output.add.
When source-maps are enabled, this results in an error SyntaxError: chunk.split is not a function because SourceMapOutput always expects its first chunk parameter to be a string on which it can call the split method.
From a cursory glance at the codebase, it seems Less 2.7.x still has this problem as well.
A minimal reproducing case:
.test { value : get-unit(10px); }
Proposed fix:
Anonymous.prototype.genCSS = function (context, output) {
var strValue = this.value != null ? String(this.value) : "";
output.add(strValue, this.currentFileInfo, this.index, this.mapLines);
};
(Sorry guys; I don't have time to set up a full pull request. I hope someone can take this and do the legwork.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate Anonymous.prototype.genCSS and the SourceMapOutput path mentioned in the issue. Reproduce the get-unit(10px) case with source maps enabled, then verify that the generated value is passed as a string and the chunk.split error no longer occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css, javascript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100