Skip to content

Commit

Permalink
Fixes #3405 (#3426)
Browse files Browse the repository at this point in the history
* Fixes to Gruntfile
* Fixes #3405
* Added #3406 example
  • Loading branch information
matthew-dean authored Aug 25, 2019
1 parent 66a839d commit 3f8a6ae
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 21 deletions.
24 changes: 17 additions & 7 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,7 @@ module.exports = function(grunt) {
}
},
build: {
command: [
scriptRuntime + " build/rollup.js --dist"
].join(" && ")
command: scriptRuntime + " build/rollup.js --dist"
},
testbuild: {
command: [
Expand All @@ -211,6 +209,12 @@ module.exports = function(grunt) {
scriptRuntime + " build/rollup.js --browser --out=./test/browser/less.min.js"
].join(" && ")
},
testcjs: {
command: scriptRuntime + " build/rollup.js --node --out=./tmp/less.cjs.js"
},
testbrowser: {
command: scriptRuntime + " build/rollup.js --browser --out=./test/browser/less.min.js"
},
test: {
command: "node test/index.js"
},
Expand Down Expand Up @@ -495,7 +499,7 @@ module.exports = function(grunt) {

// Create the browser version of less.js
grunt.registerTask("browsertest-lessjs", [
"shell:testbuild"
"shell:testbrowser"
]);

// Run all browser tests
Expand Down Expand Up @@ -567,8 +571,11 @@ module.exports = function(grunt) {
// Run shell plugin test
grunt.registerTask("shell-plugin", ["shell:plugin"]);

// Run all tests except browsertest
grunt.registerTask("quicktest", testTasks.slice(0, -1));
// Quickly build and run Node tests
grunt.registerTask("quicktest", [
"shell:testcjs",
"shell:test"
]);

// generate a good test environment for testing sourcemaps
grunt.registerTask("sourcemap-test", [
Expand All @@ -579,5 +586,8 @@ module.exports = function(grunt) {
]);

// Run benchmark
grunt.registerTask("benchmark", ["shell:benchmark"]);
grunt.registerTask("benchmark", [
"shell:testcjs",
"shell:benchmark"
]);
};
5 changes: 4 additions & 1 deletion benchmark/benchmark.less
Original file line number Diff line number Diff line change
Expand Up @@ -3976,4 +3976,7 @@ body {

.mixout ('left') {
left: 1;
}
}

// add extend
.btn:extend(.button all) {}
2 changes: 1 addition & 1 deletion benchmark/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var path = require('path'),
fs = require('fs'),
now = require("performance-now");

var less = require('../lib/less-node');
var less = require('../test/less');
var file = path.join(__dirname, 'benchmark.less');

if (process.argv[2]) { file = path.join(process.cwd(), process.argv[2]) }
Expand Down
6 changes: 3 additions & 3 deletions lib/less/parser/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ const Parser = function Parser(context, imports, fileInfo) {
continue;
}

node = mixin.definition() || this.declaration() || this.ruleset() ||
mixin.call(false, false) || this.variableCall() || this.entities.call() || this.atrule();
node = mixin.definition() || this.declaration() || mixin.call(false, false) ||
this.ruleset() || this.variableCall() || this.entities.call() || this.atrule();
if (node) {
root.push(node);
} else {
Expand Down Expand Up @@ -1159,7 +1159,7 @@ const Parser = function Parser(context, imports, fileInfo) {
parserInput.restore();
}
} else {
parserInput.forget();
parserInput.restore();
}
},

Expand Down
6 changes: 6 additions & 0 deletions test/css/namespacing/namespacing-functions.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@
width: 20px;
bar: val;
}
.bar {
width: test;
}
.example {
value: lookup;
}
10 changes: 1 addition & 9 deletions test/less-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@ module.exports = function() {
doBomTest = false,
clone = require('clone');

var less;

// Dist fallback for NPM-installed Less (for plugins that do testing)
try {
less = require('../tmp/less.cjs.js');
}
catch (e) {
less = require('../dist/less.cjs.js');
}
var less = require('./less');

var stylize = require('../lib/less-node/lessc-helper').stylize;

Expand Down
11 changes: 11 additions & 0 deletions test/less.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var less;

// Dist fallback for NPM-installed Less (for plugins that do testing)
try {
less = require('../tmp/less.cjs.js');
}
catch (e) {
less = require('../dist/less.cjs.js');
}

module.exports = less;
26 changes: 26 additions & 0 deletions test/less/namespacing/namespacing-functions.less
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,30 @@

@return: {
single: val;
}

// Issue #3405
#lookup {
@prop: test;
}

.mix (@var) {
width: @var;
}

.bar {
.mix(#lookup[@prop]);
}

// Issue #3406
.mix2 (@n) {
value: @n;
}
#lookup2 {
@var: .mix2(lookup);
}
.example {
// #lookup[@var](); -- fails, need the following alias
@dr: #lookup2[@var];
@dr();
}

0 comments on commit 3f8a6ae

Please sign in to comment.