less
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -5,5 +5,3 @@ var path = require('path'), | ||
require.paths.unshift(__dirname, path.join(__dirname, '..')); | ||
var less = require('lib/less'); | ||
var less = require('../lib/less'); | ||
var file = path.join(__dirname, 'benchmark.less'); | ||
@@ -10,0 +8,0 @@ |
@@ -104,4 +104,10 @@ // | ||
new(less.Parser)().parse(styles[i].innerHTML || '', function (e, tree) { | ||
styles[i].type = 'text/css'; | ||
styles[i].innerHTML = tree.toCSS(); | ||
var css = tree.toCSS(); | ||
var style = styles[i]; | ||
try { | ||
style.innerHTML = css; | ||
} catch (_) { | ||
style.styleSheets.cssText = css; | ||
} | ||
style.type = 'text/css'; | ||
}); | ||
@@ -108,0 +114,0 @@ } |
@@ -89,2 +89,9 @@ (function (tree) { | ||
}, | ||
fade: function (color, amount) { | ||
var hsl = color.toHSL(); | ||
hsl.a = amount.value / 100; | ||
hsl.a = clamp(hsl.a); | ||
return hsla(hsl); | ||
}, | ||
spin: function (color, amount) { | ||
@@ -151,2 +158,6 @@ var hsl = color.toHSL(); | ||
} | ||
}, | ||
argb: function (color) { | ||
return new(tree.Anonymous)(color.toARGB()); | ||
} | ||
@@ -176,2 +187,2 @@ }; | ||
})(require('less/tree')); | ||
})(require('./tree')); |
var path = require('path'), | ||
sys = require('sys'), | ||
sys = require('util'), | ||
fs = require('fs'); | ||
require.paths.unshift(path.join(__dirname, '..')); | ||
var less = { | ||
version: [1, 1, 3], | ||
Parser: require('less/parser').Parser, | ||
importer: require('less/parser').importer, | ||
tree: require('less/tree'), | ||
version: [1, 1, 5], | ||
Parser: require('./parser').Parser, | ||
importer: require('./parser').importer, | ||
tree: require('./tree'), | ||
render: function (input, options, callback) { | ||
@@ -19,3 +17,3 @@ options = options || {}; | ||
var parser = new(this.Parser)(options), | ||
var parser = new(less.Parser)(options), | ||
ee; | ||
@@ -40,8 +38,9 @@ | ||
writeError: function (ctx, options) { | ||
options = options || {}; | ||
var message = ""; | ||
var extract = ctx.extract; | ||
var error = []; | ||
var stylize = options.color ? less.stylize : function (str) { return str }; | ||
options = options || {}; | ||
if (options.silent) { return } | ||
@@ -85,3 +84,3 @@ | ||
].forEach(function (n) { | ||
require(path.join('less', 'tree', n)); | ||
require('./tree/' + n); | ||
}); | ||
@@ -109,3 +108,3 @@ | ||
new(less.Parser)({ | ||
paths: [path.dirname(pathname)], | ||
paths: [path.dirname(pathname)].concat(paths), | ||
filename: pathname | ||
@@ -123,3 +122,3 @@ }).parse(data, function (e, root) { | ||
require('less/functions'); | ||
require('./functions'); | ||
@@ -142,2 +141,3 @@ for (var k in less) { exports[k] = less[k] } | ||
} | ||
less.stylize = stylize; | ||
var less, tree; | ||
if (typeof(window) === 'undefined') { | ||
if (typeof environment === "object" && ({}).toString.call(environment) === "[object Environment]") { | ||
// Rhino | ||
// Details on how to detect Rhino: https://github.com/ringo/ringojs/issues/88 | ||
less = {}; | ||
tree = less.tree = {}; | ||
less.mode = 'rhino'; | ||
} else if (typeof(window) === 'undefined') { | ||
// Node.js | ||
less = exports, | ||
tree = require('less/tree'); | ||
tree = require('./tree'); | ||
less.mode = 'rhino'; | ||
} else { | ||
// Browser | ||
if (typeof(window.less) === 'undefined') { window.less = {} } | ||
less = window.less, | ||
tree = window.less.tree = {}; | ||
less.mode = 'browser'; | ||
} | ||
@@ -479,3 +489,3 @@ // | ||
var k; | ||
if (k = $(/^[A-Za-z-]+/)) { return new(tree.Keyword)(k) } | ||
if (k = $(/^[_A-Za-z-][_A-Za-z0-9-]*/)) { return new(tree.Keyword)(k) } | ||
}, | ||
@@ -674,3 +684,3 @@ | ||
while (e = $(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) { | ||
elements.push(new(tree.Element)(c, e)); | ||
elements.push(new(tree.Element)(c, e, i)); | ||
c = $('>'); | ||
@@ -792,8 +802,9 @@ } | ||
c = $(this.combinator); | ||
e = $(/^(?:[.#]?|:*)(?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/) || $('*') || $(this.attribute) || $(/^\([^)@]+\)/) || $(/^(?:\d*\.)?\d+%/); | ||
e = $(/^(?:\d+\.\d+|\d+)%/) || $(/^(?:[.#]?|:*)(?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/) || | ||
$('*') || $(this.attribute) || $(/^\([^)@]+\)/); | ||
if (e) { return new(tree.Element)(c, e) } | ||
if (e) { return new(tree.Element)(c, e, i) } | ||
if (c.value && c.value[0] === '&') { | ||
return new(tree.Element)(c, null); | ||
if (c.value && c.value.charAt(0) === '&') { | ||
return new(tree.Element)(c, null, i); | ||
} | ||
@@ -895,12 +906,7 @@ }, | ||
if (match = /^([.#:% \w-]+)[\s\n]*\{/.exec(chunks[j])) { | ||
i += match[0].length - 1; | ||
selectors = [new(tree.Selector)([new(tree.Element)(null, match[1])])]; | ||
} else { | ||
while (s = $(this.selector)) { | ||
selectors.push(s); | ||
$(this.comment); | ||
if (! $(',')) { break } | ||
$(this.comment); | ||
} | ||
while (s = $(this.selector)) { | ||
selectors.push(s); | ||
$(this.comment); | ||
if (! $(',')) { break } | ||
$(this.comment); | ||
} | ||
@@ -973,3 +979,3 @@ | ||
return value; | ||
} else if (name = $(/^@media|@page/) || $(/^@(?:-webkit-)?keyframes/)) { | ||
} else if (name = $(/^@media|@page/) || $(/^@(?:-webkit-|-moz-)?keyframes/)) { | ||
types = ($(/^[^{]+/) || '').trim(); | ||
@@ -1101,3 +1107,3 @@ if (rules = $(this.block)) { | ||
if (typeof(window) !== 'undefined') { | ||
if (less.mode === 'browser' || less.mode === 'rhino') { | ||
// | ||
@@ -1104,0 +1110,0 @@ // Used by `@import` directives |
@@ -1,2 +0,2 @@ | ||
require('less/tree').find = function (obj, fun) { | ||
require('./tree').find = function (obj, fun) { | ||
for (var i = 0, r; i < obj.length; i++) { | ||
@@ -7,3 +7,3 @@ if (r = fun.call(obj, obj[i])) { return r } | ||
}; | ||
require('less/tree').jsify = function (obj) { | ||
require('./tree').jsify = function (obj) { | ||
if (Array.isArray(obj.value) && (obj.value.length > 1)) { | ||
@@ -10,0 +10,0 @@ return '[' + obj.value.map(function (v) { return v.toCSS(false) }).join(', ') + ']'; |
@@ -17,2 +17,2 @@ (function (tree) { | ||
})(require('less/tree')); | ||
})(require('../tree')); |
@@ -13,2 +13,2 @@ (function (tree) { | ||
})(require('less/tree')); | ||
})(require('../tree')); |
@@ -45,2 +45,2 @@ (function (tree) { | ||
})(require('less/tree')); | ||
})(require('../tree')); |
@@ -18,7 +18,2 @@ (function (tree) { | ||
}); | ||
} else if (rgb.length == 8) { | ||
this.alpha = parseInt(rgb.substring(0,2), 16) / 255.0; | ||
this.rgb = rgb.substr(2).match(/.{2}/g).map(function (c) { | ||
return parseInt(c, 16); | ||
}); | ||
} else { | ||
@@ -95,2 +90,10 @@ this.rgb = rgb.split('').map(function (c) { | ||
return { h: h * 360, s: s, l: l, a: a }; | ||
}, | ||
toARGB: function () { | ||
var argb = [Math.round(this.alpha * 255)].concat(this.rgb); | ||
return '#' + argb.map(function (i) { | ||
i = Math.round(i); | ||
i = (i > 255 ? 255 : (i < 0 ? 0 : i)).toString(16); | ||
return i.length === 1 ? '0' + i : i; | ||
}).join(''); | ||
} | ||
@@ -100,2 +103,2 @@ }; | ||
})(require('less/tree')); | ||
})(require('../tree')); |
@@ -14,2 +14,2 @@ (function (tree) { | ||
})(require('less/tree')); | ||
})(require('../tree')); |
@@ -34,2 +34,2 @@ (function (tree) { | ||
})(require('less/tree')); | ||
})(require('../tree')); |
@@ -33,2 +33,2 @@ (function (tree) { | ||
})(require('less/tree')); | ||
})(require('../tree')); |
(function (tree) { | ||
tree.Element = function (combinator, value) { | ||
tree.Element = function (combinator, value, index) { | ||
this.combinator = combinator instanceof tree.Combinator ? | ||
combinator : new(tree.Combinator)(combinator); | ||
this.value = value ? value.trim() : ""; | ||
this.index = index; | ||
}; | ||
@@ -35,2 +36,2 @@ tree.Element.prototype.toCSS = function (env) { | ||
})(require('less/tree')); | ||
})(require('../tree')); |
@@ -23,2 +23,2 @@ (function (tree) { | ||
})(require('less/tree')); | ||
})(require('../tree')); |
@@ -21,3 +21,3 @@ (function (tree) { | ||
if (path instanceof tree.Quoted) { | ||
this.path = /\.(le?|c)ss$/.test(path.value) ? path.value : path.value + '.less'; | ||
this.path = /\.(le?|c)ss(\?.*)?$/.test(path.value) ? path.value : path.value + '.less'; | ||
} else { | ||
@@ -27,3 +27,3 @@ this.path = path.value.value || path.value; | ||
this.css = /css$/.test(this.path); | ||
this.css = /css(\?.*)?$/.test(this.path); | ||
@@ -79,2 +79,2 @@ // Only pre-compile .less files | ||
})(require('less/tree')); | ||
})(require('../tree')); |
@@ -50,3 +50,3 @@ (function (tree) { | ||
})(require('less/tree')); | ||
})(require('../tree')); | ||
@@ -9,2 +9,2 @@ (function (tree) { | ||
})(require('less/tree')); | ||
})(require('../tree')); |
@@ -106,2 +106,2 @@ (function (tree) { | ||
})(require('less/tree')); | ||
})(require('../tree')); |
@@ -32,2 +32,2 @@ (function (tree) { | ||
})(require('less/tree')); | ||
})(require('../tree')); |
@@ -29,2 +29,2 @@ (function (tree) { | ||
})(require('less/tree')); | ||
})(require('../tree')); |
@@ -38,2 +38,2 @@ (function (tree) { | ||
})(require('less/tree')); | ||
})(require('../tree')); |
@@ -93,3 +93,3 @@ (function (tree) { | ||
if (match = selector.match(rule.selectors[j])) { | ||
if (selector.elements.length > 1) { | ||
if (selector.elements.length > rule.selectors[j].elements.length) { | ||
Array.prototype.push.apply(rules, rule.find( | ||
@@ -188,3 +188,3 @@ new(tree.Selector)(selector.elements.slice(1)), self)); | ||
el = selector.elements[i]; | ||
if (el.combinator.value[0] === '&') { | ||
if (el.combinator.value.charAt(0) === '&') { | ||
hasParentSelector = true; | ||
@@ -214,2 +214,2 @@ } | ||
}; | ||
})(require('less/tree')); | ||
})(require('../tree')); |
@@ -10,7 +10,16 @@ (function (tree) { | ||
tree.Selector.prototype.match = function (other) { | ||
if (this.elements[0].value === other.elements[0].value) { | ||
return true; | ||
var len = this.elements.length, | ||
olen = other.elements.length, | ||
max = Math.min(len, olen); | ||
if (len < olen) { | ||
return false; | ||
} else { | ||
return false; | ||
for (var i = 0; i < max; i++) { | ||
if (this.elements[i].value !== other.elements[i].value) { | ||
return false; | ||
} | ||
} | ||
} | ||
return true; | ||
}; | ||
@@ -29,2 +38,2 @@ tree.Selector.prototype.toCSS = function (env) { | ||
})(require('less/tree')); | ||
})(require('../tree')); |
@@ -8,3 +8,3 @@ (function (tree) { | ||
// Add the base path if the URL is relative and we are in the browser | ||
if (!/^(?:https?:\/|file:\/|data:\/)?\//.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); | ||
@@ -26,2 +26,2 @@ } | ||
})(require('less/tree')); | ||
})(require('../tree')); |
@@ -24,2 +24,2 @@ (function (tree) { | ||
})(require('less/tree')); | ||
})(require('../tree')); |
@@ -24,2 +24,2 @@ (function (tree) { | ||
})(require('less/tree')); | ||
})(require('../tree')); |
@@ -8,3 +8,3 @@ { | ||
"contributors" : [], | ||
"version" : "1.1.4", | ||
"version" : "1.1.5", | ||
"bin" : { "lessc": "./bin/lessc" }, | ||
@@ -11,0 +11,0 @@ "main" : "./lib/less/index", |
var path = require('path'), | ||
fs = require('fs'), | ||
sys = require('sys'); | ||
sys = require('util'); | ||
require.paths.unshift(__dirname, path.join(__dirname, '..')); | ||
var less = require('../lib/less'); | ||
var less = require('lib/less'); | ||
less.tree.functions.add = function (a, b) { | ||
@@ -10,0 +8,0 @@ return new(less.tree.Dimension)(a.value + b.value); |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
1167777
99
23198
0
10