Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3405 #3426

Merged
merged 4 commits into from
Aug 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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();
}