Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

less

Package Overview
Dependencies
Maintainers
1
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

less - npm Package Compare versions

Comparing version 1.2.2 to 1.3.0

.gitignore

2

benchmark/less-benchmark.js

@@ -13,3 +13,3 @@ var path = require('path'),

sys.puts("Bechmarking...\n", path.basename(file) + " (" +
sys.puts("Benchmarking...\n", path.basename(file) + " (" +
parseInt(data.length / 1024) + " KB)", "");

@@ -16,0 +16,0 @@

@@ -6,3 +6,3 @@ var path = require('path'),

var less = {
version: [1, 2, 2],
version: [1, 3, 0],
Parser: require('./parser').Parser,

@@ -86,3 +86,4 @@ importer: require('./parser').importer,

'mixin', 'comment', 'anonymous', 'value',
'javascript', 'assignment', 'condition', 'paren'
'javascript', 'assignment', 'condition', 'paren',
'media'
].forEach(function (n) {

@@ -89,0 +90,0 @@ require('./tree/' + n);

@@ -231,4 +231,4 @@ var less, tree;

this.line = typeof(line) === 'number' ? line + 1 : null;
this.callLine = e.call && (getLocation(e.call, input) + 1);
this.callExtract = lines[getLocation(e.call, input)];
this.callLine = e.call && (getLocation(e.call, input).line + 1);
this.callExtract = lines[getLocation(e.call, input).line];
this.stack = e.stack;

@@ -767,3 +767,3 @@ this.column = col;

if (elements.length > 0 && ($(';') || peek('}'))) {
return new(tree.mixin.Call)(elements, args, index, env.filename, important);
return new(tree.mixin.Call)(elements, args || [], index, env.filename, important);
}

@@ -792,3 +792,3 @@ },

definition: function () {
var name, params = [], match, ruleset, param, value, cond;
var name, params = [], match, ruleset, param, value, cond, variadic = false;
if ((input.charAt(i) !== '.' && input.charAt(i) !== '#') ||

@@ -802,17 +802,28 @@ peek(/^[^{]*(;|})/)) return;

while (param = $(this.entities.variable) || $(this.entities.literal)
|| $(this.entities.keyword)) {
// Variable
if (param instanceof tree.Variable) {
if ($(':')) {
value = expect(this.expression, 'expected expression');
params.push({ name: param.name, value: value });
do {
if (input.charAt(i) === '.' && $(/^\.{3}/)) {
variadic = true;
break;
} else if (param = $(this.entities.variable) || $(this.entities.literal)
|| $(this.entities.keyword)) {
// Variable
if (param instanceof tree.Variable) {
if ($(':')) {
value = expect(this.expression, 'expected expression');
params.push({ name: param.name, value: value });
} else if ($(/^\.{3}/)) {
params.push({ name: param.name, variadic: true });
variadic = true;
break;
} else {
params.push({ name: param.name });
}
} else {
params.push({ name: param.name });
params.push({ value: param });
}
} else {
params.push({ value: param });
break;
}
if (! $(',')) { break }
}
} while ($(','))
expect(')');

@@ -827,3 +838,3 @@

if (ruleset) {
return new(tree.mixin.Definition)(name, params, ruleset, cond);
return new(tree.mixin.Definition)(name, params, ruleset, cond, variadic);
} else {

@@ -924,6 +935,2 @@ restore();

return new(tree.Combinator)(match);
} else if (c === ':' && input.charAt(i + 1) === ':') {
i += 2;
while (input.charAt(i) === ' ') { i++ }
return new(tree.Combinator)('::');
} else if (input.charAt(i - 1) === ' ') {

@@ -947,2 +954,8 @@ return new(tree.Combinator)(" ");

if ($('(')) {
sel = $(this.entity);
expect(')');
return new(tree.Selector)([new(tree.Element)('', sel, i)]);
}
while (e = $(this.element)) {

@@ -1003,3 +1016,3 @@ c = input.charAt(i);

if (selectors.length > 0 && (rules = $(this.block))) {
return new(tree.Ruleset)(selectors, rules);
return new(tree.Ruleset)(selectors, rules, env.strictImports);
} else {

@@ -1059,3 +1072,3 @@ // Backtrack

mediaFeature: function () {
var nodes = [];
var e, p, nodes = [];

@@ -1086,7 +1099,14 @@ do {

mediaFeatures: function () {
var f, features = [];
while (f = $(this.mediaFeature)) {
features.push(f);
if (! $(',')) { break }
}
var e, features = [];
do {
if (e = $(this.mediaFeature)) {
features.push(e);
if (! $(',')) { break }
} else if (e = $(this.entities.variable)) {
features.push(e);
if (! $(',')) { break }
}
} while (e);
return features.length > 0 ? features : null;

@@ -1096,3 +1116,3 @@ },

media: function () {
var features;
var features, rules;

@@ -1103,3 +1123,3 @@ if ($(/^@media/)) {

if (rules = $(this.block)) {
return new(tree.Directive)('@media', rules, features);
return new(tree.Media)(rules, features);
}

@@ -1106,0 +1126,0 @@ }

@@ -5,3 +5,2 @@ (function (tree) {

this.name = name;
this.features = features && new(tree.Value)(features);

@@ -17,7 +16,5 @@ if (Array.isArray(value)) {

toCSS: function (ctx, env) {
var features = this.features ? ' ' + this.features.toCSS(env) : '';
if (this.ruleset) {
this.ruleset.root = true;
return this.name + features + (env.compress ? '{' : ' {\n ') +
return this.name + (env.compress ? '{' : ' {\n ') +
this.ruleset.toCSS(ctx, env).trim().replace(/\n/g, '\n ') +

@@ -30,3 +27,2 @@ (env.compress ? '}': '\n}\n');

eval: function (env) {
this.features = this.features && this.features.eval(env);
env.frames.unshift(this);

@@ -33,0 +29,0 @@ this.ruleset = this.ruleset && this.ruleset.eval(env);

@@ -41,3 +41,2 @@ (function (tree) {

':' : ' :',
'::': '::',
'+' : env.compress ? '+' : ' + ',

@@ -44,0 +43,0 @@ '~' : env.compress ? '~' : ' ~ ',

@@ -74,3 +74,3 @@ (function (tree) {

}
return this.features ? new(tree.Directive)('@media', ruleset.rules, this.features.value) : ruleset.rules;
return this.features ? new(tree.Media)(ruleset.rules, this.features.value) : ruleset.rules;
}

@@ -77,0 +77,0 @@ }

@@ -25,3 +25,3 @@ (function (tree) {

} catch (e) {
throw { message: e.message, index: e.index, filename: this.filename, stack: e.stack, call: this.index };
throw { message: e.message, index: this.index, filename: this.filename, stack: e.stack };
}

@@ -49,3 +49,3 @@ }

tree.mixin.Definition = function (name, params, rules, condition) {
tree.mixin.Definition = function (name, params, rules, condition, variadic) {
this.name = name;

@@ -55,2 +55,3 @@ this.selectors = [new(tree.Selector)([new(tree.Element)(null, name)])];

this.condition = condition;
this.variadic = variadic;
this.arity = params.length;

@@ -74,8 +75,14 @@ this.rules = rules;

evalParams: function (env, args) {
var frame = new(tree.Ruleset)(null, []);
var frame = new(tree.Ruleset)(null, []), varargs;
for (var i = 0, val; i < this.params.length; i++) {
if (this.params[i].name) {
if (val = (args && args[i]) || this.params[i].value) {
frame.rules.unshift(new(tree.Rule)(this.params[i].name, val.eval(env)));
for (var i = 0, val, name; i < this.params.length; i++) {
if (name = this.params[i].name) {
if (this.params[i].variadic && args) {
varargs = [];
for (var j = i; j < args.length; j++) {
varargs.push(args[j].eval(env));
}
frame.rules.unshift(new(tree.Rule)(name, new(tree.Expression)(varargs).eval(env)));
} else if (val = (args && args[i]) || this.params[i].value) {
frame.rules.unshift(new(tree.Rule)(name, val.eval(env)));
} else {

@@ -90,3 +97,3 @@ throw { type: 'Runtime', message: "wrong number of arguments for " + this.name +

eval: function (env, args, important) {
var frame = this.evalParams(env, args), context, _arguments = [], rules;
var frame = this.evalParams(env, args), context, _arguments = [], rules, start;

@@ -110,4 +117,8 @@ for (var i = 0; i < Math.max(this.params.length, args && args.length); i++) {

if (argsLength < this.required) { return false }
if ((this.required > 0) && (argsLength > this.params.length)) { return false }
if (! this.variadic) {
if (argsLength < this.required) { return false }
if (argsLength > this.params.length) { return false }
if ((this.required > 0) && (argsLength > this.params.length)) { return false }
}
if (this.condition && !this.condition.eval({

@@ -114,0 +125,0 @@ frames: [this.evalParams(env, args)].concat(env.frames)

(function (tree) {
tree.Ruleset = function (selectors, rules) {
tree.Ruleset = function (selectors, rules, strictImports) {
this.selectors = selectors;
this.rules = rules;
this._lookups = {};
this.strictImports = strictImports;
};

@@ -11,3 +12,3 @@ tree.Ruleset.prototype = {

var selectors = this.selectors && this.selectors.map(function (s) { return s.eval(env) });
var ruleset = new(tree.Ruleset)(selectors, this.rules.slice(0));
var ruleset = new(tree.Ruleset)(selectors, this.rules.slice(0), this.strictImports);

@@ -21,3 +22,3 @@ ruleset.root = this.root;

// Evaluate imports
if (ruleset.root || ruleset.allowImports) {
if (ruleset.root || ruleset.allowImports || !ruleset.strictImports) {
for (var i = 0; i < ruleset.rules.length; i++) {

@@ -135,3 +136,3 @@ if (ruleset.rules[i] instanceof tree.Import) {

if (rule.rules || (rule instanceof tree.Directive)) {
if (rule.rules || (rule instanceof tree.Directive) || (rule instanceof tree.Media)) {
rulesets.push(rule.toCSS(paths, env));

@@ -138,0 +139,0 @@ } else if (rule instanceof tree.Comment) {

@@ -8,3 +8,3 @@ {

"contributors" : [],
"version" : "1.2.2",
"version" : "1.3.0",
"bin" : { "lessc": "./bin/lessc" },

@@ -11,0 +11,0 @@ "main" : "./lib/less/index",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc