mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
Fix error messages in the browser for imported files with duplicate names (different directory) and links. Fixes #932
This commit is contained in:
@@ -133,8 +133,6 @@ function loadStyleSheet(sheet, callback, reload, remaining) {
|
||||
href = url.slice(0, url.lastIndexOf('/') + 1) + href;
|
||||
}
|
||||
}
|
||||
var filename = href.match(/([^\/]+)$/)[1];
|
||||
|
||||
xhr(sheet.href, sheet.type, function (data, lastModified) {
|
||||
if (!reload && styles && lastModified &&
|
||||
(new(Date)(lastModified).valueOf() ===
|
||||
@@ -145,12 +143,12 @@ function loadStyleSheet(sheet, callback, reload, remaining) {
|
||||
} else {
|
||||
// Use remote copy (re-parse)
|
||||
try {
|
||||
contents[filename] = data; // Updating top importing parser content cache
|
||||
contents[href] = data; // Updating top importing parser content cache
|
||||
new(less.Parser)({
|
||||
optimization: less.optimization,
|
||||
paths: [href.replace(/[\w\.-]+$/, '')],
|
||||
mime: sheet.type,
|
||||
filename: filename,
|
||||
filename: href,
|
||||
'contents': contents // Passing top importing parser content cache ref down.
|
||||
}).parse(data, function (e, root) {
|
||||
if (e) { return error(e, href) }
|
||||
@@ -287,12 +285,13 @@ function error(e, href) {
|
||||
var template = '<li><label>{line}</label><pre class="{class}">{content}</pre></li>';
|
||||
var elem = document.createElement('div'), timer, content, error = [];
|
||||
var filename = e.filename || href;
|
||||
var filenameNoPath = filename.match(/([^\/]+)$/)[1];
|
||||
|
||||
elem.id = id;
|
||||
elem.className = "less-error-message";
|
||||
|
||||
content = '<h3>' + (e.message || 'There is an error in your .less file') +
|
||||
'</h3>' + '<p>in <a href="' + filename + '">' + filename + "</a> ";
|
||||
'</h3>' + '<p>in <a href="' + filename + '">' + filenameNoPath + "</a> ";
|
||||
|
||||
var errorline = function (e, i, classname) {
|
||||
if (e.extract[i]) {
|
||||
|
||||
Reference in New Issue
Block a user