mirror of
https://github.com/less/less.js.git
synced 2026-01-23 06:07:56 -05:00
Merge pull request #458 from fat/assignment-entities
Assignment entities
This commit is contained in:
@@ -73,11 +73,12 @@ var less = {
|
||||
}
|
||||
};
|
||||
|
||||
['color', 'directive', 'operation', 'dimension',
|
||||
'keyword', 'variable', 'ruleset', 'element',
|
||||
'selector', 'quoted', 'expression', 'rule',
|
||||
'call', 'url', 'alpha', 'import',
|
||||
'mixin', 'comment', 'anonymous', 'value', 'javascript'
|
||||
['color', 'directive', 'operation', 'dimension',
|
||||
'keyword', 'variable', 'ruleset', 'element',
|
||||
'selector', 'quoted', 'expression', 'rule',
|
||||
'call', 'url', 'alpha', 'import',
|
||||
'mixin', 'comment', 'anonymous', 'value',
|
||||
'javascript', 'assignment'
|
||||
].forEach(function (n) {
|
||||
require('./tree/' + n);
|
||||
});
|
||||
|
||||
@@ -502,7 +502,7 @@ less.Parser = function Parser(env) {
|
||||
call: function () {
|
||||
var name, args, index = i;
|
||||
|
||||
if (! (name = /^([\w-]+|%)\(/.exec(chunks[j]))) return;
|
||||
if (! (name = /^([\w-]+|%|progid:[\w\.]+)\(/.exec(chunks[j]))) return;
|
||||
|
||||
name = name[1].toLowerCase();
|
||||
|
||||
@@ -522,7 +522,7 @@ less.Parser = function Parser(env) {
|
||||
arguments: function () {
|
||||
var args = [], arg;
|
||||
|
||||
while (arg = $(this.expression)) {
|
||||
while (arg = $(this.entities.assignment) || $(this.expression)) {
|
||||
args.push(arg);
|
||||
if (! $(',')) { break }
|
||||
}
|
||||
@@ -534,6 +534,19 @@ less.Parser = function Parser(env) {
|
||||
$(this.entities.quoted);
|
||||
},
|
||||
|
||||
// Assignments are argument entities for calls.
|
||||
// They are present in ie filter properties as shown below.
|
||||
//
|
||||
// filter: progid:DXImageTransform.Microsoft.Alpha( *opacity=50* )
|
||||
//
|
||||
|
||||
assignment: function () {
|
||||
var key, value;
|
||||
if ((key = $(/^\w+(?=\s?=)/i)) && $('=') && (value = $(this.entity))) {
|
||||
return new(tree.Assignment)(key, value);
|
||||
}
|
||||
},
|
||||
|
||||
//
|
||||
// Parse url() tokens
|
||||
//
|
||||
|
||||
17
lib/less/tree/assignment.js
Normal file
17
lib/less/tree/assignment.js
Normal file
@@ -0,0 +1,17 @@
|
||||
(function (tree) {
|
||||
|
||||
tree.Assignment = function (key, val) {
|
||||
this.key = key;
|
||||
this.value = val;
|
||||
};
|
||||
tree.Assignment.prototype = {
|
||||
toCSS: function () {
|
||||
return this.key + '=' + (this.value.toCSS ? this.value.toCSS() : this.value);
|
||||
},
|
||||
eval: function (env) {
|
||||
if (this.value.eval) { this.value = this.value.eval(env) }
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
})(require('../tree'));
|
||||
5
test/css/ie-filters.css
Normal file
5
test/css/ie-filters.css
Normal file
@@ -0,0 +1,5 @@
|
||||
.nav {
|
||||
filter: progid:dximagetransform.microsoft.alpha(opacity=20);
|
||||
filter: progid:dximagetransform.microsoft.alpha(opacity=0);
|
||||
filter: progid:dximagetransform.microsoft.gradient(startColorstr="#333333", endColorstr="#000000", GradientType=0);
|
||||
}
|
||||
8
test/less/ie-filters.less
Normal file
8
test/less/ie-filters.less
Normal file
@@ -0,0 +1,8 @@
|
||||
@fat: 0;
|
||||
@cloudhead: "#000000";
|
||||
|
||||
.nav {
|
||||
filter: progid:DXImageTransform.Microsoft.Alpha(opacity = 20);
|
||||
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=@fat);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#333333", endColorstr=@cloudhead, GradientType=@fat);
|
||||
}
|
||||
Reference in New Issue
Block a user