Comparing version 3.7.1 to 3.8.0
@@ -0,1 +1,7 @@ | ||
## 3.7.1 | ||
2018-07-11 | ||
- Fixes mistake in `lessc` (using `console.warning` instead of actual `console.warn`) | ||
- Adds `lessc` tests | ||
## 3.7.0 | ||
@@ -2,0 +8,0 @@ |
@@ -73,3 +73,5 @@ 'use strict'; | ||
var browserTests = [ 'filemanager-plugin', | ||
var browserTests = [ | ||
'filemanager-plugin', | ||
'visitor-plugin', | ||
@@ -80,4 +82,6 @@ 'global-vars', | ||
'rootpath-relative', | ||
'rootpath-rewrite-urls', | ||
'rootpath', | ||
'relative-urls', | ||
'rewrite-urls', | ||
'browser', | ||
@@ -367,2 +371,10 @@ 'no-js-errors', | ||
}, | ||
rewriteUrls: { | ||
src: ['test/browser/less/rewrite-urls/*.less'], | ||
options: { | ||
helpers: 'test/browser/runner-rewrite-urls-options.js', | ||
specs: 'test/browser/runner-rewrite-urls-spec.js', | ||
outfile: 'tmp/browser/test-runner-rewrite-urls.html' | ||
} | ||
}, | ||
rootpath: { | ||
@@ -384,2 +396,10 @@ src: ['test/browser/less/rootpath/*.less'], | ||
}, | ||
rootpathRewriteUrls: { | ||
src: ['test/browser/less/rootpath-rewrite-urls/*.less'], | ||
options: { | ||
helpers: 'test/browser/runner-rootpath-rewrite-urls-options.js', | ||
specs: 'test/browser/runner-rootpath-rewrite-urls-spec.js', | ||
outfile: 'tmp/browser/test-runner-rootpath-rewrite-urls.html' | ||
} | ||
}, | ||
production: { | ||
@@ -386,0 +406,0 @@ src: ['test/browser/less/production/*.less'], |
@@ -45,2 +45,6 @@ var addDataAttr = require('./utils').addDataAttr, | ||
} | ||
if (options.relativeUrls) { | ||
options.rewriteUrls = 'all'; | ||
} | ||
}; |
@@ -96,3 +96,4 @@ // | ||
rootFilename: path, | ||
relativeUrls: instanceOptions.relativeUrls}; | ||
rewriteUrls: instanceOptions.rewriteUrls | ||
}; | ||
@@ -99,0 +100,0 @@ newFileInfo.entryPath = newFileInfo.currentDirectory; |
@@ -9,3 +9,3 @@ module.exports = function(environment) { | ||
var currentFileInfo = functionContext.currentFileInfo; | ||
var currentDirectory = currentFileInfo.relativeUrls ? | ||
var currentDirectory = currentFileInfo.rewriteUrls ? | ||
currentFileInfo.currentDirectory : currentFileInfo.entryPath; | ||
@@ -12,0 +12,0 @@ |
@@ -50,3 +50,4 @@ // lessc_helper.js | ||
console.log(' Works with or without the relative-urls option.'); | ||
console.log(' -ru, --relative-urls Re-writes relative urls to the base less file.'); | ||
console.log(' -ru=, --rewrite-urls= Rewrites URLs to make them relative to the base less file.'); | ||
console.log(' all|local|off \'all\' rewrites all URLs, \'local\' just those starting with a \'.\''); | ||
console.log(''); | ||
@@ -53,0 +54,0 @@ console.log(' -m=, --math='); |
var contexts = {}; | ||
module.exports = contexts; | ||
var MATH = require('./math-constants'); | ||
var Constants = require('./constants'); | ||
@@ -21,3 +21,3 @@ var copyFromOriginal = function copyFromOriginal(original, destination, propertiesToCopy) { | ||
'paths', // option - unmodified - paths to search for imports on | ||
'relativeUrls', // option - whether to adjust URL's to be relative | ||
'rewriteUrls', // option - whether to adjust URL's to be relative | ||
'rootpath', // option - rootpath to append to URL's | ||
@@ -55,3 +55,4 @@ 'strictImports', // option - | ||
'pluginManager', // Used as the plugin manager for the session | ||
'importantScope' // used to bubble up !important statements | ||
'importantScope', // used to bubble up !important statements | ||
'rewriteUrls' // option - whether to adjust URL's to be relative | ||
]; | ||
@@ -100,6 +101,6 @@ | ||
} | ||
if (op === '/' && this.math !== MATH.ALWAYS && (!this.parensStack || !this.parensStack.length)) { | ||
if (op === '/' && this.math !== Constants.Math.ALWAYS && (!this.parensStack || !this.parensStack.length)) { | ||
return false; | ||
} | ||
if (this.math > MATH.PARENS_DIVISION) { | ||
if (this.math > Constants.Math.PARENS_DIVISION) { | ||
return this.parensStack && this.parensStack.length; | ||
@@ -110,7 +111,26 @@ } | ||
contexts.Eval.prototype.isPathRelative = function (path) { | ||
return !/^(?:[a-z-]+:|\/|#)/i.test(path); | ||
contexts.Eval.prototype.pathRequiresRewrite = function (path) { | ||
var isRelative = this.rewriteUrls === Constants.RewriteUrls.LOCAL ? isPathLocalRelative : isPathRelative; | ||
return isRelative(path); | ||
}; | ||
contexts.Eval.prototype.normalizePath = function( path ) { | ||
contexts.Eval.prototype.rewritePath = function (path, rootpath) { | ||
var newPath; | ||
rootpath = rootpath || ''; | ||
newPath = this.normalizePath(rootpath + path); | ||
// If a path was explicit relative and the rootpath was not an absolute path | ||
// we must ensure that the new path is also explicit relative. | ||
if (isPathLocalRelative(path) && | ||
isPathRelative(rootpath) && | ||
isPathLocalRelative(newPath) === false) { | ||
newPath = './' + newPath; | ||
} | ||
return newPath; | ||
}; | ||
contexts.Eval.prototype.normalizePath = function (path) { | ||
var | ||
@@ -121,3 +141,3 @@ segments = path.split('/').reverse(), | ||
path = []; | ||
while (segments.length !== 0 ) { | ||
while (segments.length !== 0) { | ||
segment = segments.pop(); | ||
@@ -135,3 +155,3 @@ switch ( segment ) { | ||
default: | ||
path.push( segment ); | ||
path.push(segment); | ||
break; | ||
@@ -144,2 +164,10 @@ } | ||
function isPathRelative(path) { | ||
return !/^(?:[a-z-]+:|\/|#)/i.test(path); | ||
} | ||
function isPathLocalRelative(path) { | ||
return path.charAt(0) === '.'; | ||
} | ||
// todo - do the same for the toCSS ? |
@@ -45,3 +45,3 @@ // Export a new default each time | ||
* URL is always relative to the base imported file */ | ||
relativeUrls: false, | ||
rewriteUrls: false, | ||
@@ -48,0 +48,0 @@ /* Compatibility with IE8. Used for limiting data-uri length */ |
@@ -21,3 +21,3 @@ module.exports = function(environment) { | ||
var currentFileInfo = this.currentFileInfo; | ||
var currentDirectory = currentFileInfo.relativeUrls ? | ||
var currentDirectory = currentFileInfo.rewriteUrls ? | ||
currentFileInfo.currentDirectory : currentFileInfo.entryPath; | ||
@@ -24,0 +24,0 @@ |
@@ -11,3 +11,3 @@ var contexts = require('./contexts'), | ||
// FileInfo = { | ||
// 'relativeUrls' - option - whether to adjust URL's to be relative | ||
// 'rewriteUrls' - option - whether to adjust URL's to be relative | ||
// 'filename' - full resolved filename of current file | ||
@@ -69,3 +69,3 @@ // 'rootpath' - path to append to normal URLs for this node | ||
var newFileInfo = { | ||
relativeUrls: this.context.relativeUrls, | ||
rewriteUrls: this.context.rewriteUrls, | ||
entryPath: currentFileInfo.entryPath, | ||
@@ -97,3 +97,3 @@ rootpath: currentFileInfo.rootpath, | ||
newFileInfo.currentDirectory = fileManager.getPath(resolvedFilename); | ||
if (newFileInfo.relativeUrls) { | ||
if (newFileInfo.rewriteUrls) { | ||
newFileInfo.rootpath = fileManager.join( | ||
@@ -100,0 +100,0 @@ (importManager.context.rootpath || ''), |
@@ -5,3 +5,3 @@ module.exports = function(environment, fileManagers) { | ||
var initial = { | ||
version: [3, 7, 1], | ||
version: [3, 8, 0], | ||
data: require('./data'), | ||
@@ -8,0 +8,0 @@ tree: require('./tree'), |
@@ -49,3 +49,3 @@ var PromiseConstructor, | ||
filename: filename, | ||
relativeUrls: context.relativeUrls, | ||
rewriteUrls: context.rewriteUrls, | ||
rootpath: context.rootpath || '', | ||
@@ -52,0 +52,0 @@ currentDirectory: entryPath, |
@@ -5,3 +5,3 @@ var Node = require('./node'), | ||
Anonymous = require('./anonymous'), | ||
MATH = require('../math-constants'); | ||
MATH = require('../constants').Math; | ||
@@ -8,0 +8,0 @@ var Declaration = function (name, value, important, merge, index, currentFileInfo, inline, variable) { |
@@ -5,3 +5,3 @@ var Node = require('./node'), | ||
Dimension = require('./dimension'), | ||
MATH = require('../math-constants'); | ||
MATH = require('../constants').Math; | ||
@@ -8,0 +8,0 @@ var Expression = function (value, noSpacing) { |
@@ -100,13 +100,14 @@ var Node = require('./node'), | ||
var path = this.path.eval(context); | ||
var rootpath = this._fileInfo && this._fileInfo.rootpath; | ||
var fileInfo = this._fileInfo; | ||
if (!(path instanceof URL)) { | ||
if (rootpath) { | ||
var pathValue = path.value; | ||
// Add the base path if the import is relative | ||
if (pathValue && context.isPathRelative(pathValue)) { | ||
path.value = rootpath + pathValue; | ||
} | ||
// Add the rootpath if the URL requires a rewrite | ||
var pathValue = path.value; | ||
if (fileInfo && | ||
pathValue && | ||
context.pathRequiresRewrite(pathValue)) { | ||
path.value = context.rewritePath(pathValue, fileInfo.rootpath); | ||
} else { | ||
path.value = context.normalizePath(path.value); | ||
} | ||
path.value = context.normalizePath(path.value); | ||
} | ||
@@ -113,0 +114,0 @@ |
var Node = require('./node'), | ||
Color = require('./color'), | ||
Dimension = require('./dimension'), | ||
MATH = require('../math-constants'); | ||
MATH = require('../constants').Math; | ||
@@ -6,0 +6,0 @@ var Operation = function (op, operands, isSpaced) { |
@@ -24,16 +24,15 @@ var Node = require('./node'); | ||
if (!this.isEvald) { | ||
// Add the base path if the URL is relative | ||
// Add the rootpath if the URL requires a rewrite | ||
rootpath = this.fileInfo() && this.fileInfo().rootpath; | ||
if (rootpath && | ||
if (typeof rootpath === 'string' && | ||
typeof val.value === 'string' && | ||
context.isPathRelative(val.value)) { | ||
context.pathRequiresRewrite(val.value)) { | ||
if (!val.quote) { | ||
rootpath = rootpath.replace(/[\(\)'"\s]/g, function(match) { return '\\' + match; }); | ||
rootpath = escapePath(rootpath); | ||
} | ||
val.value = rootpath + val.value; | ||
val.value = context.rewritePath(val.value, rootpath); | ||
} else { | ||
val.value = context.normalizePath(val.value); | ||
} | ||
val.value = context.normalizePath(val.value); | ||
// Add url args if enabled | ||
@@ -55,2 +54,7 @@ if (context.urlArgs) { | ||
}; | ||
function escapePath(path) { | ||
return path.replace(/[\(\)'"\s]/g, function(match) { return '\\' + match; }); | ||
} | ||
module.exports = URL; |
/* jshint proto: true */ | ||
var MATH = require('./math-constants'); | ||
var Constants = require('./constants'); | ||
@@ -44,20 +44,37 @@ var utils = { | ||
if (opts.strictMath) { | ||
opts.math = MATH.STRICT_LEGACY; | ||
opts.math = Constants.Math.STRICT_LEGACY; | ||
} | ||
if (opts.hasOwnProperty('math') && typeof opts.math === 'string') { | ||
// Back compat with changed relativeUrls option | ||
if (opts.relativeUrls) { | ||
opts.rewriteUrls = Constants.RewriteUrls.ALL; | ||
} | ||
if (typeof opts.math === 'string') { | ||
switch (opts.math.toLowerCase()) { | ||
case 'always': | ||
opts.math = MATH.ALWAYS; | ||
opts.math = Constants.Math.ALWAYS; | ||
break; | ||
case 'parens-division': | ||
opts.math = MATH.PARENS_DIVISION; | ||
opts.math = Constants.Math.PARENS_DIVISION; | ||
break; | ||
case 'strict': | ||
case 'parens': | ||
opts.math = MATH.PARENS; | ||
opts.math = Constants.Math.PARENS; | ||
break; | ||
case 'strict-legacy': | ||
opts.math = MATH.STRICT_LEGACY; | ||
opts.math = Constants.Math.STRICT_LEGACY; | ||
} | ||
} | ||
if (typeof opts.rewriteUrls === 'string') { | ||
switch (opts.rewriteUrls.toLowerCase()) { | ||
case 'off': | ||
opts.rewriteUrls = Constants.RewriteUrls.OFF; | ||
break; | ||
case 'local': | ||
opts.rewriteUrls = Constants.RewriteUrls.LOCAL; | ||
break; | ||
case 'all': | ||
opts.rewriteUrls = Constants.RewriteUrls.ALL; | ||
break; | ||
} | ||
} | ||
return opts; | ||
@@ -64,0 +81,0 @@ }, |
{ | ||
"name": "less", | ||
"version": "3.7.1", | ||
"version": "3.8.0", | ||
"description": "Leaner CSS", | ||
@@ -5,0 +5,0 @@ "homepage": "http://lesscss.org", |
@@ -1,3 +0,3 @@ | ||
describe('less.js browser test - rootpath and relative url\'s', function() { | ||
describe('less.js browser test - rootpath and relative urls', function() { | ||
testLessEqualsInDocument(); | ||
}); |
@@ -12,4 +12,5 @@ var lessTest = require('./less-test'), | ||
[{ | ||
relativeUrls: true, | ||
silent: true, | ||
// TODO: Change this to rewriteUrls: 'all' once the relativeUrls option is removed | ||
relativeUrls: true, | ||
silent: true, | ||
javascriptEnabled: true, | ||
@@ -41,2 +42,3 @@ // Set explicitly for legacy tests for >3.0 | ||
function(name) { return name + '-all'; }], | ||
// TODO: Change this to rewriteUrls: false once the relativeUrls option is removed | ||
[{math: 'strict', relativeUrls: false, rootpath: 'folder (1)/'}, 'static-urls/'], | ||
@@ -61,2 +63,6 @@ [{math: 'strict', compress: true}, 'compression/'], | ||
[{urlArgs: '424242'}, 'url-args/'], | ||
[{rewriteUrls: 'all'}, 'rewrite-urls-all/'], | ||
[{rewriteUrls: 'local'}, 'rewrite-urls-local/'], | ||
[{rootpath: 'http://example.com/assets/css/', rewriteUrls: 'all'}, 'rootpath-rewrite-urls-all/'], | ||
[{rootpath: 'http://example.com/assets/css/', rewriteUrls: 'local'}, 'rootpath-rewrite-urls-local/'], | ||
[{paths: ['test/data/', 'test/less/import/']}, 'include-path/'], | ||
@@ -63,0 +69,0 @@ [{paths: 'test/data/'}, 'include-path-string/'], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2783510
1056
67329