Merge branch 'master' into sauce

This commit is contained in:
Luke Page
2014-10-21 13:22:19 +01:00
11 changed files with 37 additions and 7 deletions

View File

@@ -12,6 +12,10 @@ abstractFileManager.prototype.getPath = function (filename) {
return filename.slice(0, j + 1);
};
abstractFileManager.prototype.tryAppendLessExtension = function(path) {
return /(\.[a-z]*$)|([\?;].*)$/.test(path) ? path : path + '.less';
};
abstractFileManager.prototype.supportsSync = function() {
return false;
};

View File

@@ -7,6 +7,14 @@ module.exports = {
*/
getPath: function(filename) {
},
/**
* Append a .less extension if appropriate. Only called if less thinks one could be added.
* Provided by AbstractFileManager
* @param filename
* @returns {string}
*/
tryAppendLessExtension: function(filename) {
},
/**
* Whether the rootpath should be converted to be absolute.
* The browser ovverides this to return true because urls must be absolute.

View File

@@ -24,7 +24,15 @@ module.exports = function(environment) {
this.queue = []; // Files which haven't been imported yet
this.files = []; // Holds the imported parse trees.
};
ImportManager.prototype.push = function (path, currentFileInfo, importOptions, callback) {
/**
* Add an import to be imported
* @param path - the raw path
* @param tryAppendLessExtension - whether to try appending the less extension (if the path has no extension)
* @param currentFileInfo - the current file info (used for instance to work out relative paths)
* @param importOptions - import options
* @param callback - callback for when it is imported
*/
ImportManager.prototype.push = function (path, tryAppendLessExtension, currentFileInfo, importOptions, callback) {
var importManager = this;
this.queue.push(path);
@@ -54,6 +62,10 @@ module.exports = function(environment) {
return;
}
if (tryAppendLessExtension) {
path = fileManager.tryAppendLessExtension(path);
}
fileManager.loadFile(path, currentFileInfo.currentDirectory, this.context, environment)
.then(function loadFileCallback(loadedFile) {
var resolvedFilename = loadedFile.filename,

View File

@@ -389,12 +389,13 @@ var Parser = function Parser(context, imports, fileInfo) {
url: function () {
var value, index = parserInput.i;
parserInput.autoCommentAbsorb = false;
if (parserInput.currentChar() !== 'u' || !parserInput.$re(/^url\(/)) {
parserInput.autoCommentAbsorb = true;
return;
}
parserInput.autoCommentAbsorb = false;
value = this.quoted() || this.variable() ||
parserInput.$re(/^(?:(?:\\[\(\)'"])|[^\(\)'"])+/) || "";

View File

@@ -67,8 +67,7 @@ Import.prototype.genCSS = function (context, output) {
};
Import.prototype.getPath = function () {
if (this.path instanceof Quoted) {
var path = this.path.value;
return (this.css !== undefined || /(\.[a-z]*$)|([\?;].*)$/.test(path)) ? path : path + '.less';
return this.path.value;
} else if (this.path instanceof URL) {
return this.path.value.value;
}

View File

@@ -62,7 +62,9 @@ ImportVisitor.prototype = {
context.importMultiple = true;
}
this._importer.push(importNode.getPath(), importNode.currentFileInfo, importNode.options, function (e, root, importedAtRoot, fullPath) {
// try appending if we haven't determined if it is css or not
var tryAppendLessExtension = importNode.css === undefined;
this._importer.push(importNode.getPath(), tryAppendLessExtension, importNode.currentFileInfo, importNode.options, function (e, root, importedAtRoot, fullPath) {
if (e && !e.filename) {
e.index = importNode.index; e.filename = importNode.currentFileInfo.filename;
}

View File

@@ -9,6 +9,7 @@
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium), url(http://localhost:8081/test/browser/less/fonts.svg#MyGeometricModern) format("svg");
not-a-comment: url(//z);
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;

View File

@@ -4,6 +4,7 @@
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium),
url(fonts.svg#MyGeometricModern) format("svg");
not-a-comment: url(//z);
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;

View File

@@ -4,6 +4,7 @@
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium), url(fonts.svg#MyGeometricModern) format("svg");
not-a-comment: url(//z);
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;

View File

@@ -2,6 +2,7 @@
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium),
url(fonts.svg#MyGeometricModern) format("svg");
not-a-comment: url(//z);
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;

View File

@@ -1 +1 @@
{"version":3,"sources":["testweb/sourcemaps/basic.less","testweb/sourcemaps/imported.css"],"names":[],"mappings":"AAMA;EACE,YAAA;EAJA,UAAA;EAWA,iBAAA;EALA,WAAA;EACA,iBAAA;;AAJF,EASE;AATF,EASM;EACF,gBAAA;;AACA,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFA;AAEF,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFA;EAGA,UAAA;;AALN;AAAI;AAUJ;EATE,iBAAA;;AADF,EAEE;AAFE,EAEF;AAFF,EAEM;AAFF,EAEE;AAQN,OARE;AAQF,OARM;EACF,gBAAA;;AACA,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFA;AAEF,EAFF,GAEI,KAFA;AAEF,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFA;AAEF,EAFF,GAEI,KAFA;AAEF,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFA;AAEF,EAFE,GAEA,KAFA;AAEF,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFA;AAEF,EAFE,GAEA,KAFA;AAQN,OARE,GAQF,UARE;AAQF,OARE,GAEI,KAFJ;AAQF,OARE,GAQF,UARM;AAQN,OARE,GAEI,KAFA;AAEF,EAFF,GAQF,UARE;AAEE,EAFF,GAQF,UARM;AAQN,OARM,GAQN,UARE;AAQF,OARM,GAEA,KAFJ;AAQF,OARM,GAQN,UARM;AAQN,OARM,GAEA,KAFA;AAEF,EAFE,GAQN,UARE;AAEE,EAFE,GAQN,UARM;EAGA,UAAA;;AAKN;EACE,WAAA;;ACxBF;AACA;AACA;AACA;AACA;AACA;AACA","file":"sourcemaps/basic.css"}
{"version":3,"file":"sourcemaps/basic.css","sources":["testweb/sourcemaps/basic.less","testweb/sourcemaps/imported.css"],"names":[],"mappings":"AAMA;EACE,YAAA;EAJA,UAAA;EAWA,iBAAA;EALA,WAAA;EACA,iBAAA;;AAJF,EASE;AATF,EASM;EACF,gBAAA;;AACA,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFA;AAEF,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFA;EAGA,UAAA;;AALN;AAAI;AAUJ;EATE,iBAAA;;AADF,EAEE;AAFE,EAEF;AAFF,EAEM;AAFF,EAEE;AAQN,OARE;AAQF,OARM;EACF,gBAAA;;AACA,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFA;AAEF,EAFF,GAEI,KAFA;AAEF,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFA;AAEF,EAFF,GAEI,KAFA;AAEF,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFA;AAEF,EAFE,GAEA,KAFA;AAEF,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFA;AAEF,EAFE,GAEA,KAFA;AAQN,OARE,GAQF,UARE;AAQF,OARE,GAEI,KAFJ;AAQF,OARE,GAQF,UARM;AAQN,OARE,GAEI,KAFA;AAEF,EAFF,GAQF,UARE;AAEE,EAFF,GAQF,UARM;AAQN,OARM,GAQN,UARE;AAQF,OARM,GAEA,KAFJ;AAQF,OARM,GAQN,UARM;AAQN,OARM,GAEA,KAFA;AAEF,EAFE,GAQN,UARE;AAEE,EAFE,GAQN,UARM;EAGA,UAAA;;AAKN;EACE,WAAA;;ACxBF;AACA;AACA;AACA;AACA;AACA;AACA"}