From afd599dcb5aaeb9bab04efa0430c2d34f01692c9 Mon Sep 17 00:00:00 2001 From: James Foster Date: Fri, 20 May 2011 07:55:02 +0800 Subject: [PATCH 1/4] Implement parent selector --- lib/less/parser.js | 14 ++++++++++++- lib/less/tree/element.js | 5 ++++- lib/less/tree/ruleset.js | 44 +++++++++++++++++++++++++++++++++++----- test/css/selectors.css | 21 +++++++++++++++++++ test/less/selectors.less | 24 ++++++++++++++++++++++ 5 files changed, 101 insertions(+), 7 deletions(-) diff --git a/lib/less/parser.js b/lib/less/parser.js index 9cb2a30e..e828c23c 100644 --- a/lib/less/parser.js +++ b/lib/less/parser.js @@ -790,6 +790,10 @@ less.Parser = function Parser(env) { e = $(/^(?:[.#]?|:*)(?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/) || $('*') || $(this.attribute) || $(/^\([^)@]+\)/); if (e) { return new(tree.Element)(c, e) } + + if (c.value && c.value[0] === '&') { + return new(tree.Element)(c, null); + } }, // @@ -804,10 +808,18 @@ less.Parser = function Parser(env) { combinator: function () { var match, c = input.charAt(i); - if (c === '>' || c === '&' || c === '+' || c === '~') { + if (c === '>' || c === '+' || c === '~') { i++; while (input.charAt(i) === ' ') { i++ } return new(tree.Combinator)(c); + } else if (c === '&') { + match = '&'; + i++; + if(input.charAt(i) === ' ') { + match = '& '; + } + while (input.charAt(i) === ' ') { i++ } + return new(tree.Combinator)(match); } else if (c === ':' && input.charAt(i + 1) === ':') { i += 2; while (input.charAt(i) === ' ') { i++ } diff --git a/lib/less/tree/element.js b/lib/less/tree/element.js index acf5e205..27cf8228 100644 --- a/lib/less/tree/element.js +++ b/lib/less/tree/element.js @@ -3,7 +3,7 @@ tree.Element = function (combinator, value) { this.combinator = combinator instanceof tree.Combinator ? combinator : new(tree.Combinator)(combinator); - this.value = value.trim(); + this.value = value ? value.trim() : ""; }; tree.Element.prototype.toCSS = function (env) { return this.combinator.toCSS(env || {}) + this.value; @@ -12,6 +12,8 @@ tree.Element.prototype.toCSS = function (env) { tree.Combinator = function (value) { if (value === ' ') { this.value = ' '; + } else if (value === '& ') { + this.value = '& '; } else { this.value = value ? value.trim() : ""; } @@ -21,6 +23,7 @@ tree.Combinator.prototype.toCSS = function (env) { '' : '', ' ' : ' ', '&' : '', + '& ' : ' ', ':' : ' :', '::': '::', '+' : env.compress ? '+' : ' + ', diff --git a/lib/less/tree/ruleset.js b/lib/less/tree/ruleset.js index 4fbf1db8..246200fa 100644 --- a/lib/less/tree/ruleset.js +++ b/lib/less/tree/ruleset.js @@ -120,11 +120,7 @@ tree.Ruleset.prototype = { if (context.length === 0) { paths = this.selectors.map(function (s) { return [s] }); } else { - for (var s = 0; s < this.selectors.length; s++) { - for (var c = 0; c < context.length; c++) { - paths.push(context[c].concat([this.selectors[s]])); - } - } + this.joinSelectors( paths, context, this.selectors ); } } @@ -174,6 +170,44 @@ tree.Ruleset.prototype = { css.push(rulesets); return css.join('') + (env.compress ? '\n' : ''); + }, + + joinSelectors: function( paths, context, selectors ) { + for (var s = 0; s < selectors.length; s++) { + this.joinSelector(paths, context, selectors[s]); + } + }, + + joinSelector: function( paths, context, selector ) { + var before = [], after = [], beforeElements = [], afterElements = [], hasParentSelector = false, el; + + for (var i = 0; i < selector.elements.length; i++) { + el = selector.elements[i]; + if (el.combinator.value[0] === '&') { + hasParentSelector = true; + } + if(!hasParentSelector) { + beforeElements.push(el); + } else { + afterElements.push(el); + } + } + + if(!hasParentSelector) { + afterElements = beforeElements; + beforeElements = []; + } + + if(beforeElements.length > 0) { + before.push(new (tree.Selector)(beforeElements)); + } + if(afterElements.length > 0) { + after.push(new (tree.Selector)(afterElements)); + } + + for (var c = 0; c < context.length; c++) { + paths.push(before.concat(context[c]).concat(after)); + } } }; })(require('less/tree')); diff --git a/test/css/selectors.css b/test/css/selectors.css index 85916c35..a384f938 100644 --- a/test/css/selectors.css +++ b/test/css/selectors.css @@ -30,3 +30,24 @@ td { td, input { line-height: 1em; } +a { + color: red; +} +a:hover { + color: blue; +} +div a { + color: green; +} +p a span { + color: yellow; +} +.foo .bar .qux, .foo .baz .qux { + display: block; +} +.qux .foo .bar, .qux .foo .baz { + display: inline; +} +.qux .foo .bar .biz, .qux .foo .baz .biz { + display: none; +} diff --git a/test/less/selectors.less b/test/less/selectors.less index 5691bb22..5bc2bb1f 100644 --- a/test/less/selectors.less +++ b/test/less/selectors.less @@ -22,3 +22,27 @@ td { td, input { line-height: 1em; } + +a { + color: red; + + &:hover { color: blue; } + + div & { color: green; } + + p & span { color: yellow; } +} + +.foo { + .bar, .baz { + & .qux { + display: block; + } + .qux & { + display: inline; + } + .qux & .biz { + display: none; + } + } +} \ No newline at end of file From 04c2176bdbc7b9eb63f66f1768fc7c567f9c5eee Mon Sep 17 00:00:00 2001 From: cloudhead Date: Sun, 3 Jul 2011 00:19:06 -0400 Subject: [PATCH 2/4] (minor) ws fixes --- lib/less/tree/ruleset.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/less/tree/ruleset.js b/lib/less/tree/ruleset.js index 246200fa..3ba1c135 100644 --- a/lib/less/tree/ruleset.js +++ b/lib/less/tree/ruleset.js @@ -172,37 +172,36 @@ tree.Ruleset.prototype = { return css.join('') + (env.compress ? '\n' : ''); }, - joinSelectors: function( paths, context, selectors ) { + joinSelectors: function (paths, context, selectors) { for (var s = 0; s < selectors.length; s++) { this.joinSelector(paths, context, selectors[s]); } }, - joinSelector: function( paths, context, selector ) { - var before = [], after = [], beforeElements = [], afterElements = [], hasParentSelector = false, el; + joinSelector: function (paths, context, selector) { + var before = [], after = [], beforeElements = [], + afterElements = [], hasParentSelector = false, el; for (var i = 0; i < selector.elements.length; i++) { el = selector.elements[i]; if (el.combinator.value[0] === '&') { hasParentSelector = true; } - if(!hasParentSelector) { - beforeElements.push(el); - } else { - afterElements.push(el); - } + if (hasParentSelector) afterElements.push(el); + else beforeElements.push(el); } - if(!hasParentSelector) { + if (! hasParentSelector) { afterElements = beforeElements; beforeElements = []; } - if(beforeElements.length > 0) { - before.push(new (tree.Selector)(beforeElements)); + if (beforeElements.length > 0) { + before.push(new(tree.Selector)(beforeElements)); } - if(afterElements.length > 0) { - after.push(new (tree.Selector)(afterElements)); + + if (afterElements.length > 0) { + after.push(new(tree.Selector)(afterElements)); } for (var c = 0; c < context.length; c++) { From f38e64400857f5c43fd0cd2de9388b076ce68eb6 Mon Sep 17 00:00:00 2001 From: Ian Beck Date: Thu, 10 Mar 2011 11:26:19 -0800 Subject: [PATCH 3/4] add support for @keyframes blocks --- lib/less/parser.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/less/parser.js b/lib/less/parser.js index e828c23c..8ca4e610 100644 --- a/lib/less/parser.js +++ b/lib/less/parser.js @@ -787,7 +787,7 @@ less.Parser = function Parser(env) { var e, t, c; c = $(this.combinator); - e = $(/^(?:[.#]?|:*)(?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/) || $('*') || $(this.attribute) || $(/^\([^)@]+\)/); + e = $(/^(?:[.#]?|:*)(?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/) || $('*') || $(this.attribute) || $(/^\([^)@]+\)/) || $(/^(?:\d*\.)?\d+%/); if (e) { return new(tree.Element)(c, e) } @@ -889,7 +889,7 @@ less.Parser = function Parser(env) { var selectors = [], s, rules, match; save(); - if (match = /^([.#: \w-]+)[\s\n]*\{/.exec(chunks[j])) { + if (match = /^([.#:% \w-]+)[\s\n]*\{/.exec(chunks[j])) { i += match[0].length - 1; selectors = [new(tree.Selector)([new(tree.Element)(null, match[1])])]; } else { @@ -966,7 +966,7 @@ less.Parser = function Parser(env) { if (value = $(this['import'])) { return value; - } else if (name = $(/^@media|@page|@-[-a-z]+/)) { + } else if (name = $(/^@media|@page/) || $(/^@(?:-webkit-)?keyframes/)) { types = ($(/^[^{]+/) || '').trim(); if (rules = $(this.block)) { return new(tree.Directive)(name + " " + types, rules); From 15d6127ccd33ddbdcd950444cc8ce8c2f479427a Mon Sep 17 00:00:00 2001 From: cloudhead Date: Tue, 19 Jul 2011 19:09:30 -0400 Subject: [PATCH 4/4] (dist) 1.1.4 --- dist/{less-1.0.44.js => less-1.1.4.js} | 204 +++++++++++++++++++------ dist/less-1.1.4.min.js | 16 ++ package.json | 4 +- 3 files changed, 177 insertions(+), 47 deletions(-) rename dist/{less-1.0.44.js => less-1.1.4.js} (93%) create mode 100644 dist/less-1.1.4.min.js diff --git a/dist/less-1.0.44.js b/dist/less-1.1.4.js similarity index 93% rename from dist/less-1.0.44.js rename to dist/less-1.1.4.js index 2dceb48c..cb27c431 100644 --- a/dist/less-1.0.44.js +++ b/dist/less-1.1.4.js @@ -1,8 +1,8 @@ // -// LESS - Leaner CSS v1.0.44 +// LESS - Leaner CSS v1.1.4 // http://lesscss.org // -// Copyright (c) 2010, Alexis Sellier +// Copyright (c) 2009-2011, Alexis Sellier // Licensed under the Apache 2.0 License. // (function (window, undefined) { @@ -592,11 +592,15 @@ less.Parser = function Parser(env) { // "milky way" 'he\'s the one!' // quoted: function () { - var str; - if (input.charAt(i) !== '"' && input.charAt(i) !== "'") return; + var str, j = i, e; + + if (input.charAt(j) === '~') { j++, e = true } // Escaped strings + if (input.charAt(j) !== '"' && input.charAt(j) !== "'") return; + + e && $('~'); if (str = $(/^"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/)) { - return new(tree.Quoted)(str[0], str[1] || str[2]); + return new(tree.Quoted)(str[0], str[1] || str[2], e); } }, @@ -621,7 +625,7 @@ less.Parser = function Parser(env) { // The arguments are parsed with the `entities.arguments` parser. // call: function () { - var name, args; + var name, args, index = i; if (! (name = /^([\w-]+|%)\(/.exec(chunks[j]))) return; @@ -638,7 +642,7 @@ less.Parser = function Parser(env) { if (! $(')')) return; - if (name) { return new(tree.Call)(name, args) } + if (name) { return new(tree.Call)(name, args, index) } }, arguments: function () { var args = [], arg; @@ -667,7 +671,7 @@ less.Parser = function Parser(env) { if (input.charAt(i) !== 'u' || !$(/^url\(/)) return; value = $(this.entities.quoted) || $(this.entities.variable) || - $(this.entities.dataURI) || $(/^[-\w%@$\/.&=:;#+?]+/) || ""; + $(this.entities.dataURI) || $(/^[-\w%@$\/.&=:;#+?~]+/) || ""; if (! $(')')) throw new(Error)("missing closing ) for url()"); return new(tree.URL)((value.value || value.data || value instanceof tree.Variable) @@ -699,7 +703,7 @@ less.Parser = function Parser(env) { variable: function () { var name, index = i; - if (input.charAt(i) === '@' && (name = $(/^@[\w-]+/))) { + if (input.charAt(i) === '@' && (name = $(/^@@?[\w-]+/))) { return new(tree.Variable)(name, index); } }, @@ -739,12 +743,15 @@ less.Parser = function Parser(env) { // `window.location.href` // javascript: function () { - var str; + var str, j = i, e; - if (input.charAt(i) !== '`') { return } + if (input.charAt(j) === '~') { j++, e = true } // Escaped strings + if (input.charAt(j) !== '`') { return } + + e && $('~'); if (str = $(/^`([^`]*)`/)) { - return new(tree.JavaScript)(str[1], i); + return new(tree.JavaScript)(str[1], i, e); } } }, @@ -892,7 +899,7 @@ less.Parser = function Parser(env) { alpha: function () { var value; - if (! $(/^opacity=/i)) return; + if (! $(/^\(opacity=/i)) return; if (value = $(/^\d+/) || $(this.entities.variable)) { if (! $(')')) throw new(Error)("missing closing ) for alpha()"); return new(tree.Alpha)(value); @@ -915,9 +922,13 @@ less.Parser = function Parser(env) { var e, t, c; c = $(this.combinator); - e = $(/^(?:[.#]?|:*)(?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/) || $('*') || $(this.attribute) || $(/^\([^)@]+\)/); + e = $(/^(?:[.#]?|:*)(?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/) || $('*') || $(this.attribute) || $(/^\([^)@]+\)/) || $(/^(?:\d*\.)?\d+%/); if (e) { return new(tree.Element)(c, e) } + + if (c.value && c.value[0] === '&') { + return new(tree.Element)(c, null); + } }, // @@ -932,10 +943,18 @@ less.Parser = function Parser(env) { combinator: function () { var match, c = input.charAt(i); - if (c === '>' || c === '&' || c === '+' || c === '~') { + if (c === '>' || c === '+' || c === '~') { i++; while (input.charAt(i) === ' ') { i++ } return new(tree.Combinator)(c); + } else if (c === '&') { + match = '&'; + i++; + if(input.charAt(i) === ' ') { + match = '& '; + } + while (input.charAt(i) === ' ') { i++ } + return new(tree.Combinator)(match); } else if (c === ':' && input.charAt(i + 1) === ':') { i += 2; while (input.charAt(i) === ' ') { i++ } @@ -1005,7 +1024,7 @@ less.Parser = function Parser(env) { var selectors = [], s, rules, match; save(); - if (match = /^([.#: \w-]+)[\s\n]*\{/.exec(chunks[j])) { + if (match = /^([.#:% \w-]+)[\s\n]*\{/.exec(chunks[j])) { i += match[0].length - 1; selectors = [new(tree.Selector)([new(tree.Element)(null, match[1])])]; } else { @@ -1082,7 +1101,7 @@ less.Parser = function Parser(env) { if (value = $(this['import'])) { return value; - } else if (name = $(/^@media|@page|@-[-a-z]+/)) { + } else if (name = $(/^@media|@page/) || $(/^@(?:-webkit-)?keyframes/)) { types = ($(/^[^{]+/) || '').trim(); if (rules = $(this.block)) { return new(tree.Directive)(name + " " + types, rules); @@ -1408,7 +1427,10 @@ tree.Alpha.prototype = { return "alpha(opacity=" + (this.value.toCSS ? this.value.toCSS() : this.value) + ")"; }, - eval: function () { return this } + eval: function (env) { + if (this.value.eval) { this.value = this.value.eval(env) } + return this; + } }; })(require('less/tree')); @@ -1430,9 +1452,10 @@ tree.Anonymous.prototype = { // // A function call node. // -tree.Call = function (name, args) { +tree.Call = function (name, args, index) { this.name = name; this.args = args; + this.index = index; }; tree.Call.prototype = { // @@ -1451,7 +1474,12 @@ tree.Call.prototype = { var args = this.args.map(function (a) { return a.eval(env) }); if (this.name in tree.functions) { // 1. - return tree.functions[this.name].apply(tree.functions, args); + try { + return tree.functions[this.name].apply(tree.functions, args); + } catch (e) { + throw { message: "error evaluating function `" + this.name + "`", + index: this.index }; + } } else { // 2. return new(tree.Anonymous)(this.name + "(" + args.map(function (a) { return a.toCSS() }).join(', ') + ")"); @@ -1648,7 +1676,7 @@ tree.Directive.prototype = { tree.Element = function (combinator, value) { this.combinator = combinator instanceof tree.Combinator ? combinator : new(tree.Combinator)(combinator); - this.value = value.trim(); + this.value = value ? value.trim() : ""; }; tree.Element.prototype.toCSS = function (env) { return this.combinator.toCSS(env || {}) + this.value; @@ -1657,6 +1685,8 @@ tree.Element.prototype.toCSS = function (env) { tree.Combinator = function (value) { if (value === ' ') { this.value = ' '; + } else if (value === '& ') { + this.value = '& '; } else { this.value = value ? value.trim() : ""; } @@ -1666,6 +1696,7 @@ tree.Combinator.prototype.toCSS = function (env) { '' : '', ' ' : ' ', '&' : '', + '& ' : ' ', ':' : ' :', '::': '::', '+' : env.compress ? '+' : ' + ', @@ -1684,8 +1715,10 @@ tree.Expression.prototype = { return new(tree.Expression)(this.value.map(function (e) { return e.eval(env); })); - } else { + } else if (this.value.length === 1) { return this.value[0].eval(env); + } else { + return this; } }, toCSS: function (env) { @@ -1775,19 +1808,28 @@ tree.Import.prototype = { })(require('less/tree')); (function (tree) { -tree.JavaScript = function (string, index) { +tree.JavaScript = function (string, index, escaped) { + this.escaped = escaped; this.expression = string; this.index = index; }; tree.JavaScript.prototype = { - toCSS: function () { - return JSON.stringify(this.evaluated); - }, eval: function (env) { var result, - expression = new(Function)('return (' + this.expression + ')'), + that = this, context = {}; + var expression = this.expression.replace(/@\{([\w-]+)\}/g, function (_, name) { + return tree.jsify(new(tree.Variable)('@' + name, that.index).eval(env)); + }); + + try { + expression = new(Function)('return (' + expression + ')'); + } catch (e) { + throw { message: "JavaScript evaluation error: `" + expression + "`" , + index: this.index }; + } + for (var k in env.frames[0].variables()) { context[k.slice(1)] = { value: env.frames[0].variables()[k].value, @@ -1798,12 +1840,18 @@ tree.JavaScript.prototype = { } try { - this.evaluated = expression.call(context); + result = expression.call(context); } catch (e) { throw { message: "JavaScript evaluation error: '" + e.name + ': ' + e.message + "'" , index: this.index }; } - return this; + if (typeof(result) === 'string') { + return new(tree.Quoted)('"' + result + '"', result, this.escaped, this.index); + } else if (Array.isArray(result)) { + return new(tree.Anonymous)(result.join(', ')); + } else { + return new(tree.Anonymous)(result); + } } }; @@ -1828,12 +1876,13 @@ tree.mixin.Call = function (elements, args, index) { }; tree.mixin.Call.prototype = { eval: function (env) { - var mixins, rules = [], match = false; + var mixins, args, rules = [], match = false; for (var i = 0; i < env.frames.length; i++) { if ((mixins = env.frames[i].find(this.selector)).length > 0) { + args = this.arguments && this.arguments.map(function (a) { return a.eval(env) }); for (var m = 0; m < mixins.length; m++) { - if (mixins[m].match(this.arguments, env)) { + if (mixins[m].match(args, env)) { try { Array.prototype.push.apply( rules, mixins[m].eval(env, this.arguments).rules); @@ -1882,7 +1931,7 @@ tree.mixin.Definition.prototype = { rulesets: function () { return this.parent.rulesets.apply(this) }, eval: function (env, args) { - var frame = new(tree.Ruleset)(null, []), context; + var frame = new(tree.Ruleset)(null, []), context, _arguments = []; for (var i = 0, val; i < this.params.length; i++) { if (this.params[i].name) { @@ -1894,7 +1943,10 @@ tree.mixin.Definition.prototype = { } } } - frame.rules.unshift(new(tree.Rule)('@arguments', new(tree.Expression)(args))); + for (var i = 0; i < Math.max(this.params.length, args && args.length); i++) { + _arguments.push(args[i] || this.params[i].value); + } + frame.rules.unshift(new(tree.Rule)('@arguments', new(tree.Expression)(_arguments).eval(env))); return new(tree.Ruleset)(null, this.rules.slice(0)).eval({ frames: [this, frame].concat(this.frames, env.frames) @@ -1954,16 +2006,29 @@ tree.operate = function (op, a, b) { })(require('less/tree')); (function (tree) { -tree.Quoted = function (str, content) { +tree.Quoted = function (str, content, escaped, i) { + this.escaped = escaped; this.value = content || ''; this.quote = str.charAt(0); + this.index = i; }; tree.Quoted.prototype = { toCSS: function () { - return this.quote + this.value + this.quote; + if (this.escaped) { + return this.value; + } else { + return this.quote + this.value + this.quote; + } }, - eval: function () { - return this; + eval: function (env) { + var that = this; + var value = this.value.replace(/`([^`]+)`/g, function (_, exp) { + return new(tree.JavaScript)(exp, that.index, true).eval(env).value; + }).replace(/@\{([\w-]+)\}/g, function (_, name) { + var v = new(tree.Variable)('@' + name, that.index).eval(env); + return v.value || v.toCSS(); + }); + return new(tree.Quoted)(this.quote + value + this.quote, value, this.escaped, this.index); } }; @@ -2128,11 +2193,7 @@ tree.Ruleset.prototype = { if (context.length === 0) { paths = this.selectors.map(function (s) { return [s] }); } else { - for (var s = 0; s < this.selectors.length; s++) { - for (var c = 0; c < context.length; c++) { - paths.push(context[c].concat([this.selectors[s]])); - } - } + this.joinSelectors( paths, context, this.selectors ); } } @@ -2182,6 +2243,43 @@ tree.Ruleset.prototype = { css.push(rulesets); return css.join('') + (env.compress ? '\n' : ''); + }, + + joinSelectors: function (paths, context, selectors) { + for (var s = 0; s < selectors.length; s++) { + this.joinSelector(paths, context, selectors[s]); + } + }, + + joinSelector: function (paths, context, selector) { + var before = [], after = [], beforeElements = [], + afterElements = [], hasParentSelector = false, el; + + for (var i = 0; i < selector.elements.length; i++) { + el = selector.elements[i]; + if (el.combinator.value[0] === '&') { + hasParentSelector = true; + } + if (hasParentSelector) afterElements.push(el); + else beforeElements.push(el); + } + + if (! hasParentSelector) { + afterElements = beforeElements; + beforeElements = []; + } + + if (beforeElements.length > 0) { + before.push(new(tree.Selector)(beforeElements)); + } + + if (afterElements.length > 0) { + after.push(new(tree.Selector)(afterElements)); + } + + for (var c = 0; c < context.length; c++) { + paths.push(before.concat(context[c]).concat(after)); + } } }; })(require('less/tree')); @@ -2220,7 +2318,7 @@ tree.URL = function (val, paths) { this.attrs = val; } else { // Add the base path if the URL is relative and we are in the browser - if (!/^(?:https?:\/|file:\/)?\//.test(val.value) && paths.length > 0 && typeof(window) !== 'undefined') { + if (!/^(?:https?:\/|file:\/|data:\/)?\//.test(val.value) && paths.length > 0 && typeof(window) !== 'undefined') { val.value = paths[0] + (val.value.charAt(0) === '/' ? val.value.slice(1) : val.value); } this.value = val; @@ -2269,13 +2367,17 @@ tree.Variable.prototype = { eval: function (env) { var variable, v, name = this.name; + if (name.indexOf('@@') == 0) { + name = '@' + new(tree.Variable)(name.slice(1)).eval(env).value; + } + if (variable = tree.find(env.frames, function (frame) { if (v = frame.variable(name)) { return v.value.eval(env); } })) { return variable } else { - throw { message: "variable " + this.name + " is undefined", + throw { message: "variable " + name + " is undefined", index: this.index }; } } @@ -2288,12 +2390,20 @@ require('less/tree').find = function (obj, fun) { } return null; }; +require('less/tree').jsify = function (obj) { + if (Array.isArray(obj.value) && (obj.value.length > 1)) { + return '[' + obj.value.map(function (v) { return v.toCSS(false) }).join(', ') + ']'; + } else { + return obj.toCSS(false); + } +}; // // browser.js - client-side engine // var isFileProtocol = (location.protocol === 'file:' || location.protocol === 'chrome:' || + location.protocol === 'chrome-extension:' || location.protocol === 'resource:'); less.env = less.env || (location.hostname == '127.0.0.1' || @@ -2412,7 +2522,11 @@ function loadStyleSheet(sheet, callback, reload, remaining) { // Stylesheets in IE don't always return the full path if (! /^(https?|file):/.test(href)) { - href = url.slice(0, url.lastIndexOf('/') + 1) + href; + if (href.charAt(0) == "/") { + href = window.location.protocol + "//" + window.location.host + href; + } else { + href = url.slice(0, url.lastIndexOf('/') + 1) + href; + } } xhr(sheet.href, sheet.type, function (data, lastModified) { diff --git a/dist/less-1.1.4.min.js b/dist/less-1.1.4.min.js new file mode 100644 index 00000000..182b526f --- /dev/null +++ b/dist/less-1.1.4.min.js @@ -0,0 +1,16 @@ +// +// LESS - Leaner CSS v1.1.4 +// http://lesscss.org +// +// Copyright (c) 2009-2011, Alexis Sellier +// Licensed under the Apache 2.0 License. +// +// +// LESS - Leaner CSS v1.1.4 +// http://lesscss.org +// +// Copyright (c) 2009-2011, Alexis Sellier +// Licensed under the Apache 2.0 License. +// +(function(a,b){function u(a,b){var c="less-error-message:"+o(b),e=["
    ",'
  • {0}
  • ',"
  • {current}
  • ",'
  • {2}
  • ',"
"].join("\n"),f=document.createElement("div"),g,h;f.id=c,f.className="less-error-message",h="

"+(a.message||"There is an error in your .less file")+"

"+'

'+b+" ",a.extract&&(h+="on line "+a.line+", column "+(a.column+1)+":

"+e.replace(/\[(-?\d)\]/g,function(b,c){return parseInt(a.line)+parseInt(c)||""}).replace(/\{(\d)\}/g,function(b,c){return a.extract[parseInt(c)]||""}).replace(/\{current\}/,a.extract[1].slice(0,a.column)+''+a.extract[1].slice(a.column)+"")),f.innerHTML=h,p([".less-error-message ul, .less-error-message li {","list-style-type: none;","margin-right: 15px;","padding: 4px 0;","margin: 0;","}",".less-error-message label {","font-size: 12px;","margin-right: 15px;","padding: 4px 0;","color: #cc7777;","}",".less-error-message pre {","color: #ee4444;","padding: 4px 0;","margin: 0;","display: inline-block;","}",".less-error-message pre.ctx {","color: #dd4444;","}",".less-error-message h3 {","font-size: 20px;","font-weight: bold;","padding: 15px 0 5px 0;","margin: 0;","}",".less-error-message a {","color: #10a","}",".less-error-message .error {","color: red;","font-weight: bold;","padding-bottom: 2px;","border-bottom: 1px dashed red;","}"].join("\n"),{title:"error-message"}),f.style.cssText=["font-family: Arial, sans-serif","border: 1px solid #e00","background-color: #eee","border-radius: 5px","-webkit-border-radius: 5px","-moz-border-radius: 5px","color: #e00","padding: 15px","margin-bottom: 15px"].join(";"),d.env=="development"&&(g=setInterval(function(){document.body&&(document.getElementById(c)?document.body.replaceChild(f,document.getElementById(c)):document.body.insertBefore(f,document.body.firstChild),clearInterval(g))},10))}function t(a){d.env=="development"&&typeof console!="undefined"&&console.log("less: "+a)}function s(a){return a&&a.parentNode.removeChild(a)}function r(){if(a.XMLHttpRequest)return new XMLHttpRequest;try{return new ActiveXObject("MSXML2.XMLHTTP.3.0")}catch(b){t("browser doesn't support AJAX.");return null}}function q(a,b,c,e){function i(b,c,d){b.status>=200&&b.status<300?c(b.responseText,b.getResponseHeader("Last-Modified")):typeof d=="function"&&d(b.status,a)}var g=r(),h=f?!1:d.async;typeof g.overrideMimeType=="function"&&g.overrideMimeType("text/css"),g.open("GET",a,h),g.setRequestHeader("Accept",b||"text/x-less, text/css; q=0.9, */*; q=0.5"),g.send(null),f?g.status===0?c(g.responseText):e(g.status,a):h?g.onreadystatechange=function(){g.readyState==4&&i(g,c,e)}:i(g,c,e)}function p(a,b,c){var d,e=b.href?b.href.replace(/\?.*$/,""):"",f="less:"+(b.title||o(e));(d=document.getElementById(f))===null&&(d=document.createElement("style"),d.type="text/css",d.media=b.media||"screen",d.id=f,document.getElementsByTagName("head")[0].appendChild(d));if(d.styleSheet)try{d.styleSheet.cssText=a}catch(h){throw new Error("Couldn't reassign styleSheet.cssText.")}else(function(a){d.childNodes.length>0?d.firstChild.nodeValue!==a.nodeValue&&d.replaceChild(a,d.firstChild):d.appendChild(a)})(document.createTextNode(a));c&&g&&(t("saving "+e+" to cache."),g.setItem(e,a),g.setItem(e+":timestamp",c))}function o(a){return a.replace(/^[a-z]+:\/\/?[^\/]+/,"").replace(/^\//,"").replace(/\?.*$/,"").replace(/\.[^\.\/]+$/,"").replace(/[^\.\w-]+/g,"-").replace(/\./g,":")}function n(b,c,e,f){var h=a.location.href.replace(/[#?].*$/,""),i=b.href.replace(/\?.*$/,""),j=g&&g.getItem(i),k=g&&g.getItem(i+":timestamp"),l={css:j,timestamp:k};/^(https?|file):/.test(i)||(i.charAt(0)=="/"?i=a.location.protocol+"//"+a.location.host+i:i=h.slice(0,h.lastIndexOf("/")+1)+i),q(b.href,b.type,function(a,g){if(!e&&l&&g&&(new Date(g)).valueOf()===(new Date(l.timestamp)).valueOf())p(l.css,b),c(null,b,{local:!0,remaining:f});else try{(new d.Parser({optimization:d.optimization,paths:[i.replace(/[\w\.-]+$/,"")],mime:b.type})).parse(a,function(a,d){if(a)return u(a,i);try{c(d,b,{local:!1,lastModified:g,remaining:f}),s(document.getElementById("less-error-message:"+o(i)))}catch(a){u(a,i)}})}catch(h){u(h,i)}},function(a,b){throw new Error("Couldn't load "+b+" ("+a+")")})}function m(a,b){for(var c=0;c>>0;for(var d=0;d>>0,c=Array(b),d=arguments[1];for(var e=0;e>>0,c=0;if(b===0&&arguments.length===1)throw new TypeError;if(arguments.length>=2)var d=arguments[1];else do{if(c in this){d=this[c++];break}if(++c>=b)throw new TypeError}while(!0);for(;c=b)return-1;c<0&&(c+=b);for(;ck&&(j[f]=j[f].slice(c-k),k=c)}function q(){j[f]=g,c=h,k=c}function p(){g=j[f],h=c,k=c}var b,c,f,g,h,i,j,k,l,m=this,n=function(){},o=this.imports={paths:a&&a.paths||[],queue:[],files:{},mime:a&&a.mime,push:function(b,c){var e=this;this.queue.push(b),d.Parser.importer(b,this.paths,function(a){e.queue.splice(e.queue.indexOf(b),1),e.files[b]=a,c(a),e.queue.length===0&&n()},a)}};this.env=a=a||{},this.optimization="optimization"in this.env?this.env.optimization:1,this.env.filename=this.env.filename||null;return l={imports:o,parse:function(d,g){var h,l,m,o,p,q,r=[],t,u=null;c=f=k=i=0,j=[],b=d.replace(/\r\n/g,"\n"),j=function(c){var d=0,e=/[^"'`\{\}\/\(\)]+/g,f=/\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g,g=0,h,i=c[0],j,k;for(var l=0,m,n;l0)throw{type:"Syntax",message:"Missing closing `}`",filename:a.filename};return c.map(function(a){return a.join("")})}([[]]),h=new e.Ruleset([],s(this.parsers.primary)),h.root=!0,h.toCSS=function(c){var d,f,g;return function(g,h){function n(a){return a?(b.slice(0,a).match(/\n/g)||"").length:null}var i=[];g=g||{},typeof h=="object"&&!Array.isArray(h)&&(h=Object.keys(h).map(function(a){var b=h[a];b instanceof e.Value||(b instanceof e.Expression||(b=new e.Expression([b])),b=new e.Value([b]));return new e.Rule("@"+a,b,!1,0)}),i=[new e.Ruleset(null,h)]);try{var j=c.call(this,{frames:i}).toCSS([],{compress:g.compress||!1})}catch(k){f=b.split("\n"),d=n(k.index);for(var l=k.index,m=-1;l>=0&&b.charAt(l)!=="\n";l--)m++;throw{type:k.type,message:k.message,filename:a.filename,index:k.index,line:typeof d=="number"?d+1:null,callLine:k.call&&n(k.call)+1,callExtract:f[n(k.call)],stack:k.stack,column:m,extract:[f[d-1],f[d],f[d+1]]}}return g.compress?j.replace(/(\s)+/g,"$1"):j}}(h.eval);if(c=0&&b.charAt(v)!=="\n";v--)w++;u={name:"ParseError",message:"Syntax Error on line "+p,index:c,filename:a.filename,line:p,column:w,extract:[q[p-2],q[p-1],q[p]]}}this.imports.queue.length>0?n=function(){g(u,h)}:g(u,h)},parsers:{primary:function(){var a,b=[];while((a=s(this.mixin.definition)||s(this.rule)||s(this.ruleset)||s(this.mixin.call)||s(this.comment)||s(this.directive))||s(/^[\s\n]+/))a&&b.push(a);return b},comment:function(){var a;if(b.charAt(c)==="/"){if(b.charAt(c+1)==="/")return new e.Comment(s(/^\/\/.*/),!0);if(a=s(/^\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/))return new e.Comment(a)}},entities:{quoted:function(){var a,d=c,f;b.charAt(d)==="~"&&(d++,f=!0);if(b.charAt(d)==='"'||b.charAt(d)==="'"){f&&s("~");if(a=s(/^"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/))return new e.Quoted(a[0],a[1]||a[2],f)}},keyword:function(){var a;if(a=s(/^[A-Za-z-]+/))return new e.Keyword(a)},call:function(){var a,b,d=c;if(!!(a=/^([\w-]+|%)\(/.exec(j[f]))){a=a[1].toLowerCase();if(a==="url")return null;c+=a.length;if(a==="alpha")return s(this.alpha);s("("),b=s(this.entities.arguments);if(!s(")"))return;if(a)return new e.Call(a,b,d)}},arguments:function(){var a=[],b;while(b=s(this.expression)){a.push(b);if(!s(","))break}return a},literal:function(){return s(this.entities.dimension)||s(this.entities.color)||s(this.entities.quoted)},url:function(){var a;if(b.charAt(c)==="u"&&!!s(/^url\(/)){a=s(this.entities.quoted)||s(this.entities.variable)||s(this.entities.dataURI)||s(/^[-\w%@$\/.&=:;#+?~]+/)||"";if(!s(")"))throw new Error("missing closing ) for url()");return new e.URL(a.value||a.data||a instanceof e.Variable?a:new e.Anonymous(a),o.paths)}},dataURI:function(){var a;if(s(/^data:/)){a={},a.mime=s(/^[^\/]+\/[^,;)]+/)||"",a.charset=s(/^;\s*charset=[^,;)]+/)||"",a.base64=s(/^;\s*base64/)||"",a.data=s(/^,\s*[^)]+/);if(a.data)return a}},variable:function(){var a,d=c;if(b.charAt(c)==="@"&&(a=s(/^@@?[\w-]+/)))return new e.Variable(a,d)},color:function(){var a;if(b.charAt(c)==="#"&&(a=s(/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})/)))return new e.Color(a[1])},dimension:function(){var a,d=b.charCodeAt(c);if(!(d>57||d<45||d===47))if(a=s(/^(-?\d*\.?\d+)(px|%|em|pc|ex|in|deg|s|ms|pt|cm|mm|rad|grad|turn)?/))return new e.Dimension(a[1],a[2])},javascript:function(){var a,d=c,f;b.charAt(d)==="~"&&(d++,f=!0);if(b.charAt(d)==="`"){f&&s("~");if(a=s(/^`([^`]*)`/))return new e.JavaScript(a[1],c,f)}}},variable:function(){var a;if(b.charAt(c)==="@"&&(a=s(/^(@[\w-]+)\s*:/)))return a[1]},shorthand:function(){var a,b;if(!!t(/^[@\w.%-]+\/[@\w.-]+/)&&(a=s(this.entity))&&s("/")&&(b=s(this.entity)))return new e.Shorthand(a,b)},mixin:{call:function(){var a=[],d,f,g,h=c,i=b.charAt(c);if(i==="."||i==="#"){while(d=s(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/))a.push(new e.Element(f,d)),f=s(">");s("(")&&(g=s(this.entities.arguments))&&s(")");if(a.length>0&&(s(";")||t("}")))return new e.mixin.Call(a,g,h)}},definition:function(){var a,d=[],f,g,h,i;if(!(b.charAt(c)!=="."&&b.charAt(c)!=="#"||t(/^[^{]*(;|})/)))if(f=s(/^([#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+)\s*\(/)){a=f[1];while(h=s(this.entities.variable)||s(this.entities.literal)||s(this.entities.keyword)){if(h instanceof e.Variable)if(s(":"))if(i=s(this.expression))d.push({name:h.name,value:i});else throw new Error("Expected value");else d.push({name:h.name});else d.push({value:h});if(!s(","))break}if(!s(")"))throw new Error("Expected )");g=s(this.block);if(g)return new e.mixin.Definition(a,d,g)}}},entity:function(){return s(this.entities.literal)||s(this.entities.variable)||s(this.entities.url)||s(this.entities.call)||s(this.entities.keyword)||s(this.entities.javascript)||s(this.comment)},end:function(){return s(";")||t("}")},alpha:function(){var a;if(!!s(/^\(opacity=/i))if(a=s(/^\d+/)||s(this.entities.variable)){if(!s(")"))throw new Error("missing closing ) for alpha()");return new e.Alpha(a)}},element:function(){var a,b,c;c=s(this.combinator),a=s(/^(?:[.#]?|:*)(?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)||s("*")||s(this.attribute)||s(/^\([^)@]+\)/)||s(/^(?:\d*\.)?\d+%/);if(a)return new e.Element(c,a);if(c.value&&c.value[0]==="&")return new e.Element(c,null)},combinator:function(){var a,d=b.charAt(c);if(d===">"||d==="+"||d==="~"){c++;while(b.charAt(c)===" ")c++;return new e.Combinator(d)}if(d==="&"){a="&",c++,b.charAt(c)===" "&&(a="& ");while(b.charAt(c)===" ")c++;return new e.Combinator(a)}if(d===":"&&b.charAt(c+1)===":"){c+=2;while(b.charAt(c)===" ")c++;return new e.Combinator("::")}return b.charAt(c-1)===" "?new e.Combinator(" "):new e.Combinator(null)},selector:function(){var a,d,f=[],g,h;while(d=s(this.element)){g=b.charAt(c),f.push(d);if(g==="{"||g==="}"||g===";"||g===",")break}if(f.length>0)return new e.Selector(f)},tag:function(){return s(/^[a-zA-Z][a-zA-Z-]*[0-9]?/)||s("*")},attribute:function(){var a="",b,c,d;if(!!s("[")){if(b=s(/^[a-zA-Z-]+/)||s(this.entities.quoted))(d=s(/^[|~*$^]?=/))&&(c=s(this.entities.quoted)||s(/^[\w-]+/))?a=[b,d,c.toCSS?c.toCSS():c].join(""):a=b;if(!s("]"))return;if(a)return"["+a+"]"}},block:function(){var a;if(s("{")&&(a=s(this.primary))&&s("}"))return a},ruleset:function(){var a=[],b,d,g;p();if(g=/^([.#:% \w-]+)[\s\n]*\{/.exec(j[f]))c+=g[0].length-1,a=[new e.Selector([new e.Element(null,g[1])])];else while(b=s(this.selector)){a.push(b),s(this.comment);if(!s(","))break;s(this.comment)}if(a.length>0&&(d=s(this.block)))return new e.Ruleset(a,d);i=c,q()},rule:function(){var a,d,g=b.charAt(c),k,l;p();if(g!=="."&&g!=="#"&&g!=="&")if(a=s(this.variable)||s(this.property)){a.charAt(0)!="@"&&(l=/^([^@+\/'"*`(;{}-]*);/.exec(j[f]))?(c+=l[0].length-1,d=new e.Anonymous(l[1])):a==="font"?d=s(this.font):d=s(this.value),k=s(this.important);if(d&&s(this.end))return new e.Rule(a,d,k,h);i=c,q()}},"import":function(){var a;if(s(/^@import\s+/)&&(a=s(this.entities.quoted)||s(this.entities.url))&&s(";"))return new e.Import(a,o)},directive:function(){var a,d,f,g;if(b.charAt(c)==="@"){if(d=s(this["import"]))return d;if(a=s(/^@media|@page/)||s(/^@(?:-webkit-)?keyframes/)){g=(s(/^[^{]+/)||"").trim();if(f=s(this.block))return new e.Directive(a+" "+g,f)}else if(a=s(/^@[-a-z]+/))if(a==="@font-face"){if(f=s(this.block))return new e.Directive(a,f)}else if((d=s(this.entity))&&s(";"))return new e.Directive(a,d)}},font:function(){var a=[],b=[],c,d,f,g;while(g=s(this.shorthand)||s(this.entity))b.push(g);a.push(new e.Expression(b));if(s(","))while(g=s(this.expression)){a.push(g);if(!s(","))break}return new e.Value(a)},value:function(){var a,b=[],c;while(a=s(this.expression)){b.push(a);if(!s(","))break}if(b.length>0)return new e.Value(b)},important:function(){if(b.charAt(c)==="!")return s(/^! *important/)},sub:function(){var a;if(s("(")&&(a=s(this.expression))&&s(")"))return a},multiplication:function(){var a,b,c,d;if(a=s(this.operand)){while((c=s("/")||s("*"))&&(b=s(this.operand)))d=new e.Operation(c,[d||a,b]);return d||a}},addition:function(){var a,d,f,g;if(a=s(this.multiplication)){while((f=s(/^[-+]\s+/)||b.charAt(c-1)!=" "&&(s("+")||s("-")))&&(d=s(this.multiplication)))g=new e.Operation(f,[g||a,d]);return g||a}},operand:function(){var a,d=b.charAt(c+1);b.charAt(c)==="-"&&(d==="@"||d==="(")&&(a=s("-"));var f=s(this.sub)||s(this.entities.dimension)||s(this.entities.color)||s(this.entities.variable)||s(this.entities.call);return a?new e.Operation("*",[new e.Dimension(-1),f]):f},expression:function(){var a,b,c=[],d;while(a=s(this.addition)||s(this.entity))c.push(a);if(c.length>0)return new e.Expression(c)},property:function(){var a;if(a=s(/^(\*?-?[-a-z_0-9]+)\s*:/))return a[1]}}}},typeof a!="undefined"&&(d.Parser.importer=function(a,b,c,d){a.charAt(0)!=="/"&&b.length>0&&(a=b[0]+a),n({href:a,title:a,type:d.mime},c,!0)}),function(a){function d(a){return Math.min(1,Math.max(0,a))}function c(b){if(b instanceof a.Dimension)return parseFloat(b.unit=="%"?b.value/100:b.value);if(typeof b=="number")return b;throw{error:"RuntimeError",message:"color functions take numbers as parameters"}}function b(b){return a.functions.hsla(b.h,b.s,b.l,b.a)}a.functions={rgb:function(a,b,c){return this.rgba(a,b,c,1)},rgba:function(b,d,e,f){var g=[b,d,e].map(function(a){return c(a)}),f=c(f);return new a.Color(g,f)},hsl:function(a,b,c){return this.hsla(a,b,c,1)},hsla:function(a,b,d,e){function h(a){a=a<0?a+1:a>1?a-1:a;return a*6<1?g+(f-g)*a*6:a*2<1?f:a*3<2?g+(f-g)*(2/3-a)*6:g}a=c(a)%360/360,b=c(b),d=c(d),e=c(e);var f=d<=.5?d*(b+1):d+b-d*b,g=d*2-f;return this.rgba(h(a+1/3)*255,h(a)*255,h(a-1/3)*255,e)},hue:function(b){return new a.Dimension(Math.round(b.toHSL().h))},saturation:function(b){return new a.Dimension(Math.round(b.toHSL().s*100),"%")},lightness:function(b){return new a.Dimension(Math.round(b.toHSL().l*100),"%")},alpha:function(b){return new a.Dimension(b.toHSL().a)},saturate:function(a,c){var e=a.toHSL();e.s+=c.value/100,e.s=d(e.s);return b(e)},desaturate:function(a,c){var e=a.toHSL();e.s-=c.value/100,e.s=d(e.s);return b(e)},lighten:function(a,c){var e=a.toHSL();e.l+=c.value/100,e.l=d(e.l);return b(e)},darken:function(a,c){var e=a.toHSL();e.l-=c.value/100,e.l=d(e.l);return b(e)},fadein:function(a,c){var e=a.toHSL();e.a+=c.value/100,e.a=d(e.a);return b(e)},fadeout:function(a,c){var e=a.toHSL();e.a-=c.value/100,e.a=d(e.a);return b(e)},spin:function(a,c){var d=a.toHSL(),e=(d.h+c.value)%360;d.h=e<0?360+e:e;return b(d)},mix:function(b,c,d){var e=d.value/100,f=e*2-1,g=b.toHSL().a-c.toHSL().a,h=((f*g==-1?f:(f+g)/(1+f*g))+1)/2,i=1-h,j=[b.rgb[0]*h+c.rgb[0]*i,b.rgb[1]*h+c.rgb[1]*i,b.rgb[2]*h+c.rgb[2]*i],k=b.alpha*e+c.alpha*(1-e);return new a.Color(j,k)},greyscale:function(b){return this.desaturate(b,new a.Dimension(100))},e:function(b){return new a.Anonymous(b instanceof a.JavaScript?b.evaluated:b)},escape:function(b){return new a.Anonymous(encodeURI(b.value).replace(/=/g,"%3D").replace(/:/g,"%3A").replace(/#/g,"%23").replace(/;/g,"%3B").replace(/\(/g,"%28").replace(/\)/g,"%29"))},"%":function(b){var c=Array.prototype.slice.call(arguments,1),d=b.value;for(var e=0;e255?255:a<0?0:a).toString(16);return a.length===1?"0"+a:a}).join("")},operate:function(b,c){var d=[];c instanceof a.Color||(c=c.toColor());for(var e=0;e<3;e++)d[e]=a.operate(b,this.rgb[e],c.rgb[e]);return new a.Color(d,this.alpha+c.alpha)},toHSL:function(){var a=this.rgb[0]/255,b=this.rgb[1]/255,c=this.rgb[2]/255,d=this.alpha,e=Math.max(a,b,c),f=Math.min(a,b,c),g,h,i=(e+f)/2,j=e-f;if(e===f)g=h=0;else{h=i>.5?j/(2-e-f):j/(e+f);switch(e){case a:g=(b-c)/j+(b":a.compress?">":" > "}[this.value]}}(c("less/tree")),function(a){a.Expression=function(a){this.value=a},a.Expression.prototype={eval:function(b){return this.value.length>1?new a.Expression(this.value.map(function(a){return a.eval(b)})):this.value.length===1?this.value[0].eval(b):this},toCSS:function(a){return this.value.map(function(b){return b.toCSS(a)}).join(" ")}}}(c("less/tree")),function(a){a.Import=function(b,c){var d=this;this._path=b,b instanceof a.Quoted?this.path=/\.(le?|c)ss$/.test(b.value)?b.value:b.value+".less":this.path=b.value.value||b.value,this.css=/css$/.test(this.path),this.css||c.push(this.path,function(a){if(!a)throw new Error("Error parsing "+d.path);d.root=a})},a.Import.prototype={toCSS:function(){return this.css?"@import "+this._path.toCSS()+";\n":""},eval:function(b){var c;if(this.css)return this;c=new a.Ruleset(null,this.root.rules.slice(0));for(var d=0;d0){c=this.arguments&&this.arguments.map(function(b){return b.eval(a)});for(var g=0;g0&&c>this.params.length)return!1;d=Math.min(c,this.arity);for(var e=0;e1?Array.prototype.push.apply(d,e.find(new a.Selector(b.elements.slice(1)),c)):d.push(e);break}});return this._lookups[g]=d},toCSS:function(b,c){var d=[],e=[],f=[],g=[],h,i;this.root||(b.length===0?g=this.selectors.map(function(a){return[a]}):this.joinSelectors(g,b,this.selectors));for(var j=0;j0&&(h=g.map(function(a){return a.map(function(a){return a.toCSS(c)}).join("").trim()}).join(c.compress?",":g.length>3?",\n":", "),d.push(h,(c.compress?"{":" {\n ")+e.join(c.compress?"":"\n ")+(c.compress?"}":"\n}\n"))),d.push(f);return d.join("")+(c.compress?"\n":"")},joinSelectors:function(a,b,c){for(var d=0;d0&&e.push(new a.Selector(g)),h.length>0&&f.push(new a.Selector(h));for(var l=0;l0&&typeof a!="undefined"&&(b.value=c[0]+(b.value.charAt(0)==="/"?b.value.slice(1):b.value)),this.value=b,this.paths=c)},b.URL.prototype={toCSS:function(){return"url("+(this.attrs?"data:"+this.attrs +.mime+this.attrs.charset+this.attrs.base64+this.attrs.data:this.value.toCSS())+")"},eval:function(a){return this.attrs?this:new b.URL(this.value.eval(a),this.paths)}}}(c("less/tree")),function(a){a.Value=function(a){this.value=a,this.is="value"},a.Value.prototype={eval:function(b){return this.value.length===1?this.value[0].eval(b):new a.Value(this.value.map(function(a){return a.eval(b)}))},toCSS:function(a){return this.value.map(function(b){return b.toCSS(a)}).join(a.compress?",":", ")}}}(c("less/tree")),function(a){a.Variable=function(a,b){this.name=a,this.index=b},a.Variable.prototype={eval:function(b){var c,d,e=this.name;e.indexOf("@@")==0&&(e="@"+(new a.Variable(e.slice(1))).eval(b).value);if(c=a.find(b.frames,function(a){if(d=a.variable(e))return d.value.eval(b)}))return c;throw{message:"variable "+e+" is undefined",index:this.index}}}}(c("less/tree")),c("less/tree").find=function(a,b){for(var c=0,d;c1?"["+a.value.map(function(a){return a.toCSS(!1)}).join(", ")+"]":a.toCSS(!1)};var f=location.protocol==="file:"||location.protocol==="chrome:"||location.protocol==="chrome-extension:"||location.protocol==="resource:";d.env=d.env||(location.hostname=="127.0.0.1"||location.hostname=="0.0.0.0"||location.hostname=="localhost"||location.port.length>0||f?"development":"production"),d.async=!1,d.poll=d.poll||(f?1e3:1500),d.watch=function(){return this.watchMode=!0},d.unwatch=function(){return this.watchMode=!1},d.env==="development"?(d.optimization=0,/!watch/.test(location.hash)&&d.watch(),d.watchTimer=setInterval(function(){d.watchMode&&m(function(a,b,c){a&&p(a.toCSS(),b,c.lastModified)})},d.poll)):d.optimization=3;var g;try{g=typeof a.localStorage=="undefined"?null:a.localStorage}catch(h){g=null}var i=document.getElementsByTagName("link"),j=/^text\/(x-)?less$/;d.sheets=[];for(var k=0;k", "contributors" : [], - "version" : "1.1.3", + "version" : "1.1.4", "bin" : { "lessc": "./bin/lessc" }, "main" : "./lib/less/index", "directories" : { "test": "./test" }, - "engines" : { "node": ">=0.2.0" } + "engines" : { "node": ">=0.4.0" } }