mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
Removed Shorthand and Ratio parsers; Fixed some issues with paren depth state; Adjusted tests to pass on new output
This commit is contained in:
@@ -91,7 +91,7 @@ var less = {
|
||||
'call', 'url', 'alpha', 'import',
|
||||
'mixin', 'comment', 'anonymous', 'value',
|
||||
'javascript', 'assignment', 'condition', 'paren',
|
||||
'media', 'ratio', 'unicode-descriptor', 'extend'
|
||||
'media', 'unicode-descriptor', 'extend'
|
||||
].forEach(function (n) {
|
||||
require('./tree/' + n);
|
||||
});
|
||||
|
||||
@@ -606,7 +606,7 @@ less.Parser = function Parser(env) {
|
||||
nameLC = name.toLowerCase();
|
||||
|
||||
if (nameLC === 'url') { return null }
|
||||
else { i += name.length }
|
||||
else { i += name.length }
|
||||
|
||||
if (nameLC === 'alpha') {
|
||||
alpha_ret = $(this.alpha);
|
||||
@@ -620,7 +620,10 @@ less.Parser = function Parser(env) {
|
||||
|
||||
args = $(this.entities.arguments);
|
||||
|
||||
if (! $(')')) return;
|
||||
if (! $(')')) {
|
||||
parens--;
|
||||
return;
|
||||
}
|
||||
parens--;
|
||||
|
||||
if (name) { return new(tree.Call)(name, args, index, env.filename, env.rootpath) }
|
||||
@@ -635,8 +638,7 @@ less.Parser = function Parser(env) {
|
||||
return args;
|
||||
},
|
||||
literal: function () {
|
||||
return $(this.entities.ratio) ||
|
||||
$(this.entities.dimension) ||
|
||||
return $(this.entities.dimension) ||
|
||||
$(this.entities.color) ||
|
||||
$(this.entities.quoted) ||
|
||||
$(this.entities.unicodeDescriptor);
|
||||
@@ -730,20 +732,6 @@ less.Parser = function Parser(env) {
|
||||
}
|
||||
},
|
||||
|
||||
//
|
||||
// A Ratio
|
||||
//
|
||||
// 16/9
|
||||
//
|
||||
ratio: function () {
|
||||
var value, c = input.charCodeAt(i);
|
||||
if (c > 57 || c < 48) return;
|
||||
|
||||
if (value = $(/^(\d+\/\d+)/)) {
|
||||
return new(tree.Ratio)(value[1]);
|
||||
}
|
||||
},
|
||||
|
||||
//
|
||||
// A unicode descriptor, as is used in unicode-range
|
||||
//
|
||||
@@ -787,27 +775,6 @@ less.Parser = function Parser(env) {
|
||||
if (input.charAt(i) === '@' && (name = $(/^(@[\w-]+)\s*:/))) { return name[1] }
|
||||
},
|
||||
|
||||
//
|
||||
// A font size/line-height shorthand
|
||||
//
|
||||
// small/12px
|
||||
//
|
||||
// We need to peek first, or we'll match on keywords and dimensions
|
||||
//
|
||||
shorthand: function () {
|
||||
var a, b;
|
||||
|
||||
if (! peek(/^[@\w.%-]+\/[@\w.-]+/)) return;
|
||||
|
||||
save();
|
||||
|
||||
if ((a = $(this.entity)) && $('/') && (b = $(this.entity))) {
|
||||
return new(tree.Shorthand)(a, b);
|
||||
}
|
||||
|
||||
restore();
|
||||
},
|
||||
|
||||
//
|
||||
// extend syntax - used to extend selectors
|
||||
//
|
||||
@@ -1192,8 +1159,6 @@ less.Parser = function Parser(env) {
|
||||
if (!env.compress && (name.charAt(0) != '@') && (match = /^([^@+\/'"*`(;{}-]*);/.exec(chunks[j]))) {
|
||||
i += match[0].length - 1;
|
||||
value = new(tree.Anonymous)(match[1]);
|
||||
} else if (name === "font") {
|
||||
value = $(this.font);
|
||||
} else {
|
||||
value = $(this.value);
|
||||
}
|
||||
@@ -1244,7 +1209,7 @@ less.Parser = function Parser(env) {
|
||||
nodes.push(e);
|
||||
} else if ($('(')) {
|
||||
p = $(this.property);
|
||||
e = $(this.entity);
|
||||
e = $(this.value);
|
||||
if ($(')')) {
|
||||
if (p && e) {
|
||||
nodes.push(new(tree.Paren)(new(tree.Rule)(p, e, null, i, true)));
|
||||
@@ -1378,22 +1343,6 @@ less.Parser = function Parser(env) {
|
||||
|
||||
restore();
|
||||
},
|
||||
font: function () {
|
||||
var value = [], expression = [], weight, shorthand, font, e;
|
||||
|
||||
while (e = $(this.shorthand) || $(this.entity)) {
|
||||
expression.push(e);
|
||||
}
|
||||
value.push(new(tree.Expression)(expression));
|
||||
|
||||
if ($(',')) {
|
||||
while (e = $(this.expression)) {
|
||||
value.push(e);
|
||||
if (! $(',')) { break }
|
||||
}
|
||||
}
|
||||
return new(tree.Value)(value);
|
||||
},
|
||||
|
||||
//
|
||||
// A Value is a comma-delimited list of Expressions
|
||||
@@ -1425,10 +1374,11 @@ less.Parser = function Parser(env) {
|
||||
|
||||
if ($('(')) {
|
||||
parens++;
|
||||
e = $(this.expression);
|
||||
expect(')');
|
||||
parens--;
|
||||
return e;
|
||||
if (e = $(this.expression)) {
|
||||
expect(')');
|
||||
parens--;
|
||||
return e;
|
||||
}
|
||||
}
|
||||
},
|
||||
multiplication: function () {
|
||||
@@ -1515,6 +1465,9 @@ less.Parser = function Parser(env) {
|
||||
|
||||
while (e = $(this.addition) || $(this.entity)) {
|
||||
entities.push(e);
|
||||
if (!peek(/^\/\*/) && (delim = $('/'))) {
|
||||
entities.push(new(tree.Anonymous)(delim));
|
||||
}
|
||||
}
|
||||
if (entities.length > 0) {
|
||||
return new(tree.Expression)(entities);
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
(function (tree) {
|
||||
|
||||
tree.Ratio = function (value) {
|
||||
this.value = value;
|
||||
};
|
||||
tree.Ratio.prototype = {
|
||||
toCSS: function (env) {
|
||||
return this.value;
|
||||
},
|
||||
eval: function () { return this }
|
||||
};
|
||||
|
||||
})(require('../tree'));
|
||||
@@ -73,12 +73,12 @@ p::before {
|
||||
}
|
||||
}
|
||||
.units {
|
||||
font: 1.2rem/2rem;
|
||||
font: 8vw/9vw;
|
||||
font: 10vh/12vh;
|
||||
font: 12vm/15vm;
|
||||
font: 12vmin/15vmin;
|
||||
font: 1.2ch/1.5ch;
|
||||
font: 1.2rem / 2rem;
|
||||
font: 8vw / 9vw;
|
||||
font: 10vh / 12vh;
|
||||
font: 12vm / 15vm;
|
||||
font: 12vmin / 15vmin;
|
||||
font: 1.2ch / 1.5ch;
|
||||
}
|
||||
@supports ( box-shadow: 2px 2px 2px black ) or
|
||||
( -moz-box-shadow: 2px 2px 2px black ) {
|
||||
|
||||
@@ -50,16 +50,16 @@ p + h1 {
|
||||
}
|
||||
#shorthands {
|
||||
border: 1px solid #000;
|
||||
font: 12px/16px Arial;
|
||||
font: 100%/16px Arial;
|
||||
font: 12px / 16px Arial;
|
||||
font: 100% / 16px Arial;
|
||||
margin: 1px 0;
|
||||
padding: 0 auto;
|
||||
}
|
||||
#more-shorthands {
|
||||
margin: 0;
|
||||
padding: 1px 0 2px 0;
|
||||
font: normal small/20px 'Trebuchet MS', Verdana, sans-serif;
|
||||
font: 0/0 a;
|
||||
font: normal small / 20px 'Trebuchet MS', Verdana, sans-serif;
|
||||
font: 0 / 0 a;
|
||||
}
|
||||
.misc {
|
||||
-moz-border-radius: 2px;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
max-width: 480;
|
||||
}
|
||||
}
|
||||
@media all and (device-aspect-ratio: 16/9) {
|
||||
@media all and (device-aspect-ratio: 16 / 9) {
|
||||
body {
|
||||
max-width: 800px;
|
||||
}
|
||||
@@ -169,7 +169,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@media (-webkit-min-device-pixel-ratio: 2), (min--moz-device-pixel-ratio: 2), (-o-min-device-pixel-ratio: 2/1), (min-resolution: 2dppx), (min-resolution: 128dpcm) {
|
||||
@media (-webkit-min-device-pixel-ratio: 2), (min--moz-device-pixel-ratio: 2), (-o-min-device-pixel-ratio: 2 / 1), (min-resolution: 2dppx), (min-resolution: 128dpcm) {
|
||||
.b {
|
||||
background: red;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
body { max-width: @base * 60; }
|
||||
}
|
||||
|
||||
@media all and (device-aspect-ratio: 16/9) {
|
||||
@media all and (device-aspect-ratio: 16 / 9) {
|
||||
body { max-width: 800px; }
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ body {
|
||||
}
|
||||
}
|
||||
|
||||
@media (-webkit-min-device-pixel-ratio: 2), (min--moz-device-pixel-ratio: 2), (-o-min-device-pixel-ratio: 2/1), (min-resolution: 2dppx), (min-resolution: 128dpcm) {
|
||||
@media (-webkit-min-device-pixel-ratio: 2), (min--moz-device-pixel-ratio: 2), (-o-min-device-pixel-ratio: 2 / 1), (min-resolution: 2dppx), (min-resolution: 128dpcm) {
|
||||
.b {
|
||||
background: red;
|
||||
}
|
||||
@@ -204,4 +204,4 @@ body {
|
||||
@media (max-width: 900px) {
|
||||
body { font-size: 11px; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user