Changed parser to avoid all alpha() calls being parsed as IE style functions and added relevant tests. Fixes #669

Conflicts:

	test/css/colors.css
	test/less/colors.less
This commit is contained in:
DocLabyrinth
2012-03-04 21:55:54 +00:00
committed by Luke Page
parent 3be05a1c7b
commit e6e41fac6f
3 changed files with 42 additions and 4 deletions

View File

@@ -563,7 +563,7 @@ less.Parser = function Parser(env) {
// The arguments are parsed with the `entities.arguments` parser.
//
call: function () {
var name, args, index = i;
var name, args, alpha_ret, index = i;
if (! (name = /^([\w-]+|%|progid:[\w\.]+)\(/.exec(chunks[j]))) return;
@@ -572,7 +572,12 @@ less.Parser = function Parser(env) {
if (name === 'url') { return null }
else { i += name.length }
if (name === 'alpha') { return $(this.alpha) }
if (name === 'alpha') {
alpha_ret = $(this.alpha);
if(typeof alpha_ret !== 'undefined') {
return alpha_ret;
}
}
$('('); // Parse the '(' and consume whitespace.

View File

@@ -60,3 +60,18 @@
color: transparent;
background-color: rgba(0, 0, 0, 0);
}
#alpha #fromvar {
opacity: 0.7;
}
#alpha #short {
opacity: 1;
}
#alpha #long {
opacity: 1;
}
#alpha #rgba {
opacity: 0.2;
}
#alpha #hsl {
opacity: 1;
}

View File

@@ -66,5 +66,23 @@
.transparent {
color: transparent;
background-color: rgba(0, 0, 0, 0);
}
background-color: rgba(0, 0, 0, 0);
}
#alpha {
@colorvar: rgba(150, 200, 150, 0.7);
#fromvar {
opacity: alpha(@colorvar);
}
#short {
opacity: alpha(#aaa);
}
#long {
opacity: alpha(#bababa);
}
#rgba {
opacity: alpha(rgba(50, 120, 95, 0.2));
}
#hsl {
opacity: alpha(hsl(120, 100%, 50%));
}
}