mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
@@ -2,7 +2,8 @@ var LessError = require('../less-error'),
|
||||
tree = require("../tree"),
|
||||
visitors = require("../visitors"),
|
||||
getParserInput = require("./parser-input"),
|
||||
utils = require("../utils");
|
||||
utils = require("../utils"),
|
||||
functionRegistry = require('../functions/function-registry');
|
||||
|
||||
//
|
||||
// less.js - parser
|
||||
@@ -185,6 +186,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
||||
tree.Node.prototype.rootNode = root;
|
||||
root.root = true;
|
||||
root.firstRoot = true;
|
||||
// root.functionRegistry = functionRegistry.inherit();
|
||||
|
||||
} catch (e) {
|
||||
return callback(new LessError(e, imports, fileInfo.filename));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
registerPlugin({
|
||||
install: function(less, pluginManager, functions) {
|
||||
functions.add('func', function() {
|
||||
return less.Anonymous(location.href);
|
||||
return less.anonymous(location.href);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -58,4 +58,5 @@ testMap.forEach(function(args) {
|
||||
lessTester.testSyncronous({syncImport: true}, "import");
|
||||
lessTester.testSyncronous({syncImport: true}, "css");
|
||||
lessTester.testNoOptions();
|
||||
lessTester.testJSImport();
|
||||
lessTester.finished();
|
||||
|
||||
@@ -155,6 +155,24 @@ module.exports = function() {
|
||||
});
|
||||
}
|
||||
|
||||
// https://github.com/less/less.js/issues/3112
|
||||
function testJSImport() {
|
||||
process.stdout.write("- Testing root function registry");
|
||||
less.functions.functionRegistry.add('ext', function() {
|
||||
return new less.tree.Anonymous('file');
|
||||
});
|
||||
var expected = "@charset \"utf-8\";\n";
|
||||
toCSS({}, require('path').join(process.cwd(), 'test/less/root-registry/root.less'), function(error, output) {
|
||||
if (error) {
|
||||
return fail("ERROR: " + error);
|
||||
}
|
||||
if (output.css === expected) {
|
||||
return ok('OK');
|
||||
}
|
||||
difference("FAIL", expected, output.css);
|
||||
});
|
||||
}
|
||||
|
||||
function globalReplacements(input, directory, filename) {
|
||||
var path = require('path');
|
||||
var p = filename ? path.join(path.dirname(filename), '/') : path.join(process.cwd(), directory),
|
||||
@@ -422,6 +440,7 @@ module.exports = function() {
|
||||
testEmptySourcemap: testEmptySourcemap,
|
||||
testNoOptions: testNoOptions,
|
||||
prepBomTest: prepBomTest,
|
||||
testJSImport: testJSImport,
|
||||
finished: finished
|
||||
};
|
||||
};
|
||||
|
||||
1
test/less/root-registry/file.less
Normal file
1
test/less/root-registry/file.less
Normal file
@@ -0,0 +1 @@
|
||||
@charset "utf-8";
|
||||
3
test/less/root-registry/root.less
Normal file
3
test/less/root-registry/root.less
Normal file
@@ -0,0 +1,3 @@
|
||||
// https://github.com/less/less.js/issues/3112
|
||||
@file: ext();
|
||||
@import '@{file}';
|
||||
Reference in New Issue
Block a user